[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-04 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchJsonTest.java:
##
@@ -0,0 +1,409 @@
+/*
+ * 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.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchJsonTest extends 
AbstractPutElasticsearchTest {
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchJsonTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static final Path BATCH_WITH_ERROR = 
Paths.get(TEST_DIR,"batchWithError.json");
+private MockBulkLoadClientService clientService;
+private TestRunner runner;
+private static String flowFileContents;
+private static String sampleErrorResponse;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchJson.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+sampleErrorResponse = 
Files.readString(Paths.get(TEST_COMMON_DIR,"sampleErrorResponse.json"));
+flowFileContents = Files.readString(Paths.get(TEST_DIR, 
"flowFileContents.json"));
+}
+
+@BeforeEach
+public void setup() throws Exception {
+runner = TestRunners.newTestRunner(getTestProcessor());
+clientService = new MockBulkLoadClientService();
+clientService.setResponse(new IndexOperationResponse(1500));
+runner.addControllerService("clientService", clientService);
+runner.setProperty(PutElasticsearchJson.ID_ATTRIBUTE, "doc_id");
+runner.setProperty(PutElasticsearchJson.INDEX_OP, 
IndexOperationRequest.Operation.Index.getValue());
+runner.setProperty(PutElasticsearchJson.INDEX, "test_index");
+runner.setProperty(PutElasticsearchJson.TYPE, "test_type");
+runner.setProperty(PutElasticsearchJson.BATCH_SIZE, "1");
+runner.setProperty(PutElasticsearchJson.OUTPUT_ERROR_DOCUMENTS, 
"false");
+runner.setProperty(PutElasticsearchJson.LOG_ERROR_RESPONSES, "false");
+runner.setProperty(PutElasticsearchJson.CLIENT_SERVICE, 
"clientService");
+runner.setProperty(PutElasticsearchJson.NOT_FOUND_IS_SUCCESSFUL, 
"true");
+runner.setProperty(PutElasticsearchJson.OUTPUT_ERROR_RESPONSES, 
"false");
+runner.enableControllerService(clientService);
+
+runner.assertValid();
+}
+
+public void basicTest(int failure, int retry, int success) {
+Consumer> consumer = 
(List items) -> {
+long nullIdCount = items.stream().filter(item -> item.getId() == 
null).count();
+long indexCount = items.stream().filter(item -> 
"test_index".equals(item.getIndex())).count();
+long typeCount = items.stream().filter(item -> 
"test_type".equals(item.getType())).count();
+long opCount = items.stream().filter(item -> 
IndexOperationRequest.Operation.Index.equals(item.getOperation())).count();
+long emptyScriptCount = 

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-04 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/SearchElasticsearchTest.java:
##
@@ -0,0 +1,243 @@
+/*
+ * 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.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+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 {
+private static final String MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY;
+
+static {
+try {
+MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY = 
Files.readString(Paths.get("src/test/resources/AbstractPaginatedJsonQueryElasticsearchTest/matchAllWithSortByMsgQueryWithSize.json"));
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+}
+
+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, 
MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY);
+
+// 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 {
+testPaginationExpiration(PaginationType.SEARCH_AFTER);
+}
+
+private void testPaginationExpiration(final PaginationType paginationType) 
throws Exception{
+// test flowfile per page
+final TestRunner runner = createRunner(false);
+final TestElasticsearchClientService service = 
AbstractJsonQueryElasticsearchTest.getService(runner);
+service.setMaxPages(2);
+
runner.setProperty(AbstractPaginatedJsonQueryElasticsearch.PAGINATION_TYPE, 
paginationType.getValue());
+
runner.setProperty(AbstractPaginatedJsonQueryElasticsearch.PAGINATION_KEEP_ALIVE,
 "1 sec");
+runner.setProperty(AbstractJsonQueryElasticsearch.QUERY, 
MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY);
+
+// first page
+runOnce(runner);
+AbstractJsonQueryElasticsearchTest.testCounts(runner, 0, 1, 0, 0);
+

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-04 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+}
+
+@BeforeEach
+public void setup() throws Exception {
+clientService = new MockBulkLoadClientService();
+clientService.setResponse(new IndexOperationResponse(1500));
+registry = new MockSchemaRegistry();
+registry.addSchema("simple", AvroTypeUtil.createSchema(new 
Schema.Parser().parse(simpleSchema)));
+RecordReaderFactory reader = new JsonTreeReader();
+runner = TestRunners.newTestRunner(getTestProcessor());
+runner.addControllerService("registry", registry);
+runner.addControllerService("reader", reader);
+runner.addControllerService("clientService", clientService);
+runner.setProperty(reader, 

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-04 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/SearchElasticsearchTest.java:
##
@@ -0,0 +1,243 @@
+/*
+ * 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.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+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 {
+private static final String MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY;
+
+static {
+try {
+MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY = 
Files.readString(Paths.get("src/test/resources/AbstractPaginatedJsonQueryElasticsearchTest/matchAllWithSortByMsgQueryWithSize.json"));
+} catch (IOException e) {
+throw new RuntimeException(e);
+}
+}
+
+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, 
MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY);
+
+// 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 {
+testPaginationExpiration(PaginationType.SEARCH_AFTER);
+}
+
+private void testPaginationExpiration(final PaginationType paginationType) 
throws Exception{
+// test flowfile per page
+final TestRunner runner = createRunner(false);
+final TestElasticsearchClientService service = 
AbstractJsonQueryElasticsearchTest.getService(runner);
+service.setMaxPages(2);
+
runner.setProperty(AbstractPaginatedJsonQueryElasticsearch.PAGINATION_TYPE, 
paginationType.getValue());
+
runner.setProperty(AbstractPaginatedJsonQueryElasticsearch.PAGINATION_KEEP_ALIVE,
 "1 sec");
+runner.setProperty(AbstractJsonQueryElasticsearch.QUERY, 
MATCH_ALL_WITH_SORT_BY_MSG_WITH_SIZE_QUERY);
+
+// first page
+runOnce(runner);
+AbstractJsonQueryElasticsearchTest.testCounts(runner, 0, 1, 0, 0);
+

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+}
+
+@BeforeEach
+public void setup() throws Exception {
+clientService = new MockBulkLoadClientService();
+clientService.setResponse(new IndexOperationResponse(1500));
+registry = new MockSchemaRegistry();
+registry.addSchema("simple", AvroTypeUtil.createSchema(new 
Schema.Parser().parse(simpleSchema)));
+RecordReaderFactory reader = new JsonTreeReader();
+runner = TestRunners.newTestRunner(getTestProcessor());
+runner.addControllerService("registry", registry);
+runner.addControllerService("reader", reader);
+runner.addControllerService("clientService", clientService);
+runner.setProperty(reader, 

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+}
+
+@BeforeEach
+public void setup() throws Exception {
+clientService = new MockBulkLoadClientService();
+clientService.setResponse(new IndexOperationResponse(1500));
+registry = new MockSchemaRegistry();
+registry.addSchema("simple", AvroTypeUtil.createSchema(new 
Schema.Parser().parse(simpleSchema)));
+RecordReaderFactory reader = new JsonTreeReader();
+runner = TestRunners.newTestRunner(getTestProcessor());
+runner.addControllerService("registry", registry);
+runner.addControllerService("reader", reader);
+runner.addControllerService("clientService", clientService);
+runner.setProperty(reader, 

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @ChrisSamo632 @exceptionfactory This information helped a lot. I tweeked my 
code to modify the read in JSON files with the same values you had used with 
   `Time.valueOf(LOCAL_TIME).getTime()`
   `Timestamp.valueOf(LOCAL_DATE_TIME).toInstant().toEpochMilli())`
   `Date.valueOf(LOCAL_DATE).getTime())`
   
   Now even with changing the timezone with
   `TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));`
   the tests pass.
   



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

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @exceptionfactory I do not know why this did not surface earlier. I did not 
make any changes to assertion code. I cut and pasted it from a Groovy `Closure` 
to a Java `Consumer`.
   Not sure if this helps or not but in the Groovy code I placed
   
`TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));`
   
   in the `setup` method of `PutElasticsearchRecordTest` and the tests did not 
fail as it did when I placed it in the Java equivalent (as I mentioned 
previously).



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

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @exceptionfactory I do not know why this did not surface earlier. I did not 
make any changes to assertion code. I cut and pasted it from a Groovy `Closure` 
to a Java `Consumer`.
   Not sure if this helps or not but in the Groovy code I placed
   
`TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));`
   
   in the `setup` method of `PutElasticsearchRecordTest` and the tests did not 
fail as it did when I placed it in the Java equivalent.



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

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @exceptionfactory I do not know why this did not surface earlier. I did not 
make any changes to assertion code. I cut and pasted it from a Groovy `Closure` 
to a Java `Consumer`.
   Not sure if this helps or not but in the Groovy code I placed
   
`TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));`
   
   in the `setup` method of `PutElasticsearchRecordTest` and the test did not 
fail as it did when I placed it in the Java equivalent.



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

[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @exceptionfactory I do not know why this did not surface earlier. I did not 
make any changes to assertion code. I cut and pasted it from a Groovy `Closure` 
to a Java `Consumer`.



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



[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @exceptionfactory I do not know why this did not surface earlier. I did not 
make any changes to assertion code. I cut and pasted it from a Groovy closure 
to a Java `Consumer`.



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



[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @exceptionfactory I do not know why this did not surface earlier. I did not 
make any changes to assertion code. I cut and pasted it from the previous 
Groovy closure to a Java `Consumer`.



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



[GitHub] [nifi] dan-s1 commented on a diff in pull request #7537: NIFI-11778 Initial check in of refactored Groovy tests in nifi-elasticsearch-restapi-processors to Java (and JUnit 5)

2023-08-02 Thread via GitHub


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


##
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-restapi-processors/src/test/java/org/apache/nifi/processors/elasticsearch/PutElasticsearchRecordTest.java:
##
@@ -0,0 +1,784 @@
+/*
+ * 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.avro.Schema;
+import org.apache.nifi.avro.AvroTypeUtil;
+import org.apache.nifi.elasticsearch.IndexOperationRequest;
+import org.apache.nifi.elasticsearch.IndexOperationResponse;
+import org.apache.nifi.json.JsonRecordSetWriter;
+import org.apache.nifi.json.JsonTreeReader;
+import org.apache.nifi.processors.elasticsearch.mock.MockBulkLoadClientService;
+import org.apache.nifi.provenance.ProvenanceEventType;
+import org.apache.nifi.schema.access.SchemaAccessUtils;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.MockRecordParser;
+import org.apache.nifi.serialization.record.MockSchemaRegistry;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.StringUtils;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
+import java.util.function.Consumer;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class PutElasticsearchRecordTest extends 
AbstractPutElasticsearchTest {
+private static final int DATE_YEAR = 2020;
+private static final int DATE_MONTH = 11;
+private static final int DATE_DAY = 27;
+private static final int TIME_HOUR = 12;
+private static final int TIME_MINUTE = 55;
+private static final int TIME_SECOND = 23;
+private static final LocalDateTime LOCAL_DATE_TIME = 
LocalDateTime.of(DATE_YEAR, DATE_MONTH, DATE_DAY, TIME_HOUR, TIME_MINUTE, 
TIME_SECOND);
+private static final LocalDate LOCAL_DATE = LocalDate.of(DATE_YEAR, 
DATE_MONTH, DATE_DAY);
+private static final LocalTime LOCAL_TIME = LocalTime.of(TIME_HOUR, 
TIME_MINUTE, TIME_SECOND);
+private static final String TEST_DIR = 
"src/test/resources/PutElasticsearchRecordTest";
+private static final String TEST_COMMON_DIR = "src/test/resources/common";
+private static String simpleSchema;
+private MockBulkLoadClientService clientService;
+private MockSchemaRegistry registry;
+private TestRunner runner;
+
+@Override
+public Class getTestProcessor() {
+return PutElasticsearchRecord.class;
+}
+
+@BeforeAll
+public static void setUpBeforeClass() throws Exception {
+simpleSchema = Files.readString(Paths.get(TEST_DIR, 
"simpleSchema.json"));
+TimeZone.setDefault(TimeZone.getTimeZone("UTC"));

Review Comment:
   @exceptionfactory I do not know why this did not surface earlier. I did not 
make any changes to assertion code. I cut and pasted it from the previous 
Groovy closure to a Java Consumer.



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