@Test public void testFindOneReturnsNullWhenIdNotFound() { TestEntity actual = repository.findOne("non-existent ID"); assertThat(actual, is(nullValue())); }
@Test public void testFindOne() { List<TestEntity> values = Arrays.asList(1, 2) .stream() .map( v -> { TestEntity t = new TestEntity(); t.setStringProperty(String.format("Hello %s time(s)", v)); return t; }) .collect(Collectors.toList()); repository.save(values); TestEntity actual = repository.findOne(values.get(1).getId()); assertNotNull("Checking that the result is not null.", actual); assertEquals( "Checking that the list is the expected size.", values.get(1).getId(), actual.getId()); assertEquals( "Checking that the list is the expected size.", values.get(1).getStringProperty(), actual.getStringProperty()); }