BAEL-1304 changes after code review
This commit is contained in:
parent
b1323faaf3
commit
970de81734
|
@ -72,6 +72,7 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue