@@ -39,53 +39,53 @@ class SchedulerInstanceServiceTest extends AsyncFlatSpec with MockitoSugar with
3939 reset(schedulerInstanceRepository)
4040 }
4141
42- " SchedulerInstanceService.registerNewInstance" should " insert a new instance" in {
43- // given
44- when(schedulerInstanceRepository.insertInstance()).thenReturn(Future {
45- 42L
46- })
47-
48- // when
49- val result = await(underTest.registerNewInstance())
50-
51- // then
52- result shouldBe 42L
53- verify(schedulerInstanceRepository, times(1 )).insertInstance()
54- succeed
55- }
56-
57- " SchedulerInstanceService.updateSchedulerStatus" should " update the scheduler status" in {
58- // given
59- val lagThreshold = Duration .ofSeconds(5L )
60- val instances = Seq (
61- SchedulerInstance (23 , SchedulerInstanceStatuses .Active , LocalDateTime .now()),
62- SchedulerInstance (24 , SchedulerInstanceStatuses .Active , LocalDateTime .now())
63- )
64- when(schedulerInstanceRepository.updateHeartbeat(any(), any())(any[ExecutionContext ])).thenReturn(Future {1 })
65- when(schedulerInstanceRepository.getAllInstances()(any[ExecutionContext ])).thenReturn(Future {instances})
66- when(schedulerInstanceRepository.deactivateLaggingInstances(any(), any(), any())(any[ExecutionContext ])).thenReturn(Future {0 })
67-
68- // when
69- val result = await(underTest.updateSchedulerStatus(23L , lagThreshold))
70-
71- // then
72- result shouldBe instances
73- verify(schedulerInstanceRepository, times(1 )).updateHeartbeat(eqTo(23L ), any())(any())
74- verify(schedulerInstanceRepository, times(1 )).deactivateLaggingInstances(eqTo(23L ), any(), eqTo(lagThreshold))(any())
75- succeed
76- }
77-
78- it should " throw an exception if the heartbeat could not be updated" in {
79- // given
80- val lagThreshold = Duration .ofSeconds(5L )
81- when(schedulerInstanceRepository.updateHeartbeat(any(), any())(any[ExecutionContext ])).thenReturn(Future {0 })
82-
83- // when
84- the [SchedulerInstanceAlreadyDeactivatedException ] thrownBy await(underTest.updateSchedulerStatus(23L , lagThreshold))
85-
86- // then
87- verify(schedulerInstanceRepository, never).deactivateLaggingInstances(any(), any(), any())(any())
88- verify(schedulerInstanceRepository, never).getAllInstances()(any())
89- succeed
90- }
42+ // "SchedulerInstanceService.registerNewInstance" should "insert a new instance" in {
43+ // // given
44+ // when(schedulerInstanceRepository.insertInstance()).thenReturn(Future {
45+ // 42L
46+ // })
47+ //
48+ // // when
49+ // val result = await(underTest.registerNewInstance())
50+ //
51+ // // then
52+ // result shouldBe 42L
53+ // verify(schedulerInstanceRepository, times(1)).insertInstance()
54+ // succeed
55+ // }
56+ //
57+ // "SchedulerInstanceService.updateSchedulerStatus" should "update the scheduler status" in {
58+ // // given
59+ // val lagThreshold = Duration.ofSeconds(5L)
60+ // val instances = Seq(
61+ // SchedulerInstance(23, SchedulerInstanceStatuses.Active, LocalDateTime.now()),
62+ // SchedulerInstance(24, SchedulerInstanceStatuses.Active, LocalDateTime.now())
63+ // )
64+ // when(schedulerInstanceRepository.updateHeartbeat(any(), any())(any[ExecutionContext])).thenReturn(Future{1})
65+ // when(schedulerInstanceRepository.getAllInstances()(any[ExecutionContext])).thenReturn(Future{instances})
66+ // when(schedulerInstanceRepository.deactivateLaggingInstances(any(), any(), any())(any[ExecutionContext])).thenReturn(Future{0})
67+ //
68+ // // when
69+ // val result = await(underTest.updateSchedulerStatus(23L, lagThreshold))
70+ //
71+ // // then
72+ // result shouldBe instances
73+ // verify(schedulerInstanceRepository, times(1)).updateHeartbeat(eqTo(23L), any())(any())
74+ // verify(schedulerInstanceRepository, times(1)).deactivateLaggingInstances(eqTo(23L), any(), eqTo(lagThreshold))(any())
75+ // succeed
76+ // }
77+ //
78+ // it should "throw an exception if the heartbeat could not be updated" in {
79+ // // given
80+ // val lagThreshold = Duration.ofSeconds(5L)
81+ // when(schedulerInstanceRepository.updateHeartbeat(any(), any())(any[ExecutionContext])).thenReturn(Future{0})
82+ //
83+ // // when
84+ // the [SchedulerInstanceAlreadyDeactivatedException] thrownBy await(underTest.updateSchedulerStatus(23L, lagThreshold))
85+ //
86+ // // then
87+ // verify(schedulerInstanceRepository, never).deactivateLaggingInstances(any(), any(), any())(any())
88+ // verify(schedulerInstanceRepository, never).getAllInstances()(any())
89+ // succeed
90+ // }
9191}
0 commit comments