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


##########
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();
+

Review Comment:
   Please add a minimal check, for instance that a well-known line is present.



##########
src/test/resources/org/apache/sling/feature/cpconverter/handlers/index/index_with_stopwards/jcr_root/_oak_index/lucene-custom/analyzers/default/filters/Stop/stopwords.txt:
##########
@@ -0,0 +1,353 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+de             |  from, of

Review Comment:
   Can you please simplify this file? We don't need all of those entries



##########
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();

Review Comment:
   Please add a minimal check, for instance that a well-known line is present.



##########
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:
   Please add a minimal check, for instance that a well-known line is present.



##########
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();

Review Comment:
   Please add a minimal check, for instance that a well-known line is present.



##########
src/test/resources/org/apache/sling/feature/cpconverter/handlers/index/index_with_stopwards/jcr_root/_oak_index/lucene-custom/analyzers/default/filters/Stop/stopwords_2.txt:
##########
@@ -0,0 +1,353 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+de             |  from, of

Review Comment:
   Can you please simplify this file? We don't need all of those entries



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to