diff options
9 files changed, 131 insertions, 118 deletions
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java index 542411b0f..c8de4c589 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ + * Modifications copyright (c) 2019 AT&T * =================================================================== * */ @@ -84,7 +85,7 @@ public class BlueprintParser { } } String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA; - return Collections.singletonList(new MicroService(msName, "")); + return Collections.singletonList(new MicroService(msName, "", "")); } String getName(Entry<String, JsonElement> entry) { @@ -116,7 +117,7 @@ public class BlueprintParser { MicroService getNodeRepresentation(Entry<String, JsonElement> entry) { String name = getName(entry); String getInputFrom = getInput(entry); - return new MicroService(name, getInputFrom); + return new MicroService(name, getInputFrom, ""); } private String getTarget(JsonObject elementObject) { diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java index 287ac9a90..198bf0ede 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ + * Modifications copyright (c) 2019 AT&T * =================================================================== * */ @@ -25,44 +26,52 @@ package org.onap.clamp.clds.sdc.controller.installer; import java.util.Objects; public class MicroService { - private final String name; - private final String inputFrom; + private final String name; + private final String inputFrom; + private String mappedNameJpa; - public MicroService(String name, String inputFrom) { - this.name = name; - this.inputFrom = inputFrom; - } - public String getName() { - return name; - } + public MicroService(String name, String inputFrom, String mappedNameJpa) { + this.name = name; + this.inputFrom = inputFrom; + this.mappedNameJpa = mappedNameJpa; + } - public String getInputFrom() { - return inputFrom; - } + public String getName() { + return name; + } - @Override - public String toString() { - return "MicroService{" + - "name='" + name + '\'' + - ", inputFrom='" + inputFrom + '\'' + - '}'; - } + public String getInputFrom() { + return inputFrom; + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; + @Override + public String toString() { + return "MicroService{" + "name='" + name + '\'' + ", inputFrom='" + inputFrom + '\'' + ", mappedNameJpa='" + + mappedNameJpa + '\'' + '}'; } - if (o == null || getClass() != o.getClass()) { - return false; + + public String getMappedNameJpa() { + return mappedNameJpa; } - MicroService that = (MicroService) o; - return name.equals(that.name) && - inputFrom.equals(that.inputFrom); - } - @Override - public int hashCode() { - return Objects.hash(name, inputFrom); - } + public void setMappedNameJpa(String mappedNameJpa) { + this.mappedNameJpa = mappedNameJpa; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MicroService that = (MicroService) o; + return name.equals(that.name) && inputFrom.equals(that.inputFrom) && mappedNameJpa.equals(that.mappedNameJpa); + } + + @Override + public int hashCode() { + return Objects.hash(name, inputFrom, mappedNameJpa); + } } diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java index 243cb4aad..ef4c4e43d 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ + * Modifications copyright (c) 2019 AT&T * =================================================================== * */ @@ -27,10 +28,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; +import org.onap.clamp.clds.sdc.controller.installer.MicroService; + public class ClampGraphBuilder { private String policy; private String collector; - private List<String> microServices = new ArrayList<>(); + private List<MicroService> microServices = new ArrayList<>(); private final Painter painter; public ClampGraphBuilder(Painter painter) { @@ -47,16 +50,21 @@ public class ClampGraphBuilder { return this; } - public ClampGraphBuilder microService(String ms) { + public ClampGraphBuilder addMicroService(MicroService ms) { microServices.add(ms); return this; } + public ClampGraphBuilder addAllMicroServices(List<MicroService> msList) { + microServices.addAll(msList); + return this; + } + public ClampGraph build() { - if(microServices.isEmpty()) { + if (microServices.isEmpty()) { throw new InvalidStateException("At least one microservice is required"); } - if(Objects.isNull(policy) || policy.trim().isEmpty()) { + if (Objects.isNull(policy) || policy.trim().isEmpty()) { throw new InvalidStateException("Policy element must be present"); } return new ClampGraph(painter.doPaint(collector, microServices, policy)); diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java index e41ca8fb3..6263f30ba 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ + * Modifications copyright (c) 2019 AT&T * =================================================================== * */ @@ -28,7 +29,9 @@ import java.awt.Color; import java.awt.Point; import java.awt.RenderingHints; import java.util.List; + import org.apache.batik.svggen.SVGGraphics2D; +import org.onap.clamp.clds.sdc.controller.installer.MicroService; public class Painter { private final int canvasSize; @@ -47,7 +50,7 @@ public class Painter { this.canvasSize = DEFALUT_CANVAS_SIZE; } - DocumentBuilder doPaint(String collector, List<String> microServices, String policy) { + DocumentBuilder doPaint(String collector, List<MicroService> microServices, String policy) { int numOfRectangles = 2 + microServices.size(); int numOfArrows = numOfRectangles + 1; int baseLength = (canvasSize - 2 * CIRCLE_RADIUS) / (numOfArrows + numOfRectangles); @@ -63,29 +66,22 @@ public class Painter { return ib.getDocumentBuilder(); } - private void doTheActualDrawing(String collector, List<String> microServices, String policy, ImageBuilder ib) { - ib.circle("start-circle", SLIM_LINE) - .arrow() - .rectangle(collector, RectTypes.COLECTOR, collector); + private void doTheActualDrawing(String collector, List<MicroService> microServices, String policy, + ImageBuilder ib) { + ib.circle("start-circle", SLIM_LINE).arrow().rectangle(collector, RectTypes.COLECTOR, collector); - for(String ms : microServices) { - ib.arrow().rectangle(ms, RectTypes.MICROSERVICE, ms); + for (MicroService ms : microServices) { + ib.arrow().rectangle(ms.getMappedNameJpa(), RectTypes.MICROSERVICE, ms.getName()); } - ib.arrow() - .rectangle(policy, RectTypes.POLICY, policy) - .arrow() - .circle("stop-circle", THICK_LINE); + ib.arrow().rectangle(policy, RectTypes.POLICY, policy).arrow().circle("stop-circle", THICK_LINE); } private void adjustGraphics2DProperties() { - g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, - RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); + g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); g2d.setStroke(new BasicStroke(SLIM_LINE)); g2d.setPaint(Color.BLACK); } - } diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java b/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java index 0ba848639..f5bd6e79d 100644 --- a/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ + * Modifications copyright (c) 2019 AT&T * =================================================================== * */ @@ -24,6 +25,7 @@ package org.onap.clamp.clds.util.drawing; import java.util.List; + import org.apache.batik.svggen.SVGGraphics2D; import org.onap.clamp.clds.sdc.controller.installer.MicroService; import org.onap.clamp.clds.util.XmlTools; @@ -38,9 +40,7 @@ public class SvgFacade { DocumentBuilder dp = new DocumentBuilder(document, svgGraphics2D.getDOMFactory()); Painter p = new Painter(svgGraphics2D, dp); ClampGraphBuilder cgp = new ClampGraphBuilder(p).collector("VES"); - for(MicroService ms : microServicesChain) { - cgp = cgp.microService(ms.getName()); - } + cgp.addAllMicroServices(microServicesChain); ClampGraph cg = cgp.policy("Policy").build(); return cg.getAsSVG(); } diff --git a/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java index 07f1b777f..65052888d 100644 --- a/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java +++ b/src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java @@ -118,16 +118,6 @@ public class CsarInstallerImpl implements CsarInstaller { } } - private String getSvgInLoop(BlueprintArtifact blueprintArtifact) { - List<MicroService> microServicesChain = chainGenerator - .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint())); - if (microServicesChain.isEmpty()) { - microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint()); - } - return svgFacade.getSvgImage(microServicesChain); - - } - private Loop createLoopFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact) throws IOException, ParseException, InterruptedException { Loop newLoop = new Loop(); @@ -137,10 +127,18 @@ public class CsarInstallerImpl implements CsarInstaller { blueprintArtifact.getResourceAttached().getResourceInstanceName(), blueprintArtifact.getBlueprintArtifactName())); newLoop.setLastComputedState(LoopState.DESIGN); - newLoop.setMicroServicePolicies(createMicroServicePolicies(csar, blueprintArtifact, newLoop)); + + List<MicroService> microServicesChain = chainGenerator + .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint())); + if (microServicesChain.isEmpty()) { + microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint()); + } + + newLoop + .setMicroServicePolicies(createMicroServicePolicies(microServicesChain, csar, blueprintArtifact, newLoop)); newLoop.setOperationalPolicies(createOperationalPolicies(csar, blueprintArtifact, newLoop)); - newLoop.setSvgRepresentation(getSvgInLoop(blueprintArtifact)); + newLoop.setSvgRepresentation(svgFacade.getSvgImage(microServicesChain)); newLoop.setGlobalPropertiesJson(createGlobalPropertiesJson(blueprintArtifact)); newLoop.setModelPropertiesJson(createModelPropertiesJson(csar)); DcaeInventoryResponse dcaeResponse = queryDcaeToGetServiceTypeId(blueprintArtifact); @@ -156,21 +154,20 @@ public class CsarInstallerImpl implements CsarInstaller { blueprintArtifact.getBlueprintArtifactName()), newLoop, new JsonObject()))); } - private HashSet<MicroServicePolicy> createMicroServicePolicies(CsarHandler csar, - BlueprintArtifact blueprintArtifact, Loop newLoop) throws IOException { + private HashSet<MicroServicePolicy> createMicroServicePolicies(List<MicroService> microServicesChain, + CsarHandler csar, BlueprintArtifact blueprintArtifact, Loop newLoop) throws IOException { HashSet<MicroServicePolicy> newSet = new HashSet<>(); - List<MicroService> microServicesChain = chainGenerator - .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint())); - if (microServicesChain.isEmpty()) { - microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint()); - } + for (MicroService microService : microServicesChain) { - newSet.add(new MicroServicePolicy( + MicroServicePolicy microServicePolicy = new MicroServicePolicy( Policy.generatePolicyName(microService.getName(), csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(), blueprintArtifact.getResourceAttached().getResourceInstanceName(), blueprintArtifact.getBlueprintArtifactName()), - csar.getPolicyModelYaml().orElse(""), false, new HashSet<>(Arrays.asList(newLoop)))); + csar.getPolicyModelYaml().orElse(""), false, new HashSet<>(Arrays.asList(newLoop))); + + newSet.add(microServicePolicy); + microService.setMappedNameJpa(microServicePolicy.getName()); } return newSet; } @@ -179,7 +176,6 @@ public class CsarInstallerImpl implements CsarInstaller { JsonObject globalProperties = new JsonObject(); globalProperties.add("dcaeDeployParameters", getAllBlueprintParametersInJson(blueprintArtifact)); return globalProperties; - } private JsonObject createModelPropertiesJson(CsarHandler csar) { 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 2a2ab94e6..551ac1b30 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 @@ -25,6 +25,7 @@ package org.onap.clamp.clds.sdc.controller.installer; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; + import java.io.IOException; import java.util.Arrays; import java.util.Collections; @@ -33,6 +34,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; + import org.json.JSONObject; import org.junit.Assert; import org.junit.BeforeClass; @@ -59,10 +61,8 @@ public class BlueprintParserTest { public static void loadBlueprints() throws IOException { microServiceTheWholeBlueprintValid = ResourceFileUtil .getResourceAsString("clds/blueprint-with-microservice-chain.yaml"); - microServiceBlueprintOldStyleTCA = ResourceFileUtil - .getResourceAsString("clds/tca-old-style-ms.yaml"); - microServiceBlueprintOldStyleHolmes = ResourceFileUtil - .getResourceAsString("clds/holmes-old-style-ms.yaml"); + microServiceBlueprintOldStyleTCA = ResourceFileUtil.getResourceAsString("clds/tca-old-style-ms.yaml"); + microServiceBlueprintOldStyleHolmes = ResourceFileUtil.getResourceAsString("clds/holmes-old-style-ms.yaml"); String microServiceBlueprintValid = ResourceFileUtil .getResourceAsString("clds/single-microservice-fragment-valid.yaml"); @@ -83,10 +83,8 @@ public class BlueprintParserTest { @Test public void getNameShouldReturnDefinedName() { final JsonObject jsonObject = jsonObjectBlueprintValid; - String expectedName = jsonObject.get(jsonObject.keySet().iterator().next()) - .getAsJsonObject().get("properties") - .getAsJsonObject().get("name") - .getAsString(); + String expectedName = jsonObject.get(jsonObject.keySet().iterator().next()).getAsJsonObject().get("properties") + .getAsJsonObject().get("name").getAsString(); Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next(); String actualName = new BlueprintParser().getName(entry); @@ -141,7 +139,7 @@ public class BlueprintParserTest { public void getNodeRepresentationFromCompleteYaml() { final JsonObject jsonObject = jsonObjectBlueprintValid; - MicroService expected = new MicroService(SECOND_APPP, FIRST_APPP); + MicroService expected = new MicroService(SECOND_APPP, FIRST_APPP, ""); Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next(); MicroService actual = new BlueprintParser().getNodeRepresentation(entry); @@ -150,9 +148,9 @@ public class BlueprintParserTest { @Test public void getMicroServicesFromBlueprintTest() { - MicroService thirdApp = new MicroService(THIRD_APPP, ""); - MicroService firstApp = new MicroService(FIRST_APPP, THIRD_APPP); - MicroService secondApp = new MicroService(SECOND_APPP, FIRST_APPP); + MicroService thirdApp = new MicroService(THIRD_APPP, "", ""); + MicroService firstApp = new MicroService(FIRST_APPP, THIRD_APPP, ""); + MicroService secondApp = new MicroService(SECOND_APPP, FIRST_APPP, ""); Set<MicroService> expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp)); Set<MicroService> actual = new BlueprintParser().getMicroServices(microServiceTheWholeBlueprintValid); @@ -162,7 +160,7 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceTCATest() { - MicroService tcaMS = new MicroService(BlueprintParser.TCA, ""); + MicroService tcaMS = new MicroService(BlueprintParser.TCA, "", ""); List<MicroService> expected = Collections.singletonList(tcaMS); List<MicroService> actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA); @@ -172,11 +170,11 @@ public class BlueprintParserTest { @Test public void fallBackToOneMicroServiceHolmesTest() { - MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, ""); + MicroService holmesMS = new MicroService(BlueprintParser.HOLMES, "", ""); List<MicroService> expected = Collections.singletonList(holmesMS); - List<MicroService> actual = - new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleHolmes); + List<MicroService> actual = new BlueprintParser() + .fallbackToOneMicroService(microServiceBlueprintOldStyleHolmes); Assert.assertEquals(expected, actual); } 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 9573515d2..2ec508799 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 @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; + import org.junit.Assert; import org.junit.Test; @@ -37,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<MicroService> expectedList = Arrays.asList(ms1, ms2, ms3, ms4); Set<MicroService> inputSet = new HashSet<>(expectedList); @@ -51,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<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet); @@ -63,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<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); List<MicroService> 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 477e6a73f..459a701fe 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 @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ + * Modifications copyright (c) 2019 AT&T * =================================================================== * */ @@ -28,6 +29,7 @@ import static org.mockito.Mockito.verify; import java.util.Arrays; import java.util.List; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,6 +37,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; +import org.onap.clamp.clds.sdc.controller.installer.MicroService; @RunWith(MockitoJUnitRunner.class) public class ClampGraphBuilderTest { @@ -45,7 +48,7 @@ public class ClampGraphBuilderTest { private ArgumentCaptor<String> collectorCaptor; @Captor - private ArgumentCaptor<List<String>> microServicesCaptor; + private ArgumentCaptor<List<MicroService>> microServicesCaptor; @Captor private ArgumentCaptor<String> policyCaptor; @@ -53,16 +56,17 @@ public class ClampGraphBuilderTest { @Test public void clampGraphBuilderCompleteChainTest() { String collector = "VES"; - String ms1 = "ms1"; - String ms2 = "ms2"; + MicroService ms1 = new MicroService("ms1", "", "ms1_jpa_id"); + MicroService ms2 = new MicroService("ms2", "", "ms2_jpa_id"); + ; String policy = "Policy"; - List<String> microServices = Arrays.asList(ms1, ms2); + List<MicroService> microServices = Arrays.asList(ms1, ms2); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); - clampGraphBuilder.collector(collector).microService(ms1).microService(ms2).policy(policy).build(); + clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).policy(policy).build(); - verify(mockPainter, times(1)) - .doPaint(collectorCaptor.capture(), microServicesCaptor.capture(), policyCaptor.capture()); + verify(mockPainter, times(1)).doPaint(collectorCaptor.capture(), microServicesCaptor.capture(), + policyCaptor.capture()); Assert.assertEquals(collector, collectorCaptor.getValue()); Assert.assertEquals(microServices, microServicesCaptor.getValue()); @@ -72,11 +76,11 @@ public class ClampGraphBuilderTest { @Test(expected = InvalidStateException.class) public void clampGraphBuilderNoPolicyGivenTest() { String collector = "VES"; - String ms1 = "ms1"; - String ms2 = "ms2"; + MicroService ms1 = new MicroService("ms1", "", "ms1_jpa_id"); + MicroService ms2 = new MicroService("ms2", "", "ms2_jpa_id"); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); - clampGraphBuilder.collector(collector).microService(ms1).microService(ms2).build(); + clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build(); } @Test(expected = InvalidStateException.class) |