@Test void should_not_update_customers_when_agent_polls_the_second_time() { Instant inThePast = NOW.minus(3, DAYS); Instant inTheFuture = NOW.plus(7, DAYS); CustomerData customerData = CustomerData.builder() .customerId(1L) .source("test") .customerName("customerName") .pricePlan(PricePlan.of(PricePlanDefaults.TEST)) .collectionStartedAt(inThePast) .trialPeriodEndsAt(inTheFuture) .build(); CustomerData data = service.registerAgentPoll(customerData, NOW); assertThat(data.getCollectionStartedAt(), is(inThePast)); assertThat(data.getTrialPeriodEndsAt(), is(inTheFuture)); verifyNoInteractions(jdbcTemplate, eventService); }
@Override @Transactional public CustomerData registerAgentPoll(CustomerData customerData, Instant polledAt) { CustomerData result = customerData; if (customerData.getCollectionStartedAt() == null) { result = recordCollectionStarted(result, polledAt); } return result; }
CustomerServiceImpl implements CustomerService { @Override @Transactional public CustomerData registerAgentPoll(CustomerData customerData, Instant polledAt) { CustomerData result = customerData; if (customerData.getCollectionStartedAt() == null) { result = recordCollectionStarted(result, polledAt); } return result; } }
CustomerServiceImpl implements CustomerService { @Override @Transactional public CustomerData registerAgentPoll(CustomerData customerData, Instant polledAt) { CustomerData result = customerData; if (customerData.getCollectionStartedAt() == null) { result = recordCollectionStarted(result, polledAt); } return result; }  }
CustomerServiceImpl implements CustomerService { @Override @Transactional public CustomerData registerAgentPoll(CustomerData customerData, Instant polledAt) { CustomerData result = customerData; if (customerData.getCollectionStartedAt() == null) { result = recordCollectionStarted(result, polledAt); } return result; }  @PostConstruct @Transactional void ensurePricePlansExistInDatabase(); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) CustomerData getCustomerDataByLicenseKey(@NonNull String licenseKey); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) CustomerData getCustomerDataByCustomerId(long customerId); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) List<CustomerData> getCustomerDataByUserEmail(String email); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) CustomerData getCustomerDataByExternalId(
      @NonNull String source, @NonNull String externalId); @Override @Transactional(readOnly = true) void assertPublicationSize(CustomerData customerData, int publicationSize); @Override @Transactional(readOnly = true) void assertDatabaseSize(long customerId); @Override @Transactional(readOnly = true) int countMethods(long customerId); @Override @Transactional CustomerData registerAgentPoll(CustomerData customerData, Instant polledAt); @Override @Transactional void registerLogin(LoginRequest request); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) AddCustomerResponse addCustomer(AddCustomerRequest request); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) void changePlanForExternalId(
      String source, @NonNull String externalId, @NonNull String newPlanName); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) void deleteCustomerByExternalId(@NonNull String source, String externalId); @Override @Transactional(readOnly = true) @Cacheable(ROLES_CACHE) List<String> getRoleNamesByUserEmail(String email); @Override @Transactional(readOnly = true) @Secured(Roles.ADMIN) List<CustomerData> getCustomerData(); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) void updateAppDetails(String appName, String contactEmail, Long customerId); }
CustomerServiceImpl implements CustomerService { @Override @Transactional public CustomerData registerAgentPoll(CustomerData customerData, Instant polledAt) { CustomerData result = customerData; if (customerData.getCollectionStartedAt() == null) { result = recordCollectionStarted(result, polledAt); } return result; }  @PostConstruct @Transactional void ensurePricePlansExistInDatabase(); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) CustomerData getCustomerDataByLicenseKey(@NonNull String licenseKey); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) CustomerData getCustomerDataByCustomerId(long customerId); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) List<CustomerData> getCustomerDataByUserEmail(String email); @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) CustomerData getCustomerDataByExternalId(
      @NonNull String source, @NonNull String externalId); @Override @Transactional(readOnly = true) void assertPublicationSize(CustomerData customerData, int publicationSize); @Override @Transactional(readOnly = true) void assertDatabaseSize(long customerId); @Override @Transactional(readOnly = true) int countMethods(long customerId); @Override @Transactional CustomerData registerAgentPoll(CustomerData customerData, Instant polledAt); @Override @Transactional void registerLogin(LoginRequest request); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) AddCustomerResponse addCustomer(AddCustomerRequest request); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) void changePlanForExternalId(
      String source, @NonNull String externalId, @NonNull String newPlanName); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) void deleteCustomerByExternalId(@NonNull String source, String externalId); @Override @Transactional(readOnly = true) @Cacheable(ROLES_CACHE) List<String> getRoleNamesByUserEmail(String email); @Override @Transactional(readOnly = true) @Secured(Roles.ADMIN) List<CustomerData> getCustomerData(); @Override @Transactional @CacheEvict(value = CUSTOMERS_CACHE, allEntries = true) void updateAppDetails(String appName, String contactEmail, Long customerId);  }