Added verification of websocket invocation

This commit is contained in:
neviyn 2019-03-05 09:19:09 +00:00
parent ff2618cc5d
commit 7abd2c7a90

View File

@ -103,6 +103,7 @@ class GroupSessionControllerTest {
controller.addGroupObservation(GroupObservation("A Student", listOf(scenario))) controller.addGroupObservation(GroupObservation("A Student", listOf(scenario)))
controller.pushObservationsToDatabase() controller.pushObservationsToDatabase()
verify(observationRepository, times(1)).save(any()) verify(observationRepository, times(1)).save(any())
verify(websocketMessenger, times(1)).convertAndSend("/ws/scenarios", mapOf("scenarios" to mapOf("Sample title" to listOf(scenario.copy(title = "A Student")))))
assertEquals(1, tutor.observations.size) assertEquals(1, tutor.observations.size)
} }
@ -123,6 +124,7 @@ class GroupSessionControllerTest {
controller.startGroupObservation(GroupObservationInit(1, TrainingType.INITIAL, listOf(1), listOf("Sample title"))) controller.startGroupObservation(GroupObservationInit(1, TrainingType.INITIAL, listOf(1), listOf("Sample title")))
val rc = RatingComponent(rating = 5) 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)))) controller.addGroupObservation(GroupObservation("A Student", listOf(Scenario(0, "Sample title", RatingComponent(rating = 0), rc, rc, rc, rc, rc, rc, rc))))
verify(websocketMessenger, times(1)).convertAndSend("/ws/scenarios", mapOf("scenarios" to mapOf("Sample title" to listOf(Scenario(0, "A Student", RatingComponent(rating = 0), rc, rc, rc, rc, rc, rc, rc)))))
controller.pushObservationsToDatabase() controller.pushObservationsToDatabase()
} }