summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-03-07 16:17:06 +0000
committermark.j.leonard <mark.j.leonard@gmail.com>2019-03-07 16:47:20 +0000
commit5a6fd49a6aca3a567464527335b107746e28f3bd (patch)
treec4c77e4684cfb9de1300d62a44d3772699d60d4d /src/test
parentf03e49cdf5c8d54733416ab244826b9429c9c86c (diff)
Re-implement model type value for Resource Mapping
Refactor the Model/Service/Resource/Widget hierarchy to improve code readability. Replace the configurable Boolean value for a Resource's model type with a value from the existing ModelType enum. Obtain the A&AI XML Model name (always resource or service) directly from the Model class and not from the configured model type for the Resource. Change-Id: I1487d919392b34e4bf1314da8cd2805a9fbf96a3 Issue-ID: AAI-2212 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java30
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java35
2 files changed, 25 insertions, 40 deletions
diff --git a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
index 2de10b9..acc4a35 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
@@ -122,25 +122,41 @@ public class TestArtifactGeneratorToscaParser {
}
/**
- * Initialise the Artifact Generator Widget Mapping config with incomplete data (no type).
+ * Initialize the Artifact Generator Widget Mapping config with incomplete data (no type).
+ *
+ * @throws IOException
*/
- @Test(expected = IllegalArgumentException.class)
- public void testToscaMappingWithoutType() {
+ @Test(expected = IOException.class)
+ public void testToscaMappingWithoutType() throws IOException {
WidgetMapping invalidMapping = new WidgetMapping();
invalidMapping.setType(null);
WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
}
/**
- * Initialise the Artifact Generator Widget Mapping config with incomplete data (no widget name).
+ * Initialize the Artifact Generator Widget Mapping config with invalid data (type value).
+ *
+ * @throws IOException
*/
- @Test(expected = IllegalArgumentException.class)
- public void testToscaMappingWithoutWidget() {
+ @Test(expected = IOException.class)
+ public void testToscaMappingWithInvalidType() throws IOException {
+ WidgetMapping invalidMapping = new WidgetMapping();
+ invalidMapping.setType("invalid");
+ WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
+ }
+
+ /**
+ * Initialize the Artifact Generator Widget Mapping config with incomplete data (no widget name).
+ *
+ * @throws IOException
+ */
+ @Test(expected = IOException.class)
+ public void testToscaMappingWithoutWidget() throws IOException {
WidgetMapping invalidMapping = new WidgetMapping();
invalidMapping.setWidget(null);
WidgetConfigurationUtil.setWidgetMappings(Collections.singletonList(invalidMapping));
}
-
+
/**
* Process a dummy Group object for a Service Resource.
*
diff --git a/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java b/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
index c564a93..f2b78a1 100644
--- a/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
+++ b/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
@@ -26,16 +26,11 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.babel.parser.ArtifactGeneratorToscaParser;
import org.onap.aai.babel.util.ArtifactTestUtils;
import org.onap.aai.babel.xml.generator.model.Widget.Type;
-import org.onap.aai.babel.xml.generator.types.ModelType;
/**
* Direct tests of the Model abstract class (to improve code coverage). Not all methods are tested here. Some are
@@ -43,9 +38,6 @@ import org.onap.aai.babel.xml.generator.types.ModelType;
*/
public class TestModel {
- private Service serviceModel = new Service();
- private List<Resource> resourceModels =
- Arrays.asList(new Resource(Type.CR, true), new Resource(Type.INSTANCE_GROUP, true));
private Widget widgetModel = new Widget(Type.OAM_NETWORK, "oam-network", true);
private Model anonymousModel;
@@ -73,11 +65,6 @@ public class TestModel {
anonymousModel = new Model() {
@Override
- public boolean addResource(Resource resource) {
- return false;
- }
-
- @Override
public boolean addWidget(Widget resource) {
return false;
}
@@ -88,13 +75,8 @@ public class TestModel {
}
@Override
- public Map<String, Object> getProperties() {
- return Collections.emptyMap();
- }
-
- @Override
- public boolean isResource() {
- return false;
+ public String getModelTypeName() {
+ return null;
}
};
}
@@ -149,16 +131,6 @@ public class TestModel {
}
@Test
- public void testGetModelType() {
- assertThat(serviceModel.getModelType(), is(ModelType.SERVICE));
- for (Resource resourceModel : resourceModels) {
- assertThat(resourceModel.getModelType(), is(ModelType.RESOURCE));
- }
- assertThat(widgetModel.getModelType(), is(ModelType.WIDGET));
- assertThat(anonymousModel.getModelType(), is(nullValue()));
- }
-
- @Test
public void testGetModelNameVersionId() {
assertThat(anonymousModel.getModelNameVersionId(), is(nullValue()));
}
@@ -166,9 +138,6 @@ public class TestModel {
@Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
public void testGetModelNameVersionIdIsUnsupported() {
assertThat(widgetModel.getModelNameVersionId(), is(nullValue()));
- assertThat(resourceModels.get(0).getModelType(), is(ModelType.RESOURCE));
- assertThat(widgetModel.getModelType(), is(ModelType.WIDGET));
- assertThat(anonymousModel.getModelType(), is(nullValue()));
}
}