public function testRunJob()
 {
     $jobResult = $this->jobExecutor->executeJob(ProcessorRegistry::TYPE_IMPORT, MemberActivityConnector::JOB_IMPORT, [ProcessorRegistry::TYPE_IMPORT => ['channel' => $this->getReference('mailchimp:channel_1')->getId(), 'channelType' => $this->getReference('mailchimp:channel_1')->getType()]]);
     $this->assertTrue($jobResult->isSuccessful(), implode(',', $jobResult->getFailureExceptions()));
     $this->assertEquals(0, $jobResult->getContext()->getErrorEntriesCount(), implode(', ', $jobResult->getContext()->getErrors()));
     $this->assertDatabaseContent($jobResult);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 protected function executeAction($context)
 {
     $jobType = $this->getJobType($context);
     $jobName = $this->getJobName($context);
     $configuration = $this->getConfiguration($context);
     $jobResult = $this->jobExecutor->executeJob($jobType, $jobName, $configuration);
     if (!$jobResult->isSuccessful() && $jobResult->getFailureExceptions()) {
         throw new \RuntimeException(implode(PHP_EOL, $jobResult->getFailureExceptions()));
     }
     $this->contextAccessor->setValue($context, $this->attribute, $jobResult);
 }
Ejemplo n.º 3
0
 /**
  * @param string $jobType
  * @param string $jobName
  * @return JobResult
  */
 protected function executePostProcessingJob($jobType, $jobName)
 {
     $clearSkipped = $this->jobExecutor->isSkipClear();
     $this->jobExecutor->setSkipClear(true);
     $jobResult = $this->jobExecutor->executeJob($jobType, $jobName, $this->getJobConfiguration());
     $this->jobExecutor->setSkipClear($clearSkipped);
     return $jobResult;
 }
Ejemplo n.º 4
0
 public function testExecuteJobFailure()
 {
     $configuration = array('test' => true);
     $this->connection->expects($this->once())->method('getTransactionNestingLevel')->will($this->returnValue(0));
     $this->entityManager->expects($this->once())->method('beginTransaction');
     $this->entityManager->expects($this->once())->method('rollback');
     $this->entityManager->expects($this->never())->method('commit');
     $this->batchJobManager->expects($this->once())->method('persist')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobInstance'));
     $this->batchJobManager->expects($this->once())->method('flush')->with();
     $job = $this->getMockBuilder('Akeneo\\Bundle\\BatchBundle\\Job\\JobInterface')->getMock();
     $job->expects($this->once())->method('execute')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobExecution'))->will($this->returnCallback(function (JobExecution $jobExecution) use($configuration) {
         $jobExecution->addFailureException(new \Exception('Error 1'));
         $jobExecution->setStatus(new BatchStatus(BatchStatus::FAILED));
     }));
     $this->batchJobRegistry->expects($this->once())->method('getJob')->with($this->isInstanceOf('Akeneo\\Bundle\\BatchBundle\\Entity\\JobInstance'))->will($this->returnValue($job));
     $result = $this->executor->executeJob('import', 'test', $configuration);
     $this->assertInstanceOf('Oro\\Bundle\\ImportExportBundle\\Job\\JobResult', $result);
     $this->assertFalse($result->isSuccessful());
     $this->assertEquals(array('Error 1'), $result->getFailureExceptions());
 }
Ejemplo n.º 5
0
 /**
  * @param string $jobType
  * @param string $jobName
  * @return JobResult
  */
 protected function executePostProcessingJob($jobType, $jobName)
 {
     $jobResult = $this->jobExecutor->executeJob($jobType, $jobName, $this->getJobConfiguration());
     return $jobResult;
 }