public function testSetRestoreHandleMappings()
 {
     $timeTaken = 11;
     $memoryUsage = 22;
     $memoryUsed = 33;
     $options = array('my' => 'option');
     $this->entity->setRestoreHandleMappings($timeTaken, $memoryUsage, $memoryUsed, $options);
     $result = $this->entity->toArray();
     $this->assertArrayHasKey(JobStats::NAME_RESTORE_HANDLE_MAPPINGS, $result['data']);
     $data = $result['data'][JobStats::NAME_RESTORE_HANDLE_MAPPINGS];
     $this->assertSame($timeTaken, $data['timeTaken']);
     $this->assertSame($memoryUsage, $data['memoryUsage']);
     $this->assertSame($memoryUsed, $data['memoryUsed']);
     $this->assertEquals($options, $data['options']);
     $this->assertContains(date('Y-m-d H:i:'), $data['createdAt']);
 }
 /**
  * Take care of all mapping actions and handles all for elastic sid
  *
  * @param RestoreJob $job
  * @param JobStats $jobStats
  * @param OutputInterface $output
  * @throws \Exception
  * @author Daniel Wendlandt
  */
 private function handleMappings(RestoreJob $job, JobStats $jobStats, OutputInterface $output)
 {
     $memoryAtSection = memory_get_usage();
     $timeStartSection = microtime(true);
     $output->writeln('<info>*** Start handling mappings ***</info>' . PHP_EOL);
     /** @var Index $index */
     foreach ($job->getMappings()->getIndices() as $index) {
         /** @var Type $type */
         foreach ($index->getTypes() as $type) {
             $mappingAction = $job->getStrategy()->getMapping($index->getName(), $type->getName());
             if (null === $mappingAction) {
                 throw new \Exception('Mapping action missing for "' . $index->getName() . '/' . $type->getName() . '"');
             }
             if (RestoreStrategy::STRATEGY_RESET === $mappingAction->getStrategy()) {
                 $schema = array($mappingAction->getTargetType() => $type->getSchema());
                 $this->elastic->createMapping($mappingAction->getTargetIndex(), $mappingAction->getTargetType(), $schema, $job->getHost(), $job->getPort());
                 $output->writeln('<comment> - Created mapping from ' . $index->getName() . '/' . $type->getName() . ' to ' . $mappingAction->getTargetIndex() . '/' . $mappingAction->getTargetType() . '</comment>');
             } else {
                 $output->writeln('<comment> - No Action for ' . $index->getName() . '/' . $type->getName() . '</comment>');
             }
         }
     }
     $output->writeln('');
     $jobStats->setRestoreHandleMappings(microtime(true) - $timeStartSection, memory_get_usage(), memory_get_usage() - $memoryAtSection);
 }