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


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/db/ColumnNameNormalizerUtilityTest.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.standard.db;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.regex.Pattern;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+
+public class ColumnNameNormalizerUtilityTest {
+
+
+
+    @Test
+    void testNormalizingColumnName_RemoveUnderscore() {
+        String inputColumnName = "example_column_name";
+        String expectedNormalized = "EXAMPLECOLUMNNAME";
+        String normalized = 
ColumnNameNormalizerUtility.getNormalizedName(inputColumnName,true, 
TranslationStrategy.REMOVE_UNDERSCORE, null);
+
+        assertEquals(expectedNormalized, normalized);
+    }
+
+    @Test
+    void testNormalizingColumnName_RemoveSpace() {
+        String inputColumnName = "Column Name With Spaces";
+        String expectedNormalized = "COLUMNNAMEWITHSPACES";
+        String normalized = 
ColumnNameNormalizerUtility.getNormalizedName(inputColumnName,true, 
TranslationStrategy.REMOVE_SPACE, null);
+
+        assertEquals(expectedNormalized, normalized);
+    }
+
+    @Test
+    void testNormalizingColumnName_RemoveAllSpecialCharacters() {
+        String inputColumnName = "Special!Characters@Here$";
+        String expectedNormalized = "SPECIALCHARACTERSHERE";
+        String normalized = 
ColumnNameNormalizerUtility.getNormalizedName(inputColumnName,true, 
TranslationStrategy.REMOVE_ALL_SPECIAL_CHAR, null);
+
+        assertEquals(expectedNormalized, normalized);
+    }
+
+    @Test
+    void testNormalizingColumnName_Regex() {
+        String inputColumnName = "Your @Input -String Here";
+        Pattern translationPattern = Pattern.compile("[@-]");
+        String expectedNormalized = 
translationPattern.matcher(inputColumnName.toUpperCase()).replaceAll( "");

Review Comment:
   Be consistent in this unit test as  you did with the other unit tests by 
just  specifying the actual value of the expected string (w/o it be being 
calculated).
   ```suggestion
           String expectedNormalized = "YOUR INPUT STRING HERE";
   ```



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/db/TranslationStrategy.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.standard.db;
+
+import org.apache.nifi.components.DescribedValue;
+
+/**
+ * Enumeration of supported Database column name Translation Strategy
+ */
+public enum TranslationStrategy implements DescribedValue {
+    REMOVE_UNDERSCORE {
+        @Override
+        public String getDisplayName() {
+            return "Remove Underscore";
+        }
+
+        @Override
+        public String getDescription() {
+            return "Underscore(_) will be removed from column name with empty 
string Ex. Pics_1_11 become PICS111";
+        }
+    },
+    REMOVE_SPACE {
+        @Override
+        public String getDisplayName() {
+            return "Remove Space";
+        }
+
+        @Override
+        public String getDescription() {
+            return "Spaces will be removed from column name with empty string 
Ex. 'User Name' become 'USERNAME'";
+        }
+    },
+
+    //    REMOVE_ALL_SPECIAL_CHAR("REMOVE_ALL_SPECIAL_CHAR","Remove All 
Special Character","Remove All Special Character"),

Review Comment:
   Remove commented out code
   
   ```suggestion
   ```



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