test_class.declarator: restTemplate
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected TestRestTemplate restTemplate;
test_class.type: TestRestTemplate
test_class.var_name: restTemplate
test_class.declarator: objectMapper
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected ObjectMapper objectMapper;
test_class.type: ObjectMapper
test_class.var_name: objectMapper
test_class.declarator: runtimeService
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected RuntimeService runtimeService;
test_class.type: RuntimeService
test_class.var_name: runtimeService
test_class.declarator: taskService
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected TaskService taskService;
test_class.type: TaskService
test_class.var_name: taskService
test_class.declarator: managementService
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected ManagementService managementService;
test_class.type: ManagementService
test_class.var_name: managementService
test_class.declarator: processEngineConfiguration
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected ProcessEngineConfiguration processEngineConfiguration;
test_class.type: ProcessEngineConfiguration
test_class.var_name: processEngineConfiguration
test_class.declarator: cmmnRuntimeService
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected CmmnRuntimeService cmmnRuntimeService;
test_class.type: CmmnRuntimeService
test_class.var_name: cmmnRuntimeService
test_class.declarator: cmmnTaskService
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected CmmnTaskService cmmnTaskService;
test_class.type: CmmnTaskService
test_class.var_name: cmmnTaskService
test_class.declarator: cmmnEngineConfiguration
test_class.modifier: @Autowired
      protected
test_class.original_string: @Autowired
      protected CmmnEngineConfiguration cmmnEngineConfiguration;
test_class.type: CmmnEngineConfiguration
test_class.var_name: cmmnEngineConfiguration
test_class.file: modules/flowable-external-job-rest/src/test/java/org/flowable/external/job/rest/service/api/acquire/ExternalWorkerAcquireJobResourceTest.java
test_class.identifier: ExternalWorkerAcquireJobResourceTest
test_case.body: @Test
      @CmmnDeployment(resources = "org/flowable/external/job/rest/service/api/simpleExternalWorkerJob.cmmn")
      void terminateCmmnJob() {
          cmmnRuntimeService.createCaseInstanceBuilder()
                  .caseDefinitionKey("simpleExternalWorker")
                  .start();
  
          assertThat(cmmnTaskService.createTaskQuery().list()).isEmpty();
  
          ExternalWorkerJob externalWorkerJob = managementService.createExternalWorkerJobQuery().singleResult();
          assertThat(externalWorkerJob).isNotNull();
  
          ObjectNode request = objectMapper.createObjectNode();
          request.put("workerId", "testWorker");
  
          ResponseEntity<String> response = restTemplate
                  .postForEntity("/service/acquire/jobs/{jobId}/cmmnTerminate", request, String.class, externalWorkerJob.getId());
  
          assertThat(response.getStatusCode()).as(response.toString()).isEqualTo(HttpStatus.FORBIDDEN);
          String body = response.getBody();
          assertThat(body).isNotNull();
          assertThatJson(body)
                  .isEqualTo("{"
                          + "  message: 'Forbidden',"
                          + "  exception: 'testWorker does not hold a lock on the requested job'"
                          + "}");
  
          managementService.createExternalWorkerJobAcquireBuilder()
                  .topic("simple", Duration.ofMinutes(10))
                  .acquireAndLock(1, "testWorker1");
  
          request = objectMapper.createObjectNode();
          request.put("workerId", "testWorker2");
  
          response = restTemplate
                  .postForEntity("/service/acquire/jobs/{jobId}/cmmnTerminate", request, String.class, externalWorkerJob.getId());
  
          assertThat(response.getStatusCode()).as(response.toString()).isEqualTo(HttpStatus.FORBIDDEN);
          body = response.getBody();
          assertThat(body).isNotNull();
          assertThatJson(body)
                  .isEqualTo("{"
                          + "  message: 'Forbidden',"
                          + "  exception: 'testWorker2 does not hold a lock on the requested job'"
                          + "}");
  
          request = objectMapper.createObjectNode();
          request.put("workerId", "testWorker1");
  
          response = restTemplate
                  .postForEntity("/service/acquire/jobs/{jobId}/cmmnTerminate", request, String.class, externalWorkerJob.getId());
  
          assertThat(response.getStatusCode()).as(response.toString()).isEqualTo(HttpStatus.NO_CONTENT);
          body = response.getBody();
          assertThat(body).isNull();
  
          CmmnJobTestHelper.waitForJobExecutorToProcessAllJobs(cmmnEngineConfiguration, 4000, 300, true);
  
          assertThat(cmmnTaskService.createTaskQuery().list())
                  .extracting(Task::getTaskDefinitionKey)
                  .containsExactlyInAnyOrder("afterExternalWorkerTerminateTask");
      }
