dan-s1 commented on code in PR #7537:
URL: https://github.com/apache/nifi/pull/7537#discussion_r1305629659


##########
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/SearchElasticsearchTest.java:
##########
@@ -0,0 +1,217 @@
+/*
+ * 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.
+ */
+package org.apache.nifi.processors.elasticsearch;
+
+import org.apache.nifi.components.state.Scope;
+import org.apache.nifi.processors.elasticsearch.api.PaginationType;
+import org.apache.nifi.processors.elasticsearch.api.ResultOutputStrategy;
+import org.apache.nifi.state.MockStateManager;
+import org.apache.nifi.util.TestRunner;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.time.Instant;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class SearchElasticsearchTest extends 
AbstractPaginatedJsonQueryElasticsearchTest {
+    @BeforeAll
+    public static void setUpBeforeClass() throws Exception {
+        AbstractPaginatedJsonQueryElasticsearchTest.setUpBeforeClass();
+    }
+
+    public AbstractPaginatedJsonQueryElasticsearch getProcessor() {
+        return new SearchElasticsearch();
+    }
+
+    public boolean isStateUsed() {
+        return true;
+    }
+
+    public boolean isInput() {
+        return false;
+    }
+
+    @Test
+    public void testScrollError() {
+        final TestRunner runner = createRunner(false);
+        final TestElasticsearchClientService service = 
AbstractJsonQueryElasticsearchTest.getService(runner);
+        service.setMaxPages(2);
+        service.setThrowErrorInSearch(false);
+        
runner.setProperty(AbstractPaginatedJsonQueryElasticsearch.PAGINATION_TYPE, 
PaginationType.SCROLL.getValue());
+        runner.setProperty(AbstractJsonQueryElasticsearch.QUERY, 
matchAllWithSortByMsgWithSizeQuery);
+
+        // initialize search
+        runOnce(runner);
+        AbstractJsonQueryElasticsearchTest.testCounts(runner, 0, 1, 0, 0);
+        runner.clearTransferState();
+
+        // scroll (error)
+        service.setThrowErrorInSearch(true);
+        runOnce(runner);
+        AbstractJsonQueryElasticsearchTest.testCounts(runner, 0, 0, 0, 0);
+        
assertTrue(runner.getLogger().getErrorMessages().stream().anyMatch(logMessage ->
+                logMessage.getMsg().contains("Could not query documents") && 
logMessage.getThrowable().getMessage().contains("Simulated IOException - 
scroll")));
+    }
+
+    @Test
+    public void testScrollExpiration() throws Exception {
+        testPaginationExpiration(PaginationType.SCROLL);
+    }
+
+    @Test
+    public void testPitExpiration() throws Exception {
+        testPaginationExpiration(PaginationType.POINT_IN_TIME);
+    }
+
+    @Test
+    public void testSearchAfterExpiration() throws Exception {

Review Comment:
   I realize there is no need for the `public`  modifier but I seemed to have 
this conversation with @exceptionfactory  in an earlier ticket (cannot find 
right now) whether to drop `public` or not and he was in favor of keeping it 
and having a follow on ticket which would handle removing the `public` modifier 
from all the unit tests. 
   @exceptionfactory  please let me know whether you are still in favor of 
keeping the `public` modifier or can we remove it? Thanks!



-- 
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: issues-unsubscr...@nifi.apache.org

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

Reply via email to