From 3ebaf66a33d149d5e259108dae1826f8c403d405 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Fri, 30 Nov 2018 12:24:31 +0000 Subject: [PATCH] Fixed testAddObservation --- .../uk/co/neviyn/observationdatabase/ControllerTest.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt index b20c57e..d20a4a5 100644 --- a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt +++ b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt @@ -89,20 +89,21 @@ class ControllerTest { assertEquals(NameValue("Foo", 1), result) } - /** TODO: Fix this test @Test fun testAddObservation() { val site = Site(1, "X") val tutor = Tutor(1, "Foo Bar", site) + val person = Person(name = "Mr X") doReturn(Optional.of(site)).`when`(siteRepository).findById(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()) - 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()) + doReturn(person).`when`(personRepository).findFirstByNameLike("MR X") + 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()) val result = controller.addObservation(newData) assertEquals(1L, result) } - **/ @Test fun testGetObservations_SiteAndTutorNull() {