/**
  * A command run when a population has finished.
  *
  * @param $indexName
  */
 public function postPopulate($indexName)
 {
     $indexConfig = $this->configManager->getIndexConfiguration($indexName);
     if ($indexConfig->isUseAlias()) {
         $index = $this->indexManager->getIndex($indexName);
         $this->aliasProcessor->switchIndexAlias($indexConfig, $index);
     }
 }
 public function testSwitchAliasCleansUpOnRenameFailure()
 {
     $indexConfig = new IndexConfig('name', array(), array());
     list($index, $client) = $this->getMockedIndex('unique_name');
     $client->expects($this->at(0))->method('request')->with('_aliases', 'GET')->willReturn(new Response(array('old_unique_name' => array('aliases' => array('name')))));
     $client->expects($this->at(1))->method('request')->with('_aliases', 'POST', array('actions' => array(array('remove' => array('index' => 'old_unique_name', 'alias' => 'name')), array('add' => array('index' => 'unique_name', 'alias' => 'name')))))->will($this->throwException(new ResponseException(new Request(''), new Response(''))));
     $client->expects($this->at(2))->method('request')->with('unique_name', 'DELETE');
     // Not an annotation: we do not want a RuntimeException until now.
     $this->setExpectedException('RuntimeException');
     $this->processor->switchIndexAlias($indexConfig, $index, true);
 }