MikeThomsen commented on code in PR #6487:
URL: https://github.com/apache/nifi/pull/6487#discussion_r988463992


##########
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/test/java/org/apache/nifi/elasticsearch/integration/ElasticSearchClientService_IT.java:
##########
@@ -0,0 +1,745 @@
+/*
+ * 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.elasticsearch.integration;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.maven.artifact.versioning.ComparableVersion;
+import org.apache.nifi.elasticsearch.DeleteOperationResponse;
+import org.apache.nifi.elasticsearch.ElasticSearchClientService;
+import org.apache.nifi.elasticsearch.ElasticSearchClientServiceImpl;
+import org.apache.nifi.elasticsearch.ElasticsearchException;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.elasticsearch.SearchResponse;
+import org.apache.nifi.elasticsearch.TestControllerServiceProcessor;
+import org.apache.nifi.elasticsearch.UpdateOperationResponse;
+import org.apache.nifi.security.util.StandardTlsConfiguration;
+import org.apache.nifi.security.util.TemporaryKeyStoreBuilder;
+import org.apache.nifi.security.util.TlsConfiguration;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
+public class ElasticSearchClientService_IT extends AbstractElasticsearchIT {
+    private TestRunner runner;
+    private ElasticSearchClientServiceImpl service;
+
+    static final String INDEX = "messages";
+    public static String TYPE;
+
+    static final ComparableVersion VERSION = new 
ComparableVersion(System.getProperty("es_version", "0.0.0"));
+    static final ComparableVersion ES_7_10 = new ComparableVersion("7.10");
+    static final ComparableVersion ES_8_0 = new ComparableVersion("8.0");
+
+    static final String FLAVOUR = System.getProperty("es_flavour");
+    static final String DEFAULT = "default";
+
+    private static TlsConfiguration generatedTlsConfiguration;
+    private static TlsConfiguration truststoreTlsConfiguration;
+
+    @BeforeAll
+    static void beforeAll() throws IOException {
+        TYPE = getElasticMajorVersion() == 6 ? "_doc" : "";
+        System.out.println(
+                String.format("%n%n%n%n%n%n%n%n%n%n%n%n%n%n%nTYPE: 
%s%n%s%s%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n",
+                        TYPE, IMAGE.getRepository(), IMAGE.getVersionPart())
+        );
+
+        generatedTlsConfiguration = new TemporaryKeyStoreBuilder().build();
+        truststoreTlsConfiguration = new StandardTlsConfiguration(
+                null,
+                null,
+                null,
+                generatedTlsConfiguration.getTruststorePath(),
+                generatedTlsConfiguration.getTruststorePassword(),
+                generatedTlsConfiguration.getTruststoreType()
+        );
+
+        setupTestData();
+    }
+
+    @BeforeEach
+    void before() throws Exception {
+        runner = 
TestRunners.newTestRunner(TestControllerServiceProcessor.class);
+        service = new ElasticSearchClientServiceImpl();
+        runner.addControllerService("Client Service", service);
+        runner.setProperty(service, ElasticSearchClientService.HTTP_HOSTS, 
String.format("http://%s";, ELASTICSEARCH_CONTAINER.getHttpHostAddress()));
+        runner.setProperty(service, 
ElasticSearchClientService.CONNECT_TIMEOUT, "10000");
+        runner.setProperty(service, ElasticSearchClientService.SOCKET_TIMEOUT, 
"60000");
+        runner.setProperty(service, ElasticSearchClientService.RETRY_TIMEOUT, 
"60000");
+        runner.setProperty(service, ElasticSearchClientService.SUPPRESS_NULLS, 
ElasticSearchClientService.ALWAYS_SUPPRESS.getValue());
+        runner.setProperty(service, ElasticSearchClientService.USERNAME, 
"elastic");
+        runner.setProperty(service, ElasticSearchClientService.PASSWORD, 
"s3cret");
+
+        try {
+            runner.enableControllerService(service);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            throw ex;
+        }
+
+        service.refresh(null, null);
+    }
+
+    @AfterEach
+    void after() throws Exception {
+        service.onDisabled();
+    }
+
+    @Test
+    public void bootstrapTest() {
+
+    }
+
+    private String prettyJson(Object o) throws JsonProcessingException {
+        return new 
ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(o);

Review Comment:
   Done.



-- 
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