summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorXue Gao <xg353y@intl.att.com>2020-01-30 12:50:39 +0000
committerGerrit Code Review <gerrit@onap.org>2020-01-30 12:50:39 +0000
commit32d2e29dc6d751c2053a130238526144ab46912c (patch)
tree35b93ca7fb4a382ab7f1bad917977fd845923bd6 /src/test/java/org
parenta84ea55e9291f5c3af9ac3a3ae6ca31d860f1566 (diff)
parent504df70f2b210488f77274915ce8652d56978e18 (diff)
Merge "Add a unit test"
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java39
1 files changed, 26 insertions, 13 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 dcaf2b952..e48bfc44a 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,8 @@
package org.onap.clamp.clds.sdc.controller.installer;
+import static org.assertj.core.api.Assertions.assertThat;
+
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
@@ -57,7 +59,7 @@ public class BlueprintParserTest {
private static String microServiceTheWholeBlueprintValid;
private static String microServiceBlueprintOldStyleTCA;
private static String microServiceBlueprintOldStyleHolmes;
-
+ private static String newMicroServiceBlueprint;
private static JsonObject jsonObjectBlueprintValid;
private static JsonObject jsonObjectBlueprintWithoutName;
private static JsonObject jsonObjectBlueprintWithoutProperties;
@@ -66,22 +68,22 @@ public class BlueprintParserTest {
/**
* Method to load Blueprints before all test.
*
- * @throws IOException
- * In case of issues when opening the files
+ * @throws IOException In case of issues when opening the files
*/
@BeforeClass
public static void loadBlueprints() throws IOException {
microServiceTheWholeBlueprintValid = ResourceFileUtil
- .getResourceAsString("clds/blueprint-with-microservice-chain.yaml");
+ .getResourceAsString("clds/blueprint-with-microservice-chain.yaml");
microServiceBlueprintOldStyleTCA = ResourceFileUtil.getResourceAsString("clds/tca-old-style-ms.yaml");
+ newMicroServiceBlueprint = ResourceFileUtil.getResourceAsString("clds/new-microservice.yaml");
microServiceBlueprintOldStyleHolmes = ResourceFileUtil.getResourceAsString("clds/holmes-old-style-ms.yaml");
String microServiceBlueprintValid = ResourceFileUtil
- .getResourceAsString("clds/single-microservice-fragment-valid.yaml");
+ .getResourceAsString("clds/single-microservice-fragment-valid.yaml");
String microServiceBlueprintWithoutName = ResourceFileUtil
- .getResourceAsString("clds/single-microservice-fragment-without-name.yaml");
+ .getResourceAsString("clds/single-microservice-fragment-without-name.yaml");
String microServiceBlueprintWithoutProperties = ResourceFileUtil
- .getResourceAsString("clds/single-microservice-fragment-without-properties.yaml");
+ .getResourceAsString("clds/single-microservice-fragment-without-properties.yaml");
jsonObjectBlueprintValid = yamlToJson(microServiceBlueprintValid);
jsonObjectBlueprintWithoutName = yamlToJson(microServiceBlueprintWithoutName);
@@ -97,7 +99,7 @@ public class BlueprintParserTest {
public void getNameShouldReturnDefinedName() {
final JsonObject jsonObject = jsonObjectBlueprintValid;
String expectedName = jsonObject.get(jsonObject.keySet().iterator().next()).getAsJsonObject().get("properties")
- .getAsJsonObject().get("name").getAsString();
+ .getAsJsonObject().get("name").getAsString();
Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
String actualName = new BlueprintParser().getName(entry);
@@ -174,8 +176,8 @@ public class BlueprintParserTest {
@Test
public void fallBackToOneMicroServiceTcaTest() {
- MicroService tcaMs = new MicroService(BlueprintParser.TCA,
- "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "");
+ MicroService tcaMs = new MicroService(BlueprintParser.TCA, "onap.policies.monitoring.cdap.tca.hi.lo.app", "",
+ "");
List<MicroService> expected = Collections.singletonList(tcaMs);
List<MicroService> actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA);
@@ -184,16 +186,27 @@ public class BlueprintParserTest {
@Test
public void fallBackToOneMicroServiceHolmesTest() {
- MicroService holmesMs = new MicroService(BlueprintParser.HOLMES,
- "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "");
+ MicroService holmesMs = new MicroService(BlueprintParser.HOLMES, "onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "", "");
List<MicroService> expected = Collections.singletonList(holmesMs);
List<MicroService> actual = new BlueprintParser()
- .fallbackToOneMicroService(microServiceBlueprintOldStyleHolmes);
+ .fallbackToOneMicroService(microServiceBlueprintOldStyleHolmes);
Assert.assertEquals(expected, actual);
}
+ @Test
+ public void newMicroServiceTest() {
+ List<MicroService> microServicesChain = new ChainGenerator()
+ .getChainOfMicroServices(new BlueprintParser().getMicroServices(newMicroServiceBlueprint));
+ if (microServicesChain.isEmpty()) {
+ microServicesChain = new BlueprintParser().fallbackToOneMicroService(newMicroServiceBlueprint);
+ }
+ assertThat(microServicesChain.size()).isEqualTo(1);
+ assertThat(microServicesChain.get(0).getName()).isEqualTo("pmsh");
+ }
+
private static JsonObject yamlToJson(String yamlString) {
Yaml yaml = new Yaml();
Map<String, Object> map = yaml.load(yamlString);