@Test public void should_return_sensible_CustomerData() { CustomerData data = service.getCustomerDataByLicenseKey("key"); assertThat(data.getCustomerId(), is(1L)); assertThat(data.getPricePlan().getName(), is("TEST")); verifyNoInteractions(eventService); }
@Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) public CustomerData getCustomerDataByLicenseKey(@NonNull String licenseKey) throws AuthenticationCredentialsNotFoundException { try { return getCustomerData("c.licenseKey = ?", licenseKey); } catch (DataAccessException e) { throw new AuthenticationCredentialsNotFoundException( "Invalid license key: '" + licenseKey + "'"); } }
CustomerServiceImpl implements CustomerService { @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) public CustomerData getCustomerDataByLicenseKey(@NonNull String licenseKey) throws AuthenticationCredentialsNotFoundException { try { return getCustomerData("c.licenseKey = ?", licenseKey); } catch (DataAccessException e) { throw new AuthenticationCredentialsNotFoundException( "Invalid license key: '" + licenseKey + "'"); } } }
CustomerServiceImpl implements CustomerService { @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) public CustomerData getCustomerDataByLicenseKey(@NonNull String licenseKey) throws AuthenticationCredentialsNotFoundException { try { return getCustomerData("c.licenseKey = ?", licenseKey); } catch (DataAccessException e) { throw new AuthenticationCredentialsNotFoundException( "Invalid license key: '" + licenseKey + "'"); } }  }
CustomerServiceImpl implements CustomerService { @Override @Transactional(readOnly = true) @Cacheable(CUSTOMERS_CACHE) public CustomerData getCustomerDataByLicenseKey(@NonNull String licenseKey) throws AuthenticationCredentialsNotFoundException { try { return getCustomerData("c.licenseKey = ?", licenseKey); } catch (DataAccessException e) { throw new AuthenticationCredentialsNotFoundException( "Invalid license key: '" + licenseKey + "'"); } }  @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(readOnly = true) @Cacheable(CUSTOMERS_CACHE) public CustomerData getCustomerDataByLicenseKey(@NonNull String licenseKey) throws AuthenticationCredentialsNotFoundException { try { return getCustomerData("c.licenseKey = ?", licenseKey); } catch (DataAccessException e) { throw new AuthenticationCredentialsNotFoundException( "Invalid license key: '" + licenseKey + "'"); } }  @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);  }