aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/babel/parser/TestToscaParser.java4
-rw-r--r--src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java34
-rw-r--r--src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java19
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java9
-rw-r--r--src/test/resources/artifact-generator.properties5
-rw-r--r--src/test/resources/filter-types.properties1
6 files changed, 59 insertions, 13 deletions
diff --git a/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
index f340132..3bab915 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestToscaParser.java
@@ -54,12 +54,16 @@ public class TestToscaParser {
}
private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
+ private static final String FILTER_TYPES_CONFIG = "filter-types.properties";
@Before
public void setup() throws FileNotFoundException, IOException {
System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE,
+ new ArtifactTestUtils().getResourcePath(FILTER_TYPES_CONFIG));
+
InputStream in = TestToscaParser.class.getClassLoader().getResourceAsStream("artifact-generator.properties");
Properties properties = new Properties();
properties.load(in);
diff --git a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
index 67539bb..bf970a6 100644
--- a/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
+++ b/src/test/java/org/onap/aai/babel/service/CsarToXmlConverterTest.java
@@ -52,6 +52,8 @@ import org.onap.aai.babel.xml.generator.XmlArtifactGenerationException;
public class CsarToXmlConverterTest {
private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
+ private static final String FILTER_TYPES_CONFIG = "filter-types.properties";
+
private static final String INCORRECT_CSAR_NAME = "the_name_of_the_csar_file.csar";
private static final String SERVICE_VERSION = "1.0";
@@ -71,6 +73,10 @@ public class CsarToXmlConverterTest {
public void setup() {
System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
+
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE,
+ new ArtifactTestUtils().getResourcePath(FILTER_TYPES_CONFIG));
+
converter = new CsarToXmlConverter();
}
@@ -110,15 +116,14 @@ public class CsarToXmlConverterTest {
*
* @throws CsarConverterException if there is an error either extracting the YAML files or generating XML artifacts
* @throws IOException if an I/O exception occurs loading the test CSAR file
+ * @throws IOException
+ * @throws XmlArtifactGenerationException
+ * @throws CsarConverterException
*/
@Test
public void testArtifactGeneratorConfigMissing() throws CsarConverterException, IOException {
exception.expect(CsarConverterException.class);
- exception.expectMessage(
- "An error occurred trying to generate XML files from a collection of YAML files :"
- + " org.onap.aai.babel.xml.generator.XmlArtifactGenerationException: "
- + "Error occurred during artifact generation: "
- + "{AAI=[Cannot generate artifacts. artifactgenerator.config system property not configured]}");
+ exception.expectMessage("Cannot generate artifacts. System property artifactgenerator.config not configured");
// Unset the required system property
System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE);
@@ -126,6 +131,25 @@ public class CsarToXmlConverterTest {
SERVICE_VERSION);
}
+ /**
+ * Test that an Exception is thrown when the Artifact Generator's Group Filter properties are not present.
+ *
+ * @throws IOException
+ * @throws XmlArtifactGenerationException
+ * @throws CsarConverterException
+ */
+ @Test
+ public void generateXmlFromCsarFilterTypesSystemPropertyNotSet()
+ throws IOException, XmlArtifactGenerationException, CsarConverterException {
+ exception.expect(CsarConverterException.class);
+ exception.expectMessage("Cannot generate artifacts. System property groupfilter.config not configured");
+
+ // Unset the required system property
+ System.clearProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE);
+ converter.generateXmlFromCsar(CsarTest.SD_WAN_CSAR_FILE.getContent(), CsarTest.SD_WAN_CSAR_FILE.getName(),
+ SERVICE_VERSION);
+ }
+
@Test
public void testServiceMetadataMissing()
throws IOException, XmlArtifactGenerationException, CsarConverterException {
diff --git a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
index 599b3ff..78e02f4 100644
--- a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
+++ b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
@@ -55,7 +55,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:/babel-beans.xml"})
+@ContextConfiguration(locations = { "classpath:/babel-beans.xml" })
public class TestGenerateArtifactsServiceImpl {
static {
@@ -66,6 +66,7 @@ public class TestGenerateArtifactsServiceImpl {
}
private static final String ARTIFACT_GENERATOR_CONFIG = "artifact-generator.properties";
+ private static final String FILTER_TYPES_CONFIG = "filter-types.properties";
@Inject
private AAIMicroServiceAuth auth;
@@ -74,6 +75,8 @@ public class TestGenerateArtifactsServiceImpl {
public static void setup() {
System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_ARTIFACT_GENERATOR_CONFIG_FILE,
new ArtifactTestUtils().getResourcePath(ARTIFACT_GENERATOR_CONFIG));
+ System.setProperty(ArtifactGeneratorToscaParser.PROPERTY_GROUP_FILTERS_CONFIG_FILE,
+ new ArtifactTestUtils().getResourcePath(FILTER_TYPES_CONFIG));
}
@Test
@@ -148,8 +151,10 @@ public class TestGenerateArtifactsServiceImpl {
*
* @param csar
* @return the Response from the HTTP API
- * @throws URISyntaxException if the URI cannot be created
- * @throws IOException if the resource cannot be loaded
+ * @throws URISyntaxException
+ * if the URI cannot be created
+ * @throws IOException
+ * if the resource cannot be loaded
*/
private Response processJsonRequest(CsarTest csar) throws IOException, URISyntaxException {
String jsonString = csar.getJsonRequest();
@@ -159,9 +164,11 @@ public class TestGenerateArtifactsServiceImpl {
/**
* Create a (mocked) HTTPS request and invoke the Babel generate artifacts API.
*
- * @param jsonString the JSON request
+ * @param jsonString
+ * the JSON request
* @return the Response from the HTTP API
- * @throws URISyntaxException if the URI cannot be created
+ * @throws URISyntaxException
+ * if the URI cannot be created
*/
private Response invokeService(String jsonString) throws URISyntaxException {
UriInfo mockUriInfo = Mockito.mock(UriInfo.class);
@@ -192,7 +199,7 @@ public class TestGenerateArtifactsServiceImpl {
Mockito.when(mockCertificate.getSubjectX500Principal())
.thenReturn(new X500Principal("CN=test, OU=qa, O=Test Ltd, L=London, ST=London, C=GB"));
- servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] {mockCertificate});
+ servletRequest.setAttribute("javax.servlet.request.X509Certificate", new X509Certificate[] { mockCertificate });
servletRequest.setAttribute("javax.servlet.request.cipher_suite", "");
GenerateArtifactsServiceImpl service = new GenerateArtifactsServiceImpl(auth);
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 2bd6fc7..9b5700d 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
@@ -45,7 +45,7 @@ import org.onap.aai.babel.xml.generator.types.ModelType;
public class TestModel {
private Service serviceModel = new Service();
- private List<Resource> resourceModels = Arrays.asList(new VirtualFunction());
+ private List<Resource> resourceModels = Arrays.asList(new VirtualFunction(), new InstanceGroup());
private Widget widgetModel = new OamNetwork();
private Model anonymousModel;
@@ -109,6 +109,13 @@ public class TestModel {
assertThat(Model.getModelFor("org.openecomp.resource.vfc.nodes.heat.cinder"), instanceOf(VolumeWidget.class));
assertThat(Model.getModelFor("org.openecomp.nodes.PortMirroringConfiguration"),
instanceOf(Configuration.class));
+ assertThat(Model.getModelFor("org.openecomp.nodes.PortMirroringConfiguration", "Configuration"),
+ instanceOf(Configuration.class));
+ assertThat(Model.getModelFor("any.string", "Configuration"), instanceOf(Configuration.class));
+ assertThat(Model.getModelFor("org.openecomp.resource.cr.Kk1806Cr1", "CR"), instanceOf(CR.class));
+ assertThat(Model.getModelFor("any.string", "CR"), instanceOf(CR.class));
+
+ assertThat(Model.getModelFor("org.openecomp.resource.vfc", "an.unknown.type"), instanceOf(VServerWidget.class));
}
@Test
diff --git a/src/test/resources/artifact-generator.properties b/src/test/resources/artifact-generator.properties
index ba207cf..1a905b6 100644
--- a/src/test/resources/artifact-generator.properties
+++ b/src/test/resources/artifact-generator.properties
@@ -1,4 +1,4 @@
-#action widget details
+#action widget details
AAI.model-version-id.action=action-version-id
AAI.model-invariant-id.action=action-invariant-id
#action-data widget details
@@ -265,3 +265,6 @@ AAI.model-version-id.vpn-binding=vpn-binding-version-id
#vserver widget details
AAI.model-invariant-id.vserver=vserver-invariant-id
AAI.model-version-id.vserver=vserver-version-id
+#cr (Collection Resource) widget details
+AAI.model-version-id.cr=collection-resource-version-id
+AAI.model-invariant-id.cr=collection-resource-invariant-id
diff --git a/src/test/resources/filter-types.properties b/src/test/resources/filter-types.properties
new file mode 100644
index 0000000..fcf139f
--- /dev/null
+++ b/src/test/resources/filter-types.properties
@@ -0,0 +1 @@
+AAI.instance-group-types=org.openecomp.groups.NetworkCollection,org.openecomp.groups.VfcInstanceGroup