/** * @test */ public function mergeShouldMergeTwoResults() { $notice1 = $this->getMockMessage('Notice'); $notice2 = $this->getMockMessage('Notice'); $notice3 = $this->getMockMessage('Notice'); $warning1 = $this->getMockMessage('Warning'); $warning2 = $this->getMockMessage('Warning'); $warning3 = $this->getMockMessage('Warning'); $error1 = $this->getMockMessage('Error'); $error2 = $this->getMockMessage('Error'); $error3 = $this->getMockMessage('Error'); $otherResult = new \TYPO3\Flow\Error\Result(); $otherResult->addNotice($notice1); $otherResult->forProperty('foo.bar')->addNotice($notice2); $this->result->forProperty('foo')->addNotice($notice3); $otherResult->addWarning($warning1); $this->result->addWarning($warning2); $this->result->addWarning($warning3); $otherResult->forProperty('foo')->addError($error1); $otherResult->forProperty('foo')->addError($error2); $otherResult->addError($error3); $this->result->merge($otherResult); $this->assertSame(array($notice1), $this->result->getNotices(), 'Notices are not merged correctly without recursion'); $this->assertSame(array($notice3), $this->result->forProperty('foo')->getNotices(), 'Original sub-notices are overridden.'); $this->assertSame(array($notice2), $this->result->forProperty('foo')->forProperty('bar')->getNotices(), 'Sub-notices are not copied.'); $this->assertSame(array($warning2, $warning3, $warning1), $this->result->getWarnings()); $this->assertSame(array($error3), $this->result->getErrors()); $this->assertSame(array($error1, $error2), $this->result->forProperty('foo')->getErrors()); }
/** * Builds a Mapping Collection from the configured node types * * @param \Flowpack\ElasticSearch\Domain\Model\Index $index * @return \Flowpack\ElasticSearch\Mapping\MappingCollection<\Flowpack\ElasticSearch\Domain\Model\Mapping> */ public function buildMappingInformation(Index $index) { $this->lastMappingErrors = new \TYPO3\Flow\Error\Result(); $mappings = new MappingCollection(MappingCollection::TYPE_ENTITY); /** @var NodeType $nodeType */ foreach ($this->nodeTypeManager->getNodeTypes() as $nodeTypeName => $nodeType) { if ($nodeTypeName === 'unstructured' || $nodeType->isAbstract()) { continue; } $type = $index->findType(self::convertNodeTypeNameToMappingName($nodeTypeName)); $mapping = new Mapping($type); // http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates // 'not_analyzed' is necessary $mapping->addDynamicTemplate('dimensions', array('path_match' => '__dimensionCombinations.*', 'match_mapping_type' => 'string', 'mapping' => array('type' => 'string', 'index' => 'not_analyzed'))); foreach ($nodeType->getProperties() as $propertyName => $propertyConfiguration) { if (isset($propertyConfiguration['search']) && isset($propertyConfiguration['search']['elasticSearchMapping'])) { if (is_array($propertyConfiguration['search']['elasticSearchMapping'])) { $mapping->setPropertyByPath($propertyName, $propertyConfiguration['search']['elasticSearchMapping']); } } elseif (isset($propertyConfiguration['type']) && isset($this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) { if (is_array($this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) { $mapping->setPropertyByPath($propertyName, $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping']); } } else { $this->lastMappingErrors->addWarning(new \TYPO3\Flow\Error\Warning('Node Type "' . $nodeTypeName . '" - property "' . $propertyName . '": No ElasticSearch Mapping found.')); } } $mappings->add($mapping); } return $mappings; }