abhishekgarg18 commented on code in PR #152:
URL: 
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/152#discussion_r1056193284


##########
src/test/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandlerTest.java:
##########
@@ -169,7 +169,64 @@ public void handleIndexDefinitionWithNestedTikaXml() 
throws IOException, Convert
         assertIsValidXml(tikaConfig);
     }
 
+    @Test
+    public void handleIndexDefinitionWithStopwordsInAnalyzer() throws 
IOException, ConverterException, ParserConfigurationException, SAXException {
+        DefaultIndexManager manager = new DefaultIndexManager();
+
+        traverseForIndexing(manager, "index_with_stopwards");
+
+        IndexDefinitions defs = manager.getIndexes();
+        Map<String, List<DocViewNode2>> indexes = defs.getIndexes();
+
+        assertThat(indexes).as("index definitions")
+                .hasSize(1)
+                .containsKey("/oak:index");
+
+        List<DocViewNode2> rootIndexes = indexes.get("/oak:index");
+        assertThat(rootIndexes).as("root indexes")
+                .hasSize(1);
+
+        assertThat(rootIndexes).as("index definitions")
+                .hasSize(1)
+                .element(0)
+                .has(Conditions.localName("lucene-custom"));
+
+        DocViewNode2 luceneCustom = rootIndexes.get(0);
+        assertThat(luceneCustom).as("lucene index definition")
+                .has(Conditions.childWithLocalName("/oak:index/lucene-custom", 
"analyzers", defs));
+
+        List<DocViewNode2> luceneCustomChildren = 
defs.getChildren("/oak:index/lucene-custom");
+        assertThat(luceneCustomChildren).as("lucene index definition children")
+                .hasSize(1);
+
+        DocViewNode2 analyzersConfigNode = luceneCustomChildren.stream()
+                .filter( c -> c.getName().getLocalName().equals("analyzers") )
+                .findFirst()
+                .get();
+
+        assertThat(analyzersConfigNode).as("analyzers config node for stop 
words")
+                
.has(Conditions.childWithLocalName("/oak:index/lucene-custom/analyzers/default/filters/Stop","stopwords.txt",
 defs));
+
+        byte[] stopwordsConfig = 
defs.getBinary("/oak:index/lucene-custom/analyzers/default/filters/Stop/stopwords.txt").get();
+        assertThat(stopwordsConfig).as("stopwordsConfig is ").isNotNull();
 
+        byte[] stopwords_2_Config = 
defs.getBinary("/oak:index/lucene-custom/analyzers/default/filters/Stop/stopwords_2.txt").get();
+        assertThat(stopwords_2_Config).as("stopwords__2Config is 
").isNotNull();
+
+        assertThat(analyzersConfigNode).as("analyzers config node for 
prowords")
+                
.has(Conditions.childWithLocalName("/oak:index/lucene-custom/analyzers/default/filters/KeywordMarker","protwords.txt",
 defs));
+
+        byte[] keywordMarkerConfig = 
defs.getBinary("/oak:index/lucene-custom/analyzers/default/filters/KeywordMarker/protwords.txt").get();
+        assertThat(keywordMarkerConfig).as("keywordMarkerConfig is 
").isNotNull();
+
+
+        assertThat(analyzersConfigNode).as("analyzers config node dor 
Synonyms")
+                
.has(Conditions.childWithLocalName("/oak:index/lucene-custom/analyzers/default/filters/Synonym","synonyms.txt",
 defs));
+
+        byte[] synonymConfig = 
defs.getBinary("/oak:index/lucene-custom/analyzers/default/filters/Synonym/synonyms.txt").get();
+        assertThat(synonymConfig).as("synonymConfig is ").isNotNull();

Review Comment:
   added a contains check.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to