test_case.class_method_signature: ExternalWorkerAcquireJobResourceTest.terminateCmmnJob()
test_case.full_signature: @Test @CmmnDeployment(resources = "org/flowable/external/job/rest/service/api/simpleExternalWorkerJob.cmmn") void terminateCmmnJob()
test_case.identifier: terminateCmmnJob
test_case.invocations: start caseDefinitionKey createCaseInstanceBuilder isEmpty assertThat list createTaskQuery singleResult createExternalWorkerJobQuery isNotNull assertThat createObjectNode put postForEntity getId isEqualTo as assertThat getStatusCode toString getBody isNotNull assertThat isEqualTo assertThatJson acquireAndLock topic createExternalWorkerJobAcquireBuilder ofMinutes createObjectNode put postForEntity getId isEqualTo as assertThat getStatusCode toString getBody isNotNull assertThat isEqualTo assertThatJson createObjectNode put postForEntity getId isEqualTo as assertThat getStatusCode toString getBody isNull assertThat waitForJobExecutorToProcessAllJobs containsExactlyInAnyOrder extracting assertThat list createTaskQuery
test_case.modifiers: @Test @CmmnDeployment(resources = "org/flowable/external/job/rest/service/api/simpleExternalWorkerJob.cmmn")
test_case.parameters: ()
test_case.return: void
test_case.signature: void terminateCmmnJob()
focal_class.declarator: restResponseFactory
focal_class.modifier: protected final
focal_class.original_string: protected final ExternalJobRestResponseFactory restResponseFactory;
focal_class.type: ExternalJobRestResponseFactory
focal_class.var_name: restResponseFactory
focal_class.file: modules/flowable-external-job-rest/src/main/java/org/flowable/external/job/rest/service/api/acquire/ExternalWorkerAcquireJobResource.java
focal_class.identifier: ExternalWorkerAcquireJobResource
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.ExternalWorkerAcquireJobResource(ExternalJobRestResponseFactory restResponseFactory)
focal_class.full_signature: public  ExternalWorkerAcquireJobResource(ExternalJobRestResponseFactory restResponseFactory)
focal_class.identifier: ExternalWorkerAcquireJobResource
focal_class.modifiers: public
focal_class.parameters: (ExternalJobRestResponseFactory restResponseFactory)
focal_class.signature:  ExternalWorkerAcquireJobResource(ExternalJobRestResponseFactory restResponseFactory)
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.acquireAndLockJobs(@RequestBody AcquireExternalWorkerJobRequest request)
focal_class.full_signature: @ApiOperation(value = "Acquire External Worker Jobs", tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 200, message = "Indicates the jobs were acquired and locked."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights acquire the jobs."), }) @PostMapping(value = "/acquire/jobs", produces = "application/json") public List<AcquiredExternalWorkerJobResponse> acquireAndLockJobs(@RequestBody AcquireExternalWorkerJobRequest request)
focal_class.identifier: acquireAndLockJobs
focal_class.modifiers: @ApiOperation(value = "Acquire External Worker Jobs", tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 200, message = "Indicates the jobs were acquired and locked."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights acquire the jobs."), }) @PostMapping(value = "/acquire/jobs", produces = "application/json") public
focal_class.parameters: (@RequestBody AcquireExternalWorkerJobRequest request)
focal_class.return: List<AcquiredExternalWorkerJobResponse>
focal_class.signature: List<AcquiredExternalWorkerJobResponse> acquireAndLockJobs(@RequestBody AcquireExternalWorkerJobRequest request)
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.completeJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobCompleteRequest request)
focal_class.full_signature: @ApiOperation(value = "Complete an External Worker Jobs", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully completed."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/complete", produces = "application/json") public ResponseEntity<?> completeJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobCompleteRequest request)
focal_class.identifier: completeJob
focal_class.modifiers: @ApiOperation(value = "Complete an External Worker Jobs", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully completed."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/complete", produces = "application/json") public
focal_class.parameters: (@PathVariable String jobId, @RequestBody ExternalWorkerJobCompleteRequest request)
focal_class.return: ResponseEntity<?>
focal_class.signature: ResponseEntity<?> completeJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobCompleteRequest request)
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.bpmnErrorJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobErrorRequest request)
focal_class.full_signature: @ApiOperation(value = "Complete an External Worker Job with a BPMN Error", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully completed."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/bpmnError", produces = "application/json") public ResponseEntity<?> bpmnErrorJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobErrorRequest request)
focal_class.identifier: bpmnErrorJob
focal_class.modifiers: @ApiOperation(value = "Complete an External Worker Job with a BPMN Error", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully completed."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/bpmnError", produces = "application/json") public
focal_class.parameters: (@PathVariable String jobId, @RequestBody ExternalWorkerJobErrorRequest request)
focal_class.return: ResponseEntity<?>
focal_class.signature: ResponseEntity<?> bpmnErrorJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobErrorRequest request)
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.terminateCmmnJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)
focal_class.full_signature: @ApiOperation(value = "Complete an External Worker Job with a cmmn terminate transition", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully transitioned."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/cmmnTerminate", produces = "application/json") public ResponseEntity<?> terminateCmmnJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)
focal_class.identifier: terminateCmmnJob
focal_class.modifiers: @ApiOperation(value = "Complete an External Worker Job with a cmmn terminate transition", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully transitioned."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/cmmnTerminate", produces = "application/json") public
focal_class.parameters: (@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)
focal_class.return: ResponseEntity<?>
focal_class.signature: ResponseEntity<?> terminateCmmnJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.failJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobFailureRequest request)
focal_class.full_signature: @ApiOperation(value = "Fail an External Worker Job", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully completed."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/fail", produces = "application/json") public ResponseEntity<?> failJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobFailureRequest request)
focal_class.identifier: failJob
focal_class.modifiers: @ApiOperation(value = "Fail an External Worker Job", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully completed."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/fail", produces = "application/json") public
focal_class.parameters: (@PathVariable String jobId, @RequestBody ExternalWorkerJobFailureRequest request)
focal_class.return: ResponseEntity<?>
focal_class.signature: ResponseEntity<?> failJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobFailureRequest request)
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.extractVariables(List<EngineRestVariable> restVariables)
focal_class.full_signature: protected Map<String, Object> extractVariables(List<EngineRestVariable> restVariables)
focal_class.identifier: extractVariables
focal_class.modifiers: protected
focal_class.parameters: (List<EngineRestVariable> restVariables)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> extractVariables(List<EngineRestVariable> restVariables)
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.createExternalWorkerAcquireBuilder()
focal_class.full_signature: protected ExternalWorkerJobAcquireBuilder createExternalWorkerAcquireBuilder()
focal_class.identifier: createExternalWorkerAcquireBuilder
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: ExternalWorkerJobAcquireBuilder
focal_class.signature: ExternalWorkerJobAcquireBuilder createExternalWorkerAcquireBuilder()
focal_class.class_method_signature: ExternalWorkerAcquireJobResource.createExternalWorkerJobFailureBuilder(String jobId, String workerId)
focal_class.full_signature: protected ExternalWorkerJobFailureBuilder createExternalWorkerJobFailureBuilder(String jobId, String workerId)
focal_class.identifier: createExternalWorkerJobFailureBuilder
focal_class.modifiers: protected
focal_class.parameters: (String jobId, String workerId)
focal_class.return: ExternalWorkerJobFailureBuilder
focal_class.signature: ExternalWorkerJobFailureBuilder createExternalWorkerJobFailureBuilder(String jobId, String workerId)
focal_class.superclass: extends ExternalWorkerJobBaseResource
focal_method.body: @ApiOperation(value = "Complete an External Worker Job with a cmmn terminate transition", code = 204, tags = { "Acquire and Execute" })
      @ApiResponses({
              @ApiResponse(code = 204, message = "Indicates the job was successfully transitioned."),
              @ApiResponse(code = 400, message = "Indicates the request was invalid."),
              @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."),
              @ApiResponse(code = 404, message = "Indicates the job does not exist."),
      })
      @PostMapping(value = "/acquire/jobs/{jobId}/cmmnTerminate", produces = "application/json")
      public ResponseEntity<?> terminateCmmnJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request) {
          String workerId = request.getWorkerId();
          if (StringUtils.isEmpty(workerId)) {
              throw new FlowableIllegalArgumentException("workerId is required");
          }
  
          ExternalWorkerJob job = getExternalWorkerJobById(jobId);
  
          if (!workerId.equals(job.getLockOwner())) {
              throw new FlowableForbiddenException(workerId + " does not hold a lock on the requested job");
          }
  
          if (ScopeTypes.CMMN.equals(job.getScopeType())) {
              if (cmmnManagementService != null) {
                  if (restApiInterceptor != null) {
                      restApiInterceptor.cmmnTerminateExternalWorkerJob(job, request);
                  }
  
                  cmmnManagementService.createCmmnExternalWorkerTransitionBuilder(job.getId(), workerId)
                          .variables(extractVariables(request.getVariables()))
                          .terminate();
              } else {
                  throw new FlowableException("Cannot complete CMMN job. There is no CMMN engine available");
              }
          } else {
              throw new FlowableIllegalArgumentException(
                      "Can only terminate CMMN external job. Job with id '" + jobId + "' is from scope '" + job.getScopeType() + "'");
          }
  
          return ResponseEntity.noContent().build();
      }
