DefaultCustomerService implements CustomerService { @Override public List<Customer> findByFirstNamePart(final String part) { return repository.findByFirstNameIgnoreCaseContaining(part); } 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 testLookingUpByFirstNamePart() { createCustomer("Milad", "Naseri", date(1988, 1, 1)); final Customer eric = createCustomer("Eric", "Deandrea", date(1999, 1, 1)); final List<Customer> list = service.findByFirstNamePart("IC"); assertThat(list, is(notNullValue())); assertThat(list, hasSize(1)); assertThat(list.get(0), is(eric)); }