summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2019-03-14 16:31:25 +0100
committersebdet <sebastien.determe@intl.att.com>2019-03-14 16:55:14 +0100
commit493298b4191b37df7c752bdcc050c27dd6ea4c52 (patch)
treed26e6f1b9485d5aa8bb3cd3867f8998857a0def4 /src/test
parent4549fd92024cdadf3277d7cc364f33109ca22b59 (diff)
SVG microservice uniqueness
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>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java30
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java25
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java24
3 files changed, 41 insertions, 38 deletions
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 2a2ab94e..551ac1b3 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 9573515d..2ec50879 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 477e6a73..459a701f 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)