Fixed testAddObservation

This commit is contained in:
neviyn 2018-11-30 12:24:31 +00:00
parent d8b3c0040d
commit 3ebaf66a33

View File

@ -89,20 +89,21 @@ class ControllerTest {
assertEquals(NameValue("Foo", 1), result) assertEquals(NameValue("Foo", 1), result)
} }
/** TODO: Fix this test
@Test @Test
fun testAddObservation() { fun testAddObservation() {
val site = Site(1, "X") val site = Site(1, "X")
val tutor = Tutor(1, "Foo Bar", site) val tutor = Tutor(1, "Foo Bar", site)
val person = Person(name = "Mr X")
doReturn(Optional.of(site)).`when`(siteRepository).findById(1) doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
doReturn(listOf(tutor)).`when`(tutorRepository).findAllById(listOf(1)) doReturn(listOf(tutor)).`when`(tutorRepository).findAllById(listOf(1))
val newData = NewObservation(1, TrainingType.INITIAL, "An Observation", "Group A", listOf(Entry(RatingCategory.MONITORING, 5, "", "")), listOf(1), listOf()) doReturn(person).`when`(personRepository).findFirstByNameLike("MR X")
val observation = Observation(1, site, LocalDate.now(), TrainingType.INITIAL, "An Observation", "Group A", 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, newData.scenarios, setOf(tutor), setOf()) val defaultComponent = RatingComponent(rating = 5, strengths = "", improvements = "")
val newData = NewObservation(1, TrainingType.INITIAL, "An Observation", listOf(Scenario(title = "Something", monitoring = defaultComponent, controlProcedural = defaultComponent, control = defaultComponent, conservatism = defaultComponent, teamworkCommunications = defaultComponent, teamworkLeadership = defaultComponent, teamworkWorkload = defaultComponent, knowledge = defaultComponent)), listOf(1), "Mr X")
val observation = Observation(1, site, LocalDate.now(), TrainingType.INITIAL, "An Observation", 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, newData.scenarios, setOf(tutor), person)
doReturn(observation).`when`(observationRepository).save(ArgumentMatchers.any()) doReturn(observation).`when`(observationRepository).save(ArgumentMatchers.any())
val result = controller.addObservation(newData) val result = controller.addObservation(newData)
assertEquals(1L, result) assertEquals(1L, result)
} }
**/
@Test @Test
fun testGetObservations_SiteAndTutorNull() { fun testGetObservations_SiteAndTutorNull() {