BAEL-1304 changes after code review

This commit is contained in:
abialas 2017-12-15 23:43:51 +01:00
parent b1323faaf3
commit 970de81734
2 changed files with 20 additions and 27 deletions

View File

@ -72,6 +72,7 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.version}</version>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -22,38 +22,30 @@ import static org.hamcrest.core.IsNull.notNullValue;
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD)
public class PersonsRepositoryTest { public class PersonsRepositoryTest {
@Autowired @Autowired
private PersonsRepository personsRepository; private PersonsRepository personsRepository;
@Test @Test
public void shouldAddOnePersonToDB() { public void givenPerson_whenSave_thenAddOnePersonToDB() {
// when personsRepository.save(new Person());
personsRepository.save(new Person()); assertThat(personsRepository.findAll().spliterator().getExactSizeIfKnown(), equalTo(1l));
}
// then @Test
assertThat(personsRepository.findAll() public void givenPersonsAdamAndDaveInDB_whenSearchForPersonWithNameAdam_thenFindOnePerson() {
.spliterator() Person person1 = new Person();
.getExactSizeIfKnown(), equalTo(1l)); person1.setFirstName("Adam");
}
@Test Person person2 = new Person();
public void shouldFindOnePersonWithNameAdam() { person2.setFirstName("Dave");
// given
Person person1 = new Person();
person1.setFirstName("Adam");
Person person2 = new Person(); personsRepository.save(person1);
person2.setFirstName("Dave"); personsRepository.save(person2);
personsRepository.save(person1); Person foundPerson = personsRepository.findByFirstName("Adam");
personsRepository.save(person2);
// when assertThat(foundPerson.getFirstName(), equalTo("Adam"));
Person foundPerson = personsRepository.findByFirstName("Adam"); assertThat(foundPerson.getId(), notNullValue());
}
// then
assertThat(foundPerson.getFirstName(), equalTo("Adam"));
assertThat(foundPerson.getId(), notNullValue());
}
} }