public function testHandleLogWithJob()
 {
     $job = new ImageJob();
     $job->setBeginning('begin');
     $job->setEnd('end');
     $frame = new Frame('MESSAGE', array('delivery_tag' => 'delivery-' . mt_rand()), $job->toJson());
     $loop = LoopFactory::create();
     $options = array('eventloop' => $loop, 'on_error' => array($this, 'throwRedisError'));
     $redisSync = new PredisSync('tcp://127.0.0.1:6379');
     $redisSync->connect();
     $resolver = $this->getResolver();
     $resolver->expects($this->once())->method('ack');
     $done = false;
     $phpunit = $this;
     $redis = new PredisAsync('tcp://127.0.0.1:6379', $options);
     $redis->connect(function () use($phpunit, $redis, $frame, $redisSync, &$done, $resolver) {
         $component = new LogBuilderComponent();
         $component->handleLog($redis, $phpunit->getLogger(), $frame, $resolver)->then(function ($hashId) use($phpunit, $redis, $redisSync, &$done) {
             $redis->disconnect();
             $data = $redisSync->hgetall($hashId);
             $phpunit->assertGreaterThan(0, count($data));
             $phpunit->assertEquals('Gloubster\\Message\\Job\\ImageJob', $data['type']);
             $phpunit->assertTrue($redisSync->sismember('jobs', $hashId));
             $done = true;
         });
     });
     $loop->run();
     $this->assertTrue($done);
 }
 public function getData()
 {
     $delivery = new FilesystemDelivery();
     $delivery->setTarget('/path/to/Target');
     /**
      * @todo add receipts
      */
     $receipts = array();
     $image = new ImageJob();
     $image->setEnd(microtime(true))->setDeliveryDuration(25.4)->setDelivery($delivery)->setError(true)->setErrorMessage('An error ploped')->setParameters(array('param1' => 'val1', 'param2' => 'val2'))->setProcessDuration(23.42)->setWorkerId('a worker-id')->setSource('/path/to/source')->setReceipts($receipts);
     $video = new VideoJob();
     $image->setEnd(microtime(true))->setDeliveryDuration(25.4)->setDelivery($delivery)->setError(true)->setErrorMessage('An error ploped')->setParameters(array('param1' => 'val1', 'param2' => 'val2'))->setProcessDuration(23.42)->setWorkerId('a worker-id')->setSource('/path/to/source')->setReceipts($receipts);
     return array(array($image, $image->toJson()), array($video, $video->toJson()));
 }
 public function getData()
 {
     $delivery = new FilesystemDelivery();
     $delivery->setTarget('/path/to/Target');
     /**
      * @todo add receipts
      */
     $receipts = array();
     $image = new ImageJob();
     $image->setEnd(microtime(true))->setDeliveryDuration(25.4)->setDelivery($delivery)->setError(true)->setErrorMessage('An error ploped')->setParameters(array('param1' => 'val1', 'param2' => 'val2'))->setProcessDuration(23.42)->setWorkerId('a worker-id')->setSource('/path/to/source')->setReceipts($receipts);
     $video = new VideoJob();
     $image->setEnd(microtime(true))->setDeliveryDuration(25.4)->setDelivery($delivery)->setError(true)->setErrorMessage('An error ploped')->setParameters(array('param1' => 'val1', 'param2' => 'val2'))->setProcessDuration(23.42)->setWorkerId('a worker-id')->setSource('/path/to/source')->setReceipts($receipts);
     $presence = new WorkerPresence();
     $presence->setWorkerType('worker-type')->setFailureJobs(mt_rand())->setId(mt_rand())->setMemory(123456789)->setStartedTime(223456789.98765433)->setLastJobTime(333456789.9876543)->setTotalJobs(mt_rand())->setSuccessJobs(mt_rand())->setReportTime(444456789.98765445)->setIdle(true);
     return array(array($image, $image->toJson()), array($video, $video->toJson()), array($presence, $presence->toJson()));
 }
 /**
  * @expectedException Gloubster\Exception\RuntimeException
  */
 public function testFromJsonFailsWithWrongType()
 {
     $job = new ImageJob();
     Factory::fromJson($job->toJson());
 }