@@ -145,16 +145,42 @@ class GRpcJobKillServiceImplSpec extends Specification {
145
145
0 * this . agentRoutingService. isAgentConnectionLocal(this . jobId)
146
146
noExceptionThrown()
147
147
148
- when : " The job is active, the agent is connected, the job is local but no observer"
148
+ when : " The job is active, the agent is connected, the job is local but no observer, and force updating job status succeeded "
149
149
this . serviceSpy. killJob(this . jobId, this . reason, this . servletRequest)
150
150
151
- then : " Correct exception is thrown"
151
+ then : " The database is updated and no exception is thrown"
152
152
1 * this . persistenceService. getJobStatus(this . jobId) >> JobStatus . CLAIMED
153
- 0 * this . persistenceService. updateJobStatus(_ as String , _ as JobStatus , _ as JobStatus , _ as String )
153
+ 1 * this . persistenceService. updateJobStatus(_ as String , _ as JobStatus , _ as JobStatus , _ as String )
154
154
1 * this . agentRoutingService. isAgentConnectionLocal(this . jobId) >> true
155
155
0 * this . responseObserver. onNext(_ as JobKillRegistrationResponse )
156
156
0 * this . responseObserver. onCompleted()
157
- thrown(GenieServerException )
157
+ noExceptionThrown()
158
+
159
+ when : " The job is active, the agent is connected, the job is local but no observer, and current job status is invalid for updating"
160
+ this . serviceSpy. killJob(this . jobId, this . reason, this . servletRequest)
161
+
162
+ then : " The database is not updated and GenieInvalidStatusException is thrown"
163
+ 1 * this . persistenceService. getJobStatus(this . jobId) >> JobStatus . CLAIMED
164
+ 1 * this . persistenceService. updateJobStatus(this . jobId, JobStatus . CLAIMED , JobStatus . KILLED , this . reason) >> {
165
+ throw new GenieInvalidStatusException ()
166
+ }
167
+ 1 * this . agentRoutingService. isAgentConnectionLocal(this . jobId) >> true
168
+ 0 * this . responseObserver. onNext(_ as JobKillRegistrationResponse )
169
+ 0 * this . responseObserver. onCompleted()
170
+ thrown(GenieInvalidStatusException )
171
+
172
+ when : " The job is active, the agent is connected, the job is local but no observer, and the job is not found"
173
+ this . serviceSpy. killJob(this . jobId, this . reason, this . servletRequest)
174
+
175
+ then : " The database is not updated and GenieJobNotFoundException is thrown"
176
+ 1 * this . persistenceService. getJobStatus(this . jobId) >> JobStatus . CLAIMED
177
+ 1 * this . persistenceService. updateJobStatus(this . jobId, JobStatus . CLAIMED , JobStatus . KILLED , this . reason) >> {
178
+ throw new NotFoundException ()
179
+ }
180
+ 1 * this . agentRoutingService. isAgentConnectionLocal(this . jobId) >> true
181
+ 0 * this . responseObserver. onNext(_ as JobKillRegistrationResponse )
182
+ 0 * this . responseObserver. onCompleted()
183
+ thrown(GenieJobNotFoundException )
158
184
159
185
when : " The job is active, the agent is connected, and there is an observer"
160
186
this . serviceSpy. registerForKillNotification(this . request, this . responseObserver)
0 commit comments