ChrisSamo632 commented on code in PR #7537:
URL: https://github.com/apache/nifi/pull/7537#discussion_r1282344859


##########
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<PutElasticsearchRecord> {
+    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<? extends AbstractPutElasticsearch> 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:
   I wonder whether this is due to the Groovy tests having converted, for 
example, a `LocalDateTime` into a `Timestamp`, to an `Instant`, and finally the 
`long` representation of the "epoch millis" - this would (I think) cater for 
the Locale/TimeZone change in the JVM, e.g. a `Europe/Paris` TZ instead of 
`UTC`, allowing the tests to use a consistent basis for creating, using, and 
then asserting the timestamp/data/time
   
   With the change to a JSON-based structure for the FlowFile contents, are the 
timestamps being read from the file in one TZ then the tests and trying to 
use/assert them in another?
   
   I recall having to spend some time (no pun intended) on getting these tests 
to work originally, but it was a while ago now, so can't recall the specifics 
(think I maybe tried to start with a hardcoded timestamp-millis, but couldn't 
figure out how to get that to work)
   



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