aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authorsebdet <sebastien.determe@intl.att.com>2020-02-03 20:27:59 +0100
committersebdet <sebastien.determe@intl.att.com>2020-02-10 17:57:30 +0100
commit5d03e8b55ff7780079085184f6d30a4d0a26a4a7 (patch)
treef15abb7d36fe215b4b800278a4a9a2c541799b1c /src/test/java
parentb398c32d092ca7ca14fa37d22fae6cbc1710e66e (diff)
Get policy in CsarInstaller
Get the policies on the PEF engine when installing the CSAR (if needed) Issue-ID: CLAMP-518 Change-Id: I2cca157821c22ef63dc748984140287667cc4663 Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java71
-rw-r--r--src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java33
-rw-r--r--src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java2
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java94
-rw-r--r--src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java39
-rw-r--r--src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java2
-rw-r--r--src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java16
-rw-r--r--src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java22
-rw-r--r--src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java17
9 files changed, 105 insertions, 191 deletions
diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java b/src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java
deleted file mode 100644
index fd20e360a..000000000
--- a/src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.it;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.clamp.clds.config.PolicyConfiguration;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * Test Config Policy read from application.properties.
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest
-public class PolicyConfigurationItCase {
-
- @Autowired
- private PolicyConfiguration policyConfiguration;
-
- @Test
- public void testPolicyConfiguration() {
- assertNotNull(policyConfiguration.getPdpUrl1());
- assertNotNull(policyConfiguration.getPdpUrl2());
- assertNotNull(policyConfiguration.getPapUrl());
- assertNotNull(policyConfiguration.getPolicyEnvironment());
- assertNotNull(policyConfiguration.getClientId());
- assertNotNull(policyConfiguration.getClientKey());
- assertNotNull(policyConfiguration.getNotificationType());
- assertNotNull(policyConfiguration.getNotificationUebServers());
- assertEquals(8, policyConfiguration.getProperties().size());
- assertTrue(((String) policyConfiguration.getProperties().get(PolicyConfiguration.PDP_URL1))
- .contains("/pdp/ , testpdp, alpha123"));
- assertTrue(((String) policyConfiguration.getProperties().get(PolicyConfiguration.PDP_URL2))
- .contains("/pdp/ , testpdp, alpha123"));
- assertTrue(((String) policyConfiguration.getProperties().get(PolicyConfiguration.PAP_URL))
- .contains("/pap/ , testpap, alpha123"));
- assertEquals("websocket", policyConfiguration.getProperties().get(PolicyConfiguration.NOTIFICATION_TYPE));
- assertEquals("localhost",
- policyConfiguration.getProperties().get(PolicyConfiguration.NOTIFICATION_UEB_SERVERS));
- assertEquals("python", policyConfiguration.getProperties().get(PolicyConfiguration.CLIENT_ID));
- assertEquals("dGVzdA==", policyConfiguration.getProperties().get(PolicyConfiguration.CLIENT_KEY));
- assertEquals("DEVL", policyConfiguration.getProperties().get(PolicyConfiguration.ENVIRONMENT));
- }
-}
diff --git a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
index d34042038..c25415ecc 100644
--- a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
@@ -28,10 +28,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import com.google.gson.JsonElement;
+
import java.io.IOException;
-import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -55,19 +54,15 @@ public class CldsReferencePropertiesItCase {
*/
@Test
public void testGetStringValue() {
- assertEquals("DCAE", refProp.getStringValue("policy.onap.name"));
- assertEquals("Config_MS_", refProp.getStringValue("policy.ms.policyNamePrefix", ""));
- assertEquals("Config_MS_", refProp.getStringValue("policy.ms.policyNamePrefix", "testos"));
- assertEquals("Config_MS_", refProp.getStringValue("policy.ms", "policyNamePrefix"));
- assertNull(refProp.getStringValue("does.not.exist"));
+ assertEquals("healthcheck", refProp.getStringValue("policy.api.userName"));
}
@Test
public void shouldReturnJsonFromTemplate() throws IOException {
- //when
+ // when
JsonElement root = refProp.getJsonTemplate("ui.location.default");
- //then
+ // then
assertNotNull(root);
assertTrue(root.isJsonObject());
assertEquals("Data Center 1", root.getAsJsonObject().get("DC1").getAsString());
@@ -75,10 +70,10 @@ public class CldsReferencePropertiesItCase {
@Test
public void shouldReturnJsonFromTemplate_2() throws IOException {
- //when
+ // when
JsonElement root = refProp.getJsonTemplate("ui.location", "default");
- //then
+ // then
assertNotNull(root);
assertTrue(root.isJsonObject());
assertEquals("Data Center 1", root.getAsJsonObject().get("DC1").getAsString());
@@ -86,18 +81,17 @@ public class CldsReferencePropertiesItCase {
@Test
public void shouldReturnNullIfPropertyNotFound() throws IOException {
- //when
+ // when
JsonElement root = refProp.getJsonTemplate("ui.location", "");
- //then
+ // then
assertNull(root);
}
/**
* Test getting prop value as a JSON Node / template.
*
- * @throws IOException
- * when JSON parsing fails
+ * @throws IOException when JSON parsing fails
*/
@Test
public void testGetFileContent() throws IOException {
@@ -109,13 +103,4 @@ public class CldsReferencePropertiesItCase {
content = refProp.getFileContent("ui.location", "default");
assertEquals(location, content);
}
-
- @Test
- public void testGetStringList() {
- List<String> profileList = refProp.getStringList("policy.pdpUrl1", ",");
- assertEquals(3, profileList.size());
- assertTrue(profileList.get(0).trim().startsWith("http://localhost:"));
- assertEquals("testpdp", profileList.get(1).trim());
- assertEquals("alpha123", profileList.get(2).trim());
- }
}
diff --git a/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
index 7c520a252..7ef734533 100644
--- a/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
+++ b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
@@ -45,7 +45,7 @@ import org.springframework.test.util.ReflectionTestUtils;
*/
@RunWith(SpringRunner.class)
@SpringBootTest
-@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller-new")
+@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller")
public class SdcControllersConfigurationItCase {
@Autowired
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 e48bfc44a..9efb68983 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
@@ -44,6 +44,7 @@ import org.json.JSONObject;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException;
import org.onap.clamp.clds.util.ResourceFileUtil;
import org.yaml.snakeyaml.Yaml;
@@ -53,17 +54,16 @@ public class BlueprintParserTest {
private static final String SECOND_APPP = "second_app";
private static final String THIRD_APPP = "third_app";
private static final String MODEL_TYPE1 = "type1";
- private static final String MODEL_TYPE2 = "type2";
- private static final String MODEL_TYPE3 = "type3";
+ private static final String MODEL_TYPE_TCA = "onap.policies.monitoring.cdap.tca.hi.lo.app";
+ private static final String VERSION = "1.0.0";
private static String microServiceTheWholeBlueprintValid;
- private static String microServiceBlueprintOldStyleTCA;
- private static String microServiceBlueprintOldStyleHolmes;
private static String newMicroServiceBlueprint;
- private static JsonObject jsonObjectBlueprintValid;
+ private static JsonObject jsonObjectBlueprintInvalid;
private static JsonObject jsonObjectBlueprintWithoutName;
private static JsonObject jsonObjectBlueprintWithoutProperties;
private static JsonObject jsonObjectBlueprintWithoutRelationships;
+ private static JsonObject jsonObjectBlueprintValidWithVersion;
/**
* Method to load Blueprints before all test.
@@ -74,20 +74,21 @@ 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");
+
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");
+ String microServiceBlueprintInvalid = ResourceFileUtil
+ .getResourceAsString("clds/single-microservice-fragment-invalid.yaml");
+ jsonObjectBlueprintInvalid = yamlToJson(microServiceBlueprintInvalid);
String microServiceBlueprintWithoutName = ResourceFileUtil
.getResourceAsString("clds/single-microservice-fragment-without-name.yaml");
+ jsonObjectBlueprintWithoutName = yamlToJson(microServiceBlueprintWithoutName);
String microServiceBlueprintWithoutProperties = ResourceFileUtil
.getResourceAsString("clds/single-microservice-fragment-without-properties.yaml");
-
- jsonObjectBlueprintValid = yamlToJson(microServiceBlueprintValid);
- jsonObjectBlueprintWithoutName = yamlToJson(microServiceBlueprintWithoutName);
jsonObjectBlueprintWithoutProperties = yamlToJson(microServiceBlueprintWithoutProperties);
+ String microServiceBlueprintValidWithVersion = ResourceFileUtil
+ .getResourceAsString("clds/single-microservice-fragment-valid-with-version.yaml");
+ jsonObjectBlueprintValidWithVersion = yamlToJson(microServiceBlueprintValidWithVersion);
String microServiceBlueprintWithoutRelationships = ResourceFileUtil
.getResourceAsString("clds/single-microservice-fragment-without-relationships.yaml");
@@ -97,11 +98,11 @@ public class BlueprintParserTest {
@Test
public void getNameShouldReturnDefinedName() {
- final JsonObject jsonObject = jsonObjectBlueprintValid;
+ final JsonObject jsonObject = jsonObjectBlueprintInvalid;
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);
+ String actualName = BlueprintParser.getName(entry);
Assert.assertEquals(expectedName, actualName);
}
@@ -112,7 +113,7 @@ public class BlueprintParserTest {
String expectedName = jsonObject.keySet().iterator().next();
Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
- String actualName = new BlueprintParser().getName(entry);
+ String actualName = BlueprintParser.getName(entry);
Assert.assertEquals(expectedName, actualName);
}
@@ -123,18 +124,18 @@ public class BlueprintParserTest {
String expectedName = jsonObject.keySet().iterator().next();
Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
- String actualName = new BlueprintParser().getName(entry);
+ String actualName = BlueprintParser.getName(entry);
Assert.assertEquals(expectedName, actualName);
}
@Test
public void getInputShouldReturnInputWhenPresent() {
- final JsonObject jsonObject = jsonObjectBlueprintValid;
+ final JsonObject jsonObject = jsonObjectBlueprintInvalid;
String expected = FIRST_APPP;
Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
- String actual = new BlueprintParser().getInput(entry);
+ String actual = BlueprintParser.getInput(entry);
Assert.assertEquals(expected, actual);
}
@@ -145,63 +146,56 @@ public class BlueprintParserTest {
String expected = "";
Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
- String actual = new BlueprintParser().getInput(entry);
+ String actual = BlueprintParser.getInput(entry);
Assert.assertEquals(expected, actual);
}
- @Test
- public void getNodeRepresentationFromCompleteYaml() {
- final JsonObject jsonObject = jsonObjectBlueprintValid;
-
- MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, "");
- Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
- MicroService actual = new BlueprintParser().getNodeRepresentation(entry, jsonObject, null);
-
- Assert.assertEquals(expected, actual);
+ @Test(expected = BlueprintParserException.class)
+ public void getNodeRepresentationFromIncompleteYaml() throws BlueprintParserException {
+ BlueprintParser.getNodeRepresentation(jsonObjectBlueprintInvalid.entrySet().iterator().next(),
+ jsonObjectBlueprintInvalid, null);
}
@Test
- public void getMicroServicesFromBlueprintTest() {
- 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, "");
+ public void getNodeRepresentationFromCompleteYamlWithModelVersion() throws BlueprintParserException {
+ final JsonObject jsonObject = jsonObjectBlueprintValidWithVersion;
- Set<MicroService> expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp));
- Set<MicroService> actual = new BlueprintParser().getMicroServices(microServiceTheWholeBlueprintValid);
+ BlueprintMicroService expected = new BlueprintMicroService(SECOND_APPP, MODEL_TYPE1, "", "10.0.0");
+ Entry<String, JsonElement> entry = jsonObject.entrySet().iterator().next();
+ BlueprintMicroService actual = BlueprintParser.getNodeRepresentation(entry, jsonObject, null);
Assert.assertEquals(expected, actual);
}
@Test
+ public void getMicroServicesFromBlueprintTest() throws BlueprintParserException {
+ BlueprintMicroService thirdApp = new BlueprintMicroService(THIRD_APPP, MODEL_TYPE_TCA, SECOND_APPP, VERSION);
+ BlueprintMicroService firstApp = new BlueprintMicroService(FIRST_APPP, MODEL_TYPE_TCA, "", VERSION);
+ BlueprintMicroService secondApp = new BlueprintMicroService(SECOND_APPP, MODEL_TYPE_TCA, FIRST_APPP, VERSION);
- public void fallBackToOneMicroServiceTcaTest() {
- 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);
+ Set<BlueprintMicroService> expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp));
+ Set<BlueprintMicroService> actual = BlueprintParser.getMicroServices(microServiceTheWholeBlueprintValid);
Assert.assertEquals(expected, actual);
}
@Test
- public void fallBackToOneMicroServiceHolmesTest() {
- 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);
+ public void fallBackToOneMicroServiceTcaTest() {
+ BlueprintMicroService tcaMs = new BlueprintMicroService(BlueprintParser.TCA,
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "", VERSION);
+ List<BlueprintMicroService> expected = Collections.singletonList(tcaMs);
+ List<BlueprintMicroService> actual = BlueprintParser.fallbackToOneMicroService();
Assert.assertEquals(expected, actual);
}
@Test
- public void newMicroServiceTest() {
- List<MicroService> microServicesChain = new ChainGenerator()
- .getChainOfMicroServices(new BlueprintParser().getMicroServices(newMicroServiceBlueprint));
+ public void newMicroServiceTest() throws BlueprintParserException {
+ List<BlueprintMicroService> microServicesChain = new ChainGenerator()
+ .getChainOfMicroServices(BlueprintParser.getMicroServices(newMicroServiceBlueprint));
if (microServicesChain.isEmpty()) {
- microServicesChain = new BlueprintParser().fallbackToOneMicroService(newMicroServiceBlueprint);
+ microServicesChain = BlueprintParser.fallbackToOneMicroService();
}
assertThat(microServicesChain.size()).isEqualTo(1);
assertThat(microServicesChain.get(0).getName()).isEqualTo("pmsh");
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 4b4563cd4..83b3dda01 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
@@ -36,42 +36,43 @@ public class ChainGeneratorTest {
private static final String SECOND_APPP = "second_app";
private static final String THIRD_APPP = "third_app";
private static final String FOURTH_APPP = "fourth_app";
+ private static final String DEFAULT_VERSION = "1.0.0";
@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, "");
+ BlueprintMicroService ms1 = new BlueprintMicroService(FIRST_APPP, "", "", DEFAULT_VERSION);
+ BlueprintMicroService ms2 = new BlueprintMicroService(SECOND_APPP, "", FIRST_APPP, DEFAULT_VERSION);
+ BlueprintMicroService ms3 = new BlueprintMicroService(THIRD_APPP, "", SECOND_APPP, DEFAULT_VERSION);
+ BlueprintMicroService ms4 = new BlueprintMicroService(FOURTH_APPP, "", THIRD_APPP, DEFAULT_VERSION);
- List<MicroService> expectedList = Arrays.asList(ms1, ms2, ms3, ms4);
- Set<MicroService> inputSet = new HashSet<>(expectedList);
+ List<BlueprintMicroService> expectedList = Arrays.asList(ms1, ms2, ms3, ms4);
+ Set<BlueprintMicroService> inputSet = new HashSet<>(expectedList);
- List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
+ List<BlueprintMicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
Assert.assertEquals(expectedList, actualList);
}
@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, "");
+ BlueprintMicroService ms1 = new BlueprintMicroService(FIRST_APPP, "", "", DEFAULT_VERSION);
+ BlueprintMicroService ms2 = new BlueprintMicroService(SECOND_APPP, "", "", DEFAULT_VERSION);
+ BlueprintMicroService ms3 = new BlueprintMicroService(THIRD_APPP, "", SECOND_APPP, DEFAULT_VERSION);
+ BlueprintMicroService ms4 = new BlueprintMicroService(FOURTH_APPP, "", FIRST_APPP, DEFAULT_VERSION);
- Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4));
- List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
+ Set<BlueprintMicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4));
+ List<BlueprintMicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
Assert.assertTrue(actualList.isEmpty());
}
@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, "");
+ BlueprintMicroService ms1 = new BlueprintMicroService(FIRST_APPP, "", "", DEFAULT_VERSION);
+ BlueprintMicroService ms2 = new BlueprintMicroService(SECOND_APPP, "", FIRST_APPP, DEFAULT_VERSION);
+ BlueprintMicroService ms3 = new BlueprintMicroService(THIRD_APPP, "", FIRST_APPP, DEFAULT_VERSION);
+ BlueprintMicroService ms4 = new BlueprintMicroService(FOURTH_APPP, "", FIRST_APPP, DEFAULT_VERSION);
- Set<MicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4));
- List<MicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
+ Set<BlueprintMicroService> inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4));
+ List<BlueprintMicroService> actualList = new ChainGenerator().getChainOfMicroServices(inputSet);
Assert.assertTrue(actualList.isEmpty());
}
}
diff --git a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java
index 1453d0baa..f6054d538 100644
--- a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java
+++ b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java
@@ -45,7 +45,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
-@PowerMockIgnore({ "javax.crypto.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*" })
+@PowerMockIgnore({ "javax.crypto.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*" })
public class CryptoUtilsTest {
private final String data = "This is a test string";
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 269ad42e1..65eb2696f 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
@@ -39,7 +39,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;
+import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService;
@RunWith(MockitoJUnitRunner.class)
public class ClampGraphBuilderTest {
@@ -50,7 +50,7 @@ public class ClampGraphBuilderTest {
private ArgumentCaptor<String> collectorCaptor;
@Captor
- private ArgumentCaptor<List<MicroService>> microServicesCaptor;
+ private ArgumentCaptor<List<BlueprintMicroService>> microServicesCaptor;
@Captor
private ArgumentCaptor<String> policyCaptor;
@@ -58,17 +58,17 @@ 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");
+ BlueprintMicroService ms1 = new BlueprintMicroService("ms1", "", "", "1.0.0");
+ BlueprintMicroService ms2 = new BlueprintMicroService("ms2", "", "", "1.0.0");
String policy = "OperationalPolicy";
- final List<MicroService> microServices = Arrays.asList(ms1, ms2);
+ final List<BlueprintMicroService> microServices = Arrays.asList(ms1, ms2);
ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter);
clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).policy(policy).build();
verify(mockPainter, times(1)).doPaint(collectorCaptor.capture(), microServicesCaptor.capture(),
- policyCaptor.capture());
+ policyCaptor.capture());
Assert.assertEquals(collector, collectorCaptor.getValue());
Assert.assertEquals(microServices, microServicesCaptor.getValue());
@@ -78,8 +78,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");
+ BlueprintMicroService ms1 = new BlueprintMicroService("ms1", "", "", "1.0.0");
+ BlueprintMicroService ms2 = new BlueprintMicroService("ms2", "", "", "1.0.0");
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 70adf3eef..636684cdb 100644
--- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
+++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java
@@ -44,6 +44,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.clamp.clds.Application;
+import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact;
@@ -73,7 +74,7 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
-@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller-new")
+@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller")
public class CsarInstallerItCase {
private static final String CSAR_ARTIFACT_NAME = "example/sdc/service_Vloadbalancerms_csar.csar";
@@ -180,7 +181,7 @@ public class CsarInstallerItCase {
@Test
@Transactional
public void testIsCsarAlreadyDeployedTca() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, InterruptedException {
+ CsarHandlerException, IOException, InterruptedException, BlueprintParserException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csarHandler = buildFakeCsarHandler(generatedName);
assertThat(csarInstaller.isCsarAlreadyDeployed(csarHandler)).isFalse();
@@ -192,7 +193,7 @@ public class CsarInstallerItCase {
@Transactional
@Commit
public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException,
- CsarHandlerException, IOException, JSONException, InterruptedException {
+ CsarHandlerException, IOException, JSONException, InterruptedException, BlueprintParserException {
String generatedName = RandomStringUtils.randomAlphanumeric(5);
CsarHandler csar = buildFakeCsarHandler(generatedName);
csarInstaller.installTheCsar(csar);
@@ -233,16 +234,9 @@ public class CsarInstallerItCase {
assertThat(policyModelsRepository.findAll().size()).isEqualByComparingTo(1);
assertThat(policyModelsRepository
- .existsById(new PolicyModelId("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0"))).isTrue();
- }
-
- @Test(expected = SdcArtifactInstallerException.class)
- @Transactional
- public void shouldThrowSdcArtifactInstallerException()
- throws SdcArtifactInstallerException, SdcToscaParserException, IOException, InterruptedException {
- String generatedName = RandomStringUtils.randomAlphanumeric(5);
- CsarHandler csarHandler = buildFakeCsarHandler(generatedName);
- Mockito.when(csarHandler.getPolicyModelYaml()).thenThrow(IOException.class);
- csarInstaller.installTheCsar(csarHandler);
+ .existsById(new PolicyModelId("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0"))).isTrue();
+ assertThat(policyModelsRepository
+ .getOne((new PolicyModelId("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0")))
+ .getPolicyModelTosca()).isNotBlank();
}
}
diff --git a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java
index f8c1d8662..ce1181d33 100644
--- a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java
+++ b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java
@@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
+import java.util.stream.Collectors;
import javax.transaction.Transactional;
@@ -52,11 +53,13 @@ public class PolicyModelServiceItCase {
@Autowired
PolicyModelsRepository policyModelsRepository;
- private static final String POLICY_MODEL_TYPE_1 = "org.onap.test";
+ private static final String POLICY_MODEL_TYPE_1 = "org.onap.testos";
private static final String POLICY_MODEL_TYPE_1_VERSION_1 = "1.0.0";
- private static final String POLICY_MODEL_TYPE_2 = "org.onap.test2";
+ private static final String POLICY_MODEL_TYPE_2 = "org.onap.testos2";
+ private static final String POLICY_MODEL_TYPE_3 = "org.onap.testos3";
private static final String POLICY_MODEL_TYPE_2_VERSION_1 = "1.0.0";
+ private static final String POLICY_MODEL_TYPE_3_VERSION_1 = "1.0.0";
private static final String POLICY_MODEL_TYPE_2_VERSION_2 = "2.0.0";
private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym,
@@ -150,9 +153,17 @@ public class PolicyModelServiceItCase {
PolicyModel policyModel2 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_2, "TEST",
"VARIANT", "user");
policyModelsService.saveOrUpdatePolicyModel(policyModel2);
+ PolicyModel policyModel3 = getPolicyModel(POLICY_MODEL_TYPE_3, "yaml", POLICY_MODEL_TYPE_3_VERSION_1, "TEST",
+ "VARIANT", "user");
+ policyModelsService.saveOrUpdatePolicyModel(policyModel3);
SortedSet<PolicyModel> sortedSet = new TreeSet<>();
policyModelsService.getAllPolicyModels().forEach(sortedSet::add);
- assertThat(sortedSet).contains(policyModel2, policyModel1);
+ List<PolicyModel> listToCheck = sortedSet.stream().filter(
+ policy -> policy.equals(policyModel3) || policy.equals(policyModel2) || policy.equals(policyModel1))
+ .collect(Collectors.toList());
+ assertThat(listToCheck.get(0)).isEqualByComparingTo(policyModel2);
+ assertThat(listToCheck.get(1)).isEqualByComparingTo(policyModel1);
+ assertThat(listToCheck.get(2)).isEqualByComparingTo(policyModel3);
}
}