From 7eb234559c64c4702ae621d7d2f531868677cdae Mon Sep 17 00:00:00 2001 From: sebdet Date: Wed, 8 May 2019 11:33:43 +0200 Subject: Fix model_type missing Fix model missing in some cases (new DCAE Blueprint), also removed useless fields in MicroService Object Issue-ID: CLAMP-370 Change-Id: Ia246b5d58309aceb3168107a4bf76b92b23add7a Signed-off-by: sebdet --- .../controller/installer/CsarInstallerItCase.java | 7 +++---- .../controller/installer/BlueprintParserTest.java | 14 ++++++------- .../controller/installer/ChainGeneratorTest.java | 24 +++++++++++----------- .../clds/util/drawing/ClampGraphBuilderTest.java | 8 ++++---- .../org/onap/clamp/loop/CsarInstallerItCase.java | 12 +++++++++++ 5 files changed, 38 insertions(+), 27 deletions(-) (limited to 'src/test/java') diff --git a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java index 36d4eb829..e1b963cc4 100644 --- a/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/sdc/controller/installer/CsarInstallerItCase.java @@ -179,10 +179,9 @@ public class CsarInstallerItCase { ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-2.json"), StandardCharsets.UTF_8), cldsModel2.getPropText(), true); CldsModel cldsModel3 = verifyClosedLoopModelLoadedInDb(csar, "tca_3.yaml"); - JSONAssert.assertEquals( - IOUtils.toString(ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca.json"), - StandardCharsets.UTF_8), - cldsModel3.getPropText(), true); + JSONAssert.assertEquals(IOUtils.toString( + ResourceFileUtil.getResourceAsStream("example/sdc/blueprint-dcae/prop-text-for-tca-3.json"), + StandardCharsets.UTF_8), cldsModel3.getPropText(), true); } private CldsModel verifyClosedLoopModelLoadedInDb(CsarHandler csar, String artifactName) diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java index 211bb3906..7a1f9f0ac 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java @@ -142,18 +142,18 @@ public class BlueprintParserTest { public void getNodeRepresentationFromCompleteYaml() { final JsonObject jsonObject = jsonObjectBlueprintValid; - MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, "", SECOND_APPP); + MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, ""); Entry entry = jsonObject.entrySet().iterator().next(); - MicroService actual = new BlueprintParser().getNodeRepresentation(entry); + MicroService actual = new BlueprintParser().getNodeRepresentation(entry, jsonObject); Assert.assertEquals(expected, actual); } @Test public void getMicroServicesFromBlueprintTest() { - MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", "", THIRD_APPP); - MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, "", FIRST_APPP); - MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, "", SECOND_APPP); + MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", ""); + MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, ""); + MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, ""); Set expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp)); Set actual = new BlueprintParser().getMicroServices(microServiceTheWholeBlueprintValid); @@ -164,7 +164,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceTCATest() { MicroService tcaMS = new MicroService(BlueprintParser.TCA, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", - "", ""); + ""); List expected = Collections.singletonList(tcaMS); List actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA); @@ -175,7 +175,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceHolmesTest() { MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "onap.policies.monitoring.cdap.tca.hi.lo.app", - "", "", ""); + "", ""); List expected = Collections.singletonList(holmesMS); List actual = new BlueprintParser() diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java index 1eb66eadd..4b41ee818 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java @@ -38,10 +38,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, "", ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, ""); List expectedList = Arrays.asList(ms1, ms2, ms3, ms4); Set inputSet = new HashSet<>(expectedList); @@ -52,10 +52,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesTwiceNoInputTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", "", "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, "", ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", "", ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, ""); Set inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); @@ -64,10 +64,10 @@ public class ChainGeneratorTest { @Test public void getChainOfMicroServicesBranchingTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, "", ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, "", ""); + MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); + MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, ""); + MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, ""); + MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, ""); Set inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java index 5eb664fe7..ff6e1b5d4 100644 --- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java +++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java @@ -56,8 +56,8 @@ public class ClampGraphBuilderTest { @Test public void clampGraphBuilderCompleteChainTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", ""); - MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", ""); + MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id"); + MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id"); String policy = "OperationalPolicy"; List microServices = Arrays.asList(ms1, ms2); @@ -76,8 +76,8 @@ public class ClampGraphBuilderTest { @Test(expected = InvalidStateException.class) public void clampGraphBuilderNoPolicyGivenTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id", ""); - MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id", ""); + MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id"); + MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id"); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build(); diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index 3bf85009a..cd6db68db 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -51,6 +51,7 @@ import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.sdc.api.notification.IArtifactInfo; import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; @@ -206,6 +207,17 @@ public class CsarInstallerItCase { assertThat(loop.getModelPropertiesJson().get("resourceDetails")).isNotNull(); JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), JsonUtils.GSON.toJson(loop.getModelPropertiesJson()), true); + assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty(); + + loop = loopsRepo + .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE1, "tca_3.yaml")) + .get(); + assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty(); + + loop = loopsRepo + .findById(Loop.generateLoopName(generatedName, "1.0", RESOURCE_INSTANCE_NAME_RESOURCE2, "tca_2.yaml")) + .get(); + assertThat(((MicroServicePolicy) (loop.getMicroServicePolicies().toArray()[0])).getModelType()).isNotEmpty(); } } -- cgit 1.2.3-korg