Add UT for CommonUtil 11/70911/12
authorSatyaki Mallick <satyaki.mallick@huawei.com>
Sun, 21 Oct 2018 13:49:42 +0000 (19:19 +0530)
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>
Mon, 12 Nov 2018 10:42:35 +0000 (10:42 +0000)
Add UT for CommonUtil in openecomp-be.

Issue-ID: SDC-1774

Change-Id: Id197e79ede009f3ca34043f907a48b26af17be53
Signed-off-by: Satyaki Mallick <satyaki.mallick@huawei.com>
openecomp-be/lib/openecomp-common-lib/pom.xml
openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/utils/CommonUtil.java
openecomp-be/lib/openecomp-common-lib/src/test/java/org/openecomp/sdc/common/utils/CommonUtilTest.java [new file with mode: 0644]

index 4cdf92b..607b716 100644 (file)
             <artifactId>zusammen-datatypes</artifactId>
             <version>${zusammen.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+        </dependency>
     </dependencies>
 
 </project>
index a7b17b7..7d37a55 100644 (file)
@@ -1,9 +1,6 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
  * Licensed 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
@@ -15,7 +12,6 @@
  * 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.
- * ============LICENSE_END=========================================================
  */
 
 package org.openecomp.sdc.common.utils;
@@ -53,8 +49,8 @@ import java.util.zip.ZipException;
 import java.util.zip.ZipInputStream;
 
 public class CommonUtil {
-  private static final String DEFAULT = "default";
-  private static final String _DEFAULT = "_default";
+  static final String DEFAULT = "default";
+  static final String _DEFAULT = "_default";
 
   private CommonUtil() {
     // prevent instantiation
diff --git a/openecomp-be/lib/openecomp-common-lib/src/test/java/org/openecomp/sdc/common/utils/CommonUtilTest.java b/openecomp-be/lib/openecomp-common-lib/src/test/java/org/openecomp/sdc/common/utils/CommonUtilTest.java
new file mode 100644 (file)
index 0000000..d421043
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2017 Huawei Intellectual Property. All rights reserved.
+ *
+ * Licensed 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.openecomp.sdc.common.utils;
+
+import org.testng.annotations.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.testng.Assert.assertTrue;
+
+public class CommonUtilTest {
+
+    @Test
+    public void testGetObjectAsMap() {
+        Map<String, String> obj = new HashMap<>(1);
+        obj.put(CommonUtil.DEFAULT, "");
+        Map<String, Object> newMap = CommonUtil.getObjectAsMap(obj);
+
+        boolean exists = newMap.containsKey(CommonUtil._DEFAULT);
+
+        assertTrue(exists);
+    }
+}
\ No newline at end of file