Removed unused route and accompanying data structure.
This commit is contained in:
parent
0fcfcfaa09
commit
9435befee3
@ -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<Entry>
|
||||
) {
|
||||
constructor(observation: Observation) : this(observation.date, observation.type,
|
||||
observation.observed, observation.whom, observation.entries)
|
||||
}
|
||||
|
||||
data class NewObservation(
|
||||
val site: Long,
|
||||
val type: TrainingType,
|
||||
|
@ -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<SimpleObservation> =
|
||||
tutorRepository.findById(id).map { tutor ->
|
||||
tutor.observations.map { SimpleObservation(it) }
|
||||
}.orElse(listOf())
|
||||
|
||||
/**
|
||||
* Add a new observation to the database using data provided in [newObservation].
|
||||
*/
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user