Update aai-parent in babel to 1.13.3
[aai/babel.git] / src / test / java / org / onap / aai / babel / xml / generator / model / TestModel.java
index ed4f5c1..93dd443 100644 (file)
@@ -23,11 +23,13 @@ package org.onap.aai.babel.xml.generator.model;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.IOException;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.onap.aai.babel.util.ArtifactTestUtils;
 
 /**
@@ -37,16 +39,14 @@ import org.onap.aai.babel.util.ArtifactTestUtils;
 public class TestModel {
 
     /**
-     * Load the Widget Configuration, including the type mappings and the UUID mappings.
+     * Load the Widget mapping configuration.
      *
      * @throws IOException
      *             if the mappings configuration cannot be loaded
      */
-    @BeforeClass
+    @BeforeAll
     public static void setup() throws IOException {
-        ArtifactTestUtils util = new ArtifactTestUtils();
-        util.loadWidgetToUuidMappings();
-        util.loadWidgetMappings();
+        new ArtifactTestUtils().loadWidgetMappings();
     }
 
     @Test
@@ -73,9 +73,39 @@ public class TestModel {
         assertMapping("org.openecomp.resource.vfc", "an.unknown.type", WidgetType.valueOf("VSERVER"));
     }
 
+    /**
+     * Test that there is no exception if processing a Model that has no metadata properties.
+     */
+    @Test
+    public void testNullIdentProperties() {
+        assertDoesNotThrow(() -> {
+            createTestModel().populateModelIdentificationInformation(null);
+        });
+    }
+
+    /**
+     * Test that an exception occurs if calling code passes an unsupported Widget Type value to the base implementation
+     * of the hasWidgetType() method.
+     */
+    @Test
+    public void testUnknownWidgetType() {
+        assertThrows(IllegalArgumentException.class, () -> {
+            createTestModel().hasWidgetType(null);
+        });
+    }
+
+    /**
+     * Create any Model with a valid WidgetType, for method testing.
+     *
+     * @return a valid Model for testing purposes
+     */
+    private Model createTestModel() {
+        return new Resource(WidgetType.valueOf("VSERVER"), false);
+    }
+
     /**
      * Assert that the TOSCA type String is mapped to the expected Widget Type.
-     * 
+     *
      * @param toscaType
      *            the TOSCA type or prefix
      * @param widgetType
@@ -87,7 +117,7 @@ public class TestModel {
 
     /**
      * Assert that the TOSCA metadata type is mapped to the expected Widget Type.
-     * 
+     *
      * @param toscaType
      *            the name (or name prefix) of the TOSCA type
      * @param metadataType