Added test for controller search with person.
This commit is contained in:
parent
680fe08a9e
commit
474fbe18da
@ -21,6 +21,8 @@ class ControllerTest {
|
||||
lateinit var tutorRepository: TutorRepository
|
||||
@Mock
|
||||
lateinit var observationRepository: ObservationRepository
|
||||
@Mock
|
||||
lateinit var personRepository: PersonRepository
|
||||
|
||||
@Test
|
||||
fun testGetSites() {
|
||||
@ -172,4 +174,22 @@ class ControllerTest {
|
||||
assertEquals(1, result.size)
|
||||
assertEquals(observation, result[0])
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGetObservations_WithPerson() {
|
||||
val request = ObservationsRequest(1, null, null, "Foo Bar", LocalDate.now(), LocalDate.now())
|
||||
val site = Site(1, "Area 51")
|
||||
val tutor = Tutor(1, "Mr Unknown", site)
|
||||
val person = Person(1, "Foo Bar")
|
||||
val observation = Observation(site = site, date = LocalDate.now(),
|
||||
type = TrainingType.INITIAL, observed = "1", whom = "Group A", monitoring = 5.0, controlProcedural = 3.0,
|
||||
control = 4.0, conservatism = 3.0, teamworkCommunications = 2.0, teamworkLeadership = 3.0,
|
||||
teamworkWorkload = 1.0, knowledge = 1.0, entries = listOf(), tutors = setOf(tutor), persons = setOf(person))
|
||||
doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
|
||||
doReturn(person).`when`(personRepository).findByName("Foo Bar")
|
||||
doReturn(listOf(observation)).`when`(observationRepository).findBySiteAndPersonsAndDateBetween(site, person, LocalDate.now(), LocalDate.now())
|
||||
val result = controller.getObservations(request)
|
||||
assertEquals(1, result.size)
|
||||
assertEquals(observation, result[0])
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user