create tests for PropertyTypeExt.java and remove unsused method 56/109256/2
authorJulienBe <julien.bertozzi@intl.att.com>
Wed, 17 Jun 2020 14:53:55 +0000 (16:53 +0200)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Thu, 18 Jun 2020 05:41:13 +0000 (05:41 +0000)
Issue-ID: SDC-3124
Change-Id: I5d3baeeff23c0003952eabc39a5f9dd296dd7c39
Signed-off-by: JulienBe <julien.bertozzi@intl.att.com>
common/onap-tosca-datatype/src/main/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java
common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExtTest.java [new file with mode: 0644]

index 8d1b552..60f2650 100644 (file)
@@ -7,9 +7,9 @@
  * 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.
@@ -29,54 +29,40 @@ import java.util.Map;
  */
 public enum PropertyTypeExt {
 
-  /**
-   * Json property type ext.
-   */
-  JSON("json");
+    /**
+     * Json property type ext.
+     */
+    JSON("json");
 
-  private static final Map<String, PropertyTypeExt> M_MAP =
-      Collections.unmodifiableMap(initializeMapping());
-  private String displayName;
+    private static final Map<String, PropertyTypeExt> M_MAP =
+            Collections.unmodifiableMap(initializeMapping());
+    private String displayName;
 
-  PropertyTypeExt(String displayName) {
-
-    this.displayName = displayName;
-  }
-
-  /**
-   * Initialize mapping map.
-   *
-   * @return the map
-   */
-  public static Map<String, PropertyTypeExt> initializeMapping() {
-    Map<String, PropertyTypeExt> typeMap = new HashMap<String, PropertyTypeExt>();
-    for (PropertyTypeExt v : PropertyTypeExt.values()) {
-      typeMap.put(v.displayName, v);
+    PropertyTypeExt(String displayName) {
+        this.displayName = displayName;
     }
-    return typeMap;
-  }
 
-  /**
-   * Gets property type by display name.
-   *
-   * @param displayName the display name
-   * @return the property type by display name
-   */
-  public static PropertyTypeExt getPropertyTypeByDisplayName(String displayName) {
-    if (M_MAP.containsKey(displayName)) {
-      return M_MAP.get(displayName);
+    /**
+     * Initialize mapping map.
+     *
+     * @return the map
+     */
+    public static Map<String, PropertyTypeExt> initializeMapping() {
+        Map<String, PropertyTypeExt> typeMap = new HashMap<>();
+        for (PropertyTypeExt v : PropertyTypeExt.values()) {
+            typeMap.put(v.displayName, v);
+        }
+        return typeMap;
     }
-    return null;
-  }
 
-  /**
-   * Gets display name.
-   *
-   * @return the display name
-   */
-  public String getDisplayName() {
-    return displayName;
-  }
+    /**
+     * Gets display name.
+     *
+     * @return the display name
+     */
+    public String getDisplayName() {
+        return displayName;
+    }
 
 
 }
diff --git a/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExtTest.java b/common/onap-tosca-datatype/src/test/java/org/onap/sdc/tosca/datatypes/model/heatextend/PropertyTypeExtTest.java
new file mode 100644 (file)
index 0000000..0e6c1ff
--- /dev/null
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2020 AT&T. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.sdc.tosca.datatypes.model.heatextend;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class PropertyTypeExtTest {
+
+    @Test
+    public void initializeProperMapping() {
+        Map<String, PropertyTypeExt> map = PropertyTypeExt.initializeMapping();
+        assertNotNull(map);
+        assertEquals(1, map.size());
+        assertEquals(PropertyTypeExt.JSON, map.get("json"));
+    }
+
+    @Test
+    public void getDisplayName() {
+        assertEquals("json", PropertyTypeExt.JSON.getDisplayName());
+    }
+
+}