X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fmodelloader%2Fnotification%2FTestBabelArtifactConverter.java;h=aee3dc21c51e761ae1b5158089ca31388b94aa8b;hb=HEAD;hp=1d8151355f2ed409066f6fcc51f6dc59e34182c0;hpb=b5c15a4baafeac466c1565f2237d6f8cdaf9fd72;p=aai%2Fmodel-loader.git diff --git a/src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java b/src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java index 1d81513..aee3dc2 100644 --- a/src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java +++ b/src/test/java/org/onap/aai/modelloader/notification/TestBabelArtifactConverter.java @@ -22,11 +22,9 @@ package org.onap.aai.modelloader.notification; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import org.junit.jupiter.api.Test; @@ -34,6 +32,7 @@ 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.entity.model.ModelArtifactParser; import org.onap.aai.modelloader.fixture.NotificationDataFixtureBuilder; import org.onap.aai.modelloader.util.ArtifactTestUtils; import org.onap.sdc.api.notification.IArtifactInfo; @@ -47,17 +46,11 @@ public class TestBabelArtifactConverter { @Test public void convert_nullToscaFiles() throws BabelArtifactParsingException { assertThrows(NullPointerException.class, () -> { - new BabelArtifactConverter().convertToModel(null); + new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(null); fail("An instance of ArtifactGenerationException should have been thrown"); }); } - @Test - public void testEmptyToscaFiles() throws BabelArtifactParsingException { - assertTrue(new BabelArtifactConverter().convertToModel(new ArrayList<>()).isEmpty(), - "Nothing should have been returned"); - } - @Test public void testInvalidXml() throws IOException, BabelArtifactParsingException { assertThrows(BabelArtifactParsingException.class, () -> { @@ -67,22 +60,20 @@ public class TestBabelArtifactConverter { INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile(); - List toscaArtifacts = setupTest(problemXml, data); + BabelArtifact toscaArtifact = setupTest(problemXml, data); - new BabelArtifactConverter().convertToModel(toscaArtifacts); + new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(toscaArtifact); fail("An instance of ModelArtifactParsingException should have been thrown"); }); } - private List setupTest(byte[] xml, INotificationData data) throws IOException { - List toscaArtifacts = new ArrayList<>(); + private BabelArtifact setupTest(byte[] xml, INotificationData data) throws IOException { IArtifactInfo artifactInfo = data.getServiceArtifacts().get(0); BabelArtifact xmlArtifact = new BabelArtifact(artifactInfo.getArtifactName(), BabelArtifact.ArtifactType.MODEL, new String(xml)); - toscaArtifacts.add(xmlArtifact); - return toscaArtifacts; + return xmlArtifact; } @Test @@ -90,9 +81,9 @@ public class TestBabelArtifactConverter { INotificationData data = NotificationDataFixtureBuilder.getNotificationDataWithToscaCsarFile(); byte[] xml = new ArtifactTestUtils().loadResource("convertedYmls/AAI-SCP-Test-VSP-resource-1.0.xml"); - List toscaArtifacts = setupTest(xml, data); + BabelArtifact toscaArtifact = setupTest(xml, data); - List modelArtifacts = new BabelArtifactConverter().convertToModel(toscaArtifacts); + List modelArtifacts = new BabelArtifactConverter(new ModelArtifactParser()).convertToModel(toscaArtifact); assertEquals(1, modelArtifacts.size(), "There should have been 1 artifact"); assertEquals(new String(xml), modelArtifacts.get(0).getPayload());