simonbence commented on a change in pull request #5530:
URL: https://github.com/apache/nifi/pull/5530#discussion_r794301478



##########
File path: 
nifi-nar-bundles/nifi-standard-services/nifi-record-serialization-services-bundle/nifi-record-serialization-services/src/test/java/org/apache/nifi/cef/TestCEFUtil.java
##########
@@ -0,0 +1,128 @@
+/*
+ * 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.cef;
+
+import org.apache.nifi.serialization.record.Record;
+import org.apache.nifi.serialization.record.RecordField;
+import org.apache.nifi.serialization.record.RecordFieldType;
+import org.junit.Assert;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+public class TestCEFUtil {
+    static final String RAW_FIELD = "raw";
+    static final String RAW_VALUE = "Oct 12 04:16:11 localhost 
CEF:0|Company|Product|1.2.3|audit-login|Successful login|3|";
+
+    static final String INPUT_SINGLE_ROW_HEADER_FIELDS_ONLY = 
"src/test/resources/cef/single-row-header-fields-only.txt";
+    static final String INPUT_SINGLE_ROW_WITH_EXTENSIONS = 
"src/test/resources/cef/single-row-with-extensions.txt";
+    static final String INPUT_SINGLE_ROW_WITH_EMPTY_EXTENSION = 
"src/test/resources/cef/single-row-with-empty-extension.txt";
+    static final String INPUT_SINGLE_ROW_WITH_CUSTOM_EXTENSIONS = 
"src/test/resources/cef/single-row-with-custom-extensions.txt";
+    static final String INPUT_SINGLE_ROW_WITH_EMPTY_CUSTOM_EXTENSIONS = 
"src/test/resources/cef/single-row-with-empty-custom-extensions.txt";
+    static final String INPUT_SINGLE_ROW_WITH_INCORRECT_HEADER_FIELD = 
"src/test/resources/cef/single-row-with-incorrect-header-field.txt";
+    static final String INPUT_SINGLE_ROW_WITH_INCORRECT_CUSTOM_EXTENSIONS = 
"src/test/resources/cef/single-row-with-incorrect-custom-extensions.txt";
+    static final String INPUT_EMPTY_ROW = 
"src/test/resources/cef/empty-row.txt";
+    static final String INPUT_MISFORMATTED_ROW = 
"src/test/resources/cef/misformatted-row.txt";
+    static final String INPUT_MULTIPLE_IDENTICAL_ROWS = 
"src/test/resources/cef/multiple-rows.txt";
+    static final String INPUT_MULTIPLE_ROWS_WITH_DIFFERENT_CUSTOM_TYPES = 
"src/test/resources/cef/multiple-rows-with-different-custom-types.txt";
+    static final String INPUT_MULTIPLE_ROWS_STARTING_WITH_EMPTY_ROW = 
"src/test/resources/cef/multiple-rows-starting-with-empty-row.txt";
+    static final String INPUT_MULTIPLE_ROWS_WITH_EMPTY_ROWS = 
"src/test/resources/cef/multiple-rows-with-empty-rows.txt";
+    static final String 
INPUT_MULTIPLE_ROWS_WITH_DECREASING_NUMBER_OF_EXTENSIONS = 
"src/test/resources/cef/multiple-rows-decreasing-number-of-extensions.txt";
+    static final String 
INPUT_MULTIPLE_ROWS_WITH_INCREASING_NUMBER_OF_EXTENSIONS = 
"src/test/resources/cef/multiple-rows-increasing-number-of-extensions.txt";
+
+    static final Map<String, Object> EXPECTED_HEADER_VALUES = new HashMap<>();
+    static final Map<String, Object> EXPECTED_EXTENSION_VALUES = new 
HashMap<>();
+
+    static final String CUSTOM_EXTENSION_FIELD_NAME = "loginsequence";
+    static final RecordField CUSTOM_EXTENSION_FIELD = new 
RecordField(TestCEFUtil.CUSTOM_EXTENSION_FIELD_NAME, 
RecordFieldType.INT.getDataType());
+    static final RecordField CUSTOM_EXTENSION_FIELD_AS_STRING = new 
RecordField(TestCEFUtil.CUSTOM_EXTENSION_FIELD_NAME, 
RecordFieldType.STRING.getDataType());
+    static final RecordField CUSTOM_EXTENSION_FIELD_AS_CHOICE = new 
RecordField(TestCEFUtil.CUSTOM_EXTENSION_FIELD_NAME, 
RecordFieldType.CHOICE.getChoiceDataType(
+            RecordFieldType.FLOAT.getDataType(), 
RecordFieldType.STRING.getDataType()
+    ));
+
+    static {
+        EXPECTED_HEADER_VALUES.put("version", Integer.valueOf(0));
+        EXPECTED_HEADER_VALUES.put("deviceVendor", "Company");
+        EXPECTED_HEADER_VALUES.put("deviceProduct", "Product");
+        EXPECTED_HEADER_VALUES.put("deviceVersion", "1.2.3");
+        EXPECTED_HEADER_VALUES.put("deviceEventClassId", "audit-login");
+        EXPECTED_HEADER_VALUES.put("name", "Successful login");
+        EXPECTED_HEADER_VALUES.put("severity", "3");
+
+        EXPECTED_EXTENSION_VALUES.put("cn1Label", "userid");
+        EXPECTED_EXTENSION_VALUES.put("spt", Integer.valueOf(46117));
+        EXPECTED_EXTENSION_VALUES.put("cn1", Long.valueOf(99999));
+        EXPECTED_EXTENSION_VALUES.put("cfp1", Float.valueOf(1.23F));

Review comment:
       This is intentional: even if it is not necessary, it highlights what I 
wanted to test here, this communicates my intents somewhat more clrear.




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