コード例 #1
0
 /**
  * Create new orchestration job test
  *
  * @param int $orchestrationId
  * @return int job ID
  */
 private function runOrchestrationTest($orchestrationId)
 {
     $url = '/orchestrator/run';
     $errorMessage = sprintf("Response for call '%s %s' should return new job.", 'POST', $url);
     $response = $this->callApiPost($url, array('config' => $orchestrationId), 202);
     $this->assertArrayHasKey('id', $response, $errorMessage);
     $this->assertArrayHasKey('orchestrationId', $response, $errorMessage);
     $this->assertArrayHasKey('initializedBy', $response, $errorMessage);
     $this->assertArrayHasKey('url', $response, $errorMessage);
     $this->assertEquals(OrchestrationOrConfigEntity::parseOrchestrationId($orchestrationId), $response['orchestrationId'], $errorMessage);
     $this->assertEquals('manually', $response['initializedBy'], $errorMessage);
     $this->assertArrayHasKey('isFinished', $response);
     $this->assertEquals(false, $response['isFinished']);
     return $response['id'];
 }
コード例 #2
0
 /**
  * Manually execute job
  *
  * @param Request $request
  * @return Response
  */
 public function postJobsAsyncAction(Request $request)
 {
     $orchestrationId = null;
     try {
         $form = $this->createForm(new OrchestrationRunAsyncType($this->dbOrchestrationManager, $this->token));
         $handler = new RestFormHandler($form, $request);
         if ($handler->process()) {
             $orchestrationId = OrchestrationOrConfigEntity::parseOrchestrationId($handler->getPost('config'));
         }
     } catch (HttpException $e) {
         $exception = new OrchestratorException($e->getStatusCode(), $e->getMessage());
         $exception->setExceptionCode('ORCHESTRATION_VALIDATION');
         throw $exception;
     }
     return $this->handlePostJobs($orchestrationId, $request, true);
 }