Added test for partial submission

This commit is contained in:
neviyn 2019-03-05 11:37:42 +00:00
parent 9ae1544b22
commit 4e81e9a5b9
2 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package uk.co.neviyn.observationdatabase
import junit.framework.TestCase.assertFalse
import junit.framework.TestCase.assertNotNull
import org.junit.Test
import org.junit.runner.RunWith
@ -22,5 +23,6 @@ class ObservationDatabaseApplicationTests {
fun contextLoads() {
assertNotNull(observationsController)
assertNotNull(groupSessionController)
assertFalse(GroupSessionManager.isValid())
}
}

View File

@ -137,4 +137,17 @@ class GroupSessionControllerTest {
val rc = RatingComponent(rating = 5)
controller.addGroupObservation(GroupObservation("A Student", listOf(Scenario(0, "Different Title", rc, rc, rc, rc, rc, rc, rc, rc))))
}
@Test
fun testSubmit_PartialData() {
val site = Site(1, "Test site")
Mockito.doReturn(Optional.of(site)).`when`(siteRepository).findById(1)
Mockito.doReturn(listOf(Tutor(1, "Mr X", site))).`when`(tutorRepository).findAllById(listOf(1))
controller.startGroupObservation(GroupObservationInit(1, TrainingType.INITIAL, listOf(1), listOf("Sample title")))
val rc = RatingComponent(rating = 5)
controller.addGroupObservation(GroupObservation("A Student", listOf(Scenario(0, "Sample title", RatingComponent(rating = 0), rc, rc, rc, rc, rc, rc, rc))))
assertEquals(1, GroupSessionManager.observations.size)
assertEquals("A Student", GroupSessionManager.observations.keys.first())
assertEquals("A Student", GroupSessionManager.observations.values.first().person)
}
}