DefaultPlaneService implements PlaneService { @Override public String lookup(Long id) { return repository.findById(id).map(Plane::getModel).orElse(null); } DefaultPlaneService(PlaneRepository repository); @Override Long create(String model, String serial); @Override String lookup(Long id); @Override String lookup(String serial);  }
@Test public void testLookupById() { final Plane entity = new Plane(); entity.setModel("Boeing 747"); entity.setSerial("123456"); entity.setCapacity(1000); final Plane saved = repository.save(entity); final String model = service.lookup(saved.getId()); assertThat(model, is(notNullValue())); assertThat(model, is(entity.getModel())); }
@Test public void testLookupBySerial() { final Plane entity = new Plane(); entity.setModel("Boeing 747"); entity.setSerial("123456"); entity.setCapacity(1000); repository.save(entity); final String model = service.lookup(entity.getSerial()); assertThat(model, is(notNullValue())); assertThat(model, is(entity.getModel())); }