// save a couple of customers service.save(new Customer("Alice", "Smith")); service.save(new Customer("Bob", "Smith"));
// fetch all customers System.out.println("Customers found with findAll():"); System.out.println("-------------------------------"); int count = 0; for (Customer customer : service.findAll()) { System.out.println(customer); count++; } assertThat(count, is(2));
// fetch an individual customer System.out.println("Customer found with findByFirstName('Alice'):"); System.out.println("--------------------------------"); Customer c = service.findByFirstName("Alice"); assertThat(c, notNullValue()); assertThat(c.getFirstName(), is("Alice"));
System.out.println("Customers found with findByLastName('Smith'):"); System.out.println("--------------------------------");
Customers found with findAll(): ------------------------------- Customer[id=5a9a30e616afd63f48afeea6, firstName='Alice', lastName='Smith'] Customer[id=5a9a30e616afd63f48afeea7, firstName='Bob', lastName='Smith'] Customer found with findByFirstName('Alice'): -------------------------------- Customers found with findByLastName('Smith'):