focal_method.class_method_signature: ExternalWorkerAcquireJobResource.terminateCmmnJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)
focal_method.full_signature: @ApiOperation(value = "Complete an External Worker Job with a cmmn terminate transition", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully transitioned."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/cmmnTerminate", produces = "application/json") public ResponseEntity<?> terminateCmmnJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)
focal_method.identifier: terminateCmmnJob
focal_method.invocations: getWorkerId isEmpty getExternalWorkerJobById equals getLockOwner equals getScopeType cmmnTerminateExternalWorkerJob terminate variables createCmmnExternalWorkerTransitionBuilder getId extractVariables getVariables getScopeType build noContent
focal_method.modifiers: @ApiOperation(value = "Complete an External Worker Job with a cmmn terminate transition", code = 204, tags = { "Acquire and Execute" }) @ApiResponses({ @ApiResponse(code = 204, message = "Indicates the job was successfully transitioned."), @ApiResponse(code = 400, message = "Indicates the request was invalid."), @ApiResponse(code = 403, message = "Indicates the user does not have the rights complete the job."), @ApiResponse(code = 404, message = "Indicates the job does not exist."), }) @PostMapping(value = "/acquire/jobs/{jobId}/cmmnTerminate", produces = "application/json") public
focal_method.parameters: (@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)
focal_method.return: ResponseEntity<?>
focal_method.signature: ResponseEntity<?> terminateCmmnJob(@PathVariable String jobId, @RequestBody ExternalWorkerJobTerminateRequest request)