X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fmodelloader%2Fnotification%2FTestBabelArtifactConverter.java;fp=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fmodelloader%2Fnotification%2FBabelArtifactConverterTest.java;h=718c415fd496f44ccf63c4aba056c52c00eaeeaa;hb=refs%2Fchanges%2F97%2F50697%2F1;hp=e9e6059e4caddd17be17db5a825ac3d2eea8b15f;hpb=ce332032dd208c5c769a2297409d8aca3f780fa8;p=aai%2Fmodel-loader.git
diff --git a/src/test/java/org/onap/aai/modelloader/notification/BabelArtifactConverterTest.java b/src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java
similarity index 68%
rename from src/test/java/org/onap/aai/modelloader/notification/BabelArtifactConverterTest.java
rename to src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java
index e9e6059..718c415 100644
--- a/src/test/java/org/onap/aai/modelloader/notification/BabelArtifactConverterTest.java
+++ b/src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java
@@ -1,5 +1,5 @@
/**
- * ============LICENSE_START=======================================================
+ * ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
@@ -20,6 +20,7 @@
*/
package org.onap.aai.modelloader.notification;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -28,15 +29,18 @@ import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.onap.aai.babel.service.data.BabelArtifact;
+import org.onap.aai.modelloader.entity.Artifact;
+import org.onap.aai.modelloader.entity.ArtifactType;
import org.onap.aai.modelloader.entity.model.BabelArtifactParsingException;
import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder;
+import org.onap.aai.modelloader.util.ArtifactTestUtils;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
/**
- * Tests {@link BabelArtifactConverter}
+ * Tests {@link BabelArtifactConverter}.
*/
-public class BabelArtifactConverterTest {
+public class TestBabelArtifactConverter {
@Test(expected = NullPointerException.class)
public void convert_nullToscaFiles() throws BabelArtifactParsingException {
@@ -45,20 +49,20 @@ public class BabelArtifactConverterTest {
}
@Test
- public void convert_emptyToscaFiles() throws BabelArtifactParsingException {
+ public void testEmptyToscaFiles() throws BabelArtifactParsingException {
assertTrue("Nothing should have been returned",
new BabelArtifactConverter().convertToModel(new ArrayList<>()).isEmpty());
}
@Test(expected = BabelArtifactParsingException.class)
- public void convert_problemWithConvertedXML() throws IOException, BabelArtifactParsingException {
- byte[] problemXML =
+ public void testInvalidXml() throws IOException, BabelArtifactParsingException {
+ byte[] problemXml =
"This is some xml that should cause the model artifact parser to throw an erorr"
.getBytes();
INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
- List toscaArtifacts = setupTest(problemXML, data);
+ List toscaArtifacts = setupTest(problemXml, data);
new BabelArtifactConverter().convertToModel(toscaArtifacts);
fail("An instance of ModelArtifactParsingException should have been thrown");
@@ -74,4 +78,18 @@ public class BabelArtifactConverterTest {
return toscaArtifacts;
}
+
+ @Test
+ public void convert_singleResourceFile() throws BabelArtifactParsingException, IOException {
+ INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile();
+
+ byte[] xml = new ArtifactTestUtils().loadResource("convertedYmls/AAI-SCP-Test-VSP-resource-1.0.xml");
+ List toscaArtifacts = setupTest(xml, data);
+
+ List modelArtifacts = new BabelArtifactConverter().convertToModel(toscaArtifacts);
+
+ assertTrue("There should have been 1 artifact", modelArtifacts.size() == 1);
+ assertEquals(new String(xml), modelArtifacts.get(0).getPayload());
+ assertEquals(ArtifactType.MODEL, modelArtifacts.get(0).getType());
+ }
}