/**
  * This command will adjust the backend's mapping to the mapping the entity status prescribes.
  *
  * @param string $clientName The client name for the configuration. Defaults to the default client configured.
  * @return void
  */
 public function convergeCommand($clientName = null)
 {
     $client = $this->clientFactory->create($clientName);
     $entityMappingCollection = $this->entityMappingBuilder->buildMappingInformation();
     $this->backendMappingBuilder->setClient($client);
     $backendMappingCollection = $this->backendMappingBuilder->buildMappingInformation();
     $additiveMappings = $entityMappingCollection->diffAgainstCollection($backendMappingCollection);
     /** @var $mapping \Flowpack\ElasticSearch\Domain\Model\Mapping */
     foreach ($additiveMappings as $mapping) {
         $index = $mapping->getType()->getIndex();
         $index->setClient($client);
         if (!$index->exists()) {
             $this->outputFormatted('Index <b>%s</b> does not exist', array($index->getName()));
             continue;
         }
         $this->outputLine('Attempt to apply properties to %s/%s: %s... ', array($index->getName(), $mapping->getType()->getName(), print_r($mapping->getProperties(), true)));
         $response = $mapping->apply();
         if ($response->getStatusCode() === 200) {
             $this->outputFormatted('<b>OK</b>');
         } else {
             $this->outputFormatted('<b>NOT OK</b>, response code was %d, response body was: %s', array($response->getStatusCode(), $response->getOriginalResponse()->getContent()), 4);
         }
     }
     if (0 === $additiveMappings->count()) {
         $this->outputLine('No mappings were to be applied.');
     }
 }
 /**
  * @test
  */
 public function basicTest()
 {
     $information = $this->mappingBuilder->buildMappingInformation();
     $this->assertGreaterThanOrEqual(2, count($information));
     $this->assertInstanceOf('Flowpack\\ElasticSearch\\Domain\\Model\\Mapping', $information[0]);
 }