DefaultPlaneService implements PlaneService { @Override public Long create(String model, String serial) { final Plane plane = new Plane(); plane.setModel(model); plane.setCapacity(100); plane.setSerial(serial); return repository.save(plane).getId(); } DefaultPlaneService(PlaneRepository repository); @Override Long create(String model, String serial); @Override String lookup(Long id); @Override String lookup(String serial);  }
@Test public void testCreate() { assertThat(repository.count(), is(0L)); final String model = "F-22"; final String serial = "123456"; final Long id = service.create(model, serial); assertThat(id, is(notNullValue())); final Plane loaded = repository.findById(id).orElse(null); assertThat(loaded, is(notNullValue())); assertThat(loaded.getModel(), is(model)); assertThat(loaded.getSerial(), is(serial)); }