From 9435befee3ae5800d1f826694246981d6d060ac2 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Wed, 10 Oct 2018 13:37:09 +0100 Subject: [PATCH] Removed unused route and accompanying data structure. --- .../uk/co/neviyn/observationdatabase/Api.kt | 11 ---- .../neviyn/observationdatabase/Controller.kt | 9 ---- .../observationdatabase/ControllerTest.kt | 52 ------------------- 3 files changed, 72 deletions(-) diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt index ecc7ebc..b7fe4fc 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt @@ -16,17 +16,6 @@ data class NewTutor( val siteId: Long ) -data class SimpleObservation( - val date: LocalDate, - val type: TrainingType, - val observed: String, - val whom: String, - val entries: List -) { - constructor(observation: Observation) : this(observation.date, observation.type, - observation.observed, observation.whom, observation.entries) -} - data class NewObservation( val site: Long, val type: TrainingType, diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt index 8c0d6dc..6117e05 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt @@ -71,15 +71,6 @@ class Controller { return nameValue } - /** - * Get all observations overseen by the tutor with [id]. - */ - @GetMapping("/tutor/{id}/observations") - fun getObservationsForTutor(@PathVariable(value = "id") id: Long): List = - tutorRepository.findById(id).map { tutor -> - tutor.observations.map { SimpleObservation(it) } - }.orElse(listOf()) - /** * Add a new observation to the database using data provided in [newObservation]. */ 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 de8cf7c..8c965f6 100644 --- a/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt +++ b/backend/src/test/kotlin/uk/co/neviyn/observationdatabase/ControllerTest.kt @@ -87,58 +87,6 @@ class ControllerTest { assertEquals(NameValue("Foo", 1), result) } - @Test - fun testGetObservationsForTutor() { - val site = Site(1, "X") - val tutor = Tutor(1, "Foo Bar", site) - val observations = listOf(Observation( - site = site, - date = LocalDate.now(), - type = TrainingType.INITIAL, - observed = "1", - whom = "G1", - monitoring = 5.0, - control = 4.0, - conservatism = 3.0, - teamwork = 2.0, - knowledge = 1.0, - entries = listOf(), - tutors = setOf(tutor) - ), Observation( - site = site, - date = LocalDate.now(), - type = TrainingType.INITIAL, - observed = "2", - whom = "G2", - monitoring = 5.0, - control = 4.0, - conservatism = 3.0, - teamwork = 2.0, - knowledge = 1.0, - entries = listOf(), - tutors = setOf(tutor) - )) - tutor.observations.addAll(observations) - doReturn(Optional.of(tutor)).`when`(tutorRepository).findById(1) - val result = controller.getObservationsForTutor(1) - for (i in 0..1) { - val expected = observations[i] - val actual = result[i] - assertEquals(expected.date, actual.date) - assertEquals(expected.type, actual.type) - assertEquals(expected.observed, actual.observed) - assertEquals(expected.whom, actual.whom) - assertEquals(expected.entries, actual.entries) - } - } - - @Test - fun testGetObservationsForTutor_NoTutor() { - doReturn(Optional.ofNullable(null)).`when`(tutorRepository).findById(1) - val result = controller.getObservationsForTutor(1) - assertTrue(result.isEmpty()) - } - @Test fun testAddObservation() { val site = Site(1, "X")