SVG microservice uniqueness 68/82268/2
authorsebdet <sebastien.determe@intl.att.com>
Thu, 14 Mar 2019 15:31:25 +0000 (16:31 +0100)
committersebdet <sebastien.determe@intl.att.com>
Thu, 14 Mar 2019 15:55:14 +0000 (16:55 +0100)
Add field to support uniqueness of the microservice in the SVG

Issue-ID: CLAMP-284
Change-Id: Idbfe593374eecf6f180725ad5ae5b077020a9f14
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java
src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java
src/main/java/org/onap/clamp/clds/util/drawing/Painter.java
src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java
src/main/java/org/onap/clamp/loop/CsarInstallerImpl.java
src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java
src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java
src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java

index 542411b..c8de4c5 100644 (file)
@@ -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) {
index 287ac9a..198bf0e 100644 (file)
@@ -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);
+    }
 }
index 243cb4a..ef4c4e4 100755 (executable)
@@ -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));
index e41ca8f..6263f30 100755 (executable)
@@ -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);
     }
 
-
 }
index 0ba8486..f5bd6e7 100644 (file)
@@ -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();
     }
index 07f1b77..6505288 100644 (file)
@@ -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) {
index 2a2ab94..551ac1b 100644 (file)
@@ -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);
     }
index 9573515..2ec5087 100644 (file)
@@ -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);
index 477e6a7..459a701 100644 (file)
@@ -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)