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>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.version}</version>
</plugin>
</plugins>
</build>

View File

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