DefaultCustomerService implements CustomerService { public Customer findCustomer(long id) { return repository.findById(id).orElse(null); } DefaultCustomerService(CustomerRepository repository); long register(String firstName, String lastName, Date birthday); Customer findCustomer(long id); List<Customer> findCustomersByBirthday(Date from, Date to); List<Customer> findCustomersByName(String firstName, String lastName); List<Customer> findCustomersByFirstNames(Collection<String> firstNames); @Override List<Customer> findByFirstNamePart(final String part);  }
@Test public void testLoadingCustomerById() { final Customer customer = createCustomer("Milad", "Naseri", date(1988, 1, 1)); final Customer loaded = service.findCustomer(customer.getId()); assertThat(loaded, is(notNullValue())); assertThat(loaded.getId(), is(customer.getId())); assertThat(loaded.getBirthday(), is(customer.getBirthday())); assertThat(loaded.getFirstName(), is(customer.getFirstName())); assertThat(loaded.getLastName(), is(customer.getLastName())); }