DefaultCustomerService implements CustomerService { public long register(String firstName, String lastName, Date birthday) { final Customer customer = new Customer(); customer.setFirstName(firstName); customer.setLastName(lastName); customer.setBirthday(birthday); return repository.save(customer).getId(); } 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 testCustomerRegistration() { final Date date = date(1988, 0, 1); assertThat(repository.count(), is(0L)); final String firstName = "Milad"; final String lastName = "Naseri"; final long id = service.register(firstName, lastName, date); assertThat(repository.count(), is(1L)); final Customer customer = repository.findById(id).orElse(null); assertThat(customer, is(notNullValue())); assertThat(customer.getId(), is(id)); assertThat(customer.getFirstName(), is(firstName)); assertThat(customer.getLastName(), is(lastName)); assertThat(customer.getBirthday(), is(date)); }