summaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java2
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java115
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java3
-rw-r--r--vid-app-common/src/test/resources/csars/service-MnsVnn1bDmzSvc-csar.csarbin0 -> 9042 bytes
-rw-r--r--vid-app-common/src/test/resources/csars/service-MnsVnn1bExnSvc-csar.csarbin0 -> 8913 bytes
-rw-r--r--vid-app-common/src/test/resources/vlan-tagging.json4
-rw-r--r--vid-app-common/src/test/resources/vrf-csar.json84
7 files changed, 170 insertions, 38 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
index 121c7e4c1..1c8a465cb 100644
--- a/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
+++ b/vid-app-common/src/main/java/org/onap/vid/model/ServiceModel.java
@@ -333,7 +333,7 @@ public class ServiceModel {
// now check to see if there is a vf module with customization name that starts with normalizedVnfCustomizationName
- if (!MapUtils.isEmpty(getVolumeGroups())) {
+ if (!MapUtils.isEmpty(getVfModules())) {
for (Entry<String, VfModule> vfModuleComponent : getVfModules().entrySet()) {
vfModuleCustomizationName = vfModuleComponent.getValue().getModelCustomizationName();
diff --git a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
index 92d78d43e..e25834bd6 100644
--- a/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
+++ b/vid-app-common/src/test/java/org/onap/vid/asdc/parser/ToscaParserImpl2Test.java
@@ -26,11 +26,13 @@ import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.onap.vid.asdc.parser.ToscaParserImpl2.Constants.ECOMP_GENERATED_NAMING_PROPERTY;
import static org.onap.vid.testUtils.TestUtils.assertJsonStringEqualsIgnoreNulls;
+import static org.onap.vid.testUtils.TestUtils.testWithSystemProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -43,6 +45,7 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -57,6 +60,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.onap.sdc.toscaparser.api.Group;
import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.Property;
@@ -178,15 +182,16 @@ public class ToscaParserImpl2Test {
}
}
-// @Test
-// public void verifyFabricConfiguration() throws Exception {
-// ToscaParserMockHelper toscaParserMockHelper = Arrays.stream(getExpectedServiceModel()).filter(x -> x.getUuid().equals(Constants.fabricConfigurationUuid)).findFirst().get();
-// ServiceModel actualServiceModel = toscaParserImpl2.makeServiceModel(getCsarPath(Constants.fabricConfigurationUuid), getServiceByUuid(Constants.fabricConfigurationUuid));
-// final Map<String, Node> fabricConfigurations = actualServiceModel.getFabricConfigurations();
-// String fabricConfigName = "Fabric Configuration 0";
-// Map<String, Node> expectedFC = toscaParserMockHelper.getNewServiceModel().getFabricConfigurations();
-// verifyBaseNodeMetadata(expectedFC.get(fabricConfigName), fabricConfigurations.get(fabricConfigName));
-// }
+ @Test
+ public void verifyFabricConfiguration() throws Exception {
+ ToscaParserMockHelper toscaParserMockHelper = Arrays.stream(getExpectedServiceModel()).filter(x -> x.getUuid().equals(Constants.fabricConfigurationUuid)).findFirst().get();
+ ServiceModel actualServiceModel = toscaParserImpl2.makeServiceModel(getCsarPath(Constants.fabricConfigurationUuid), getServiceByUuid(Constants.fabricConfigurationUuid));
+ final Map<String, Node> fabricConfigurations = actualServiceModel.getFabricConfigurations();
+ String fabricConfigName = "Fabric Configuration 0";
+ Map<String, Node> expectedFC = toscaParserMockHelper.getServiceModel().getFabricConfigurations();
+ verifyBaseNodeMetadata(expectedFC.get(fabricConfigName), fabricConfigurations.get(fabricConfigName));
+ }
+
private void verifyCollectionResource(CR expectedCR, CR actualCR) {
verifyBaseNodeMetadata(expectedCR, actualCR);
@@ -273,6 +278,25 @@ public class ToscaParserImpl2Test {
assertJsonStringEqualsIgnoreNulls("{ vfModules: { 201712488_pasqualevpe10..201712488PasqualeVpe1..PASQUALE_vRE_BV..module-1: { inputs: { availability_zone_0: { } } } } }", om.writeValueAsString(serviceModel));
}
+ @DataProvider
+ public static Object[] oldCsarUuid() {
+ return new Object[][]{{ "2a53419b-3f85-4ad5-a9c9-d79905500a27", "MNS VNN1B EXN VF 1" }
+ , {"e32a5014-357f-4be4-b3f9-fecb0010811e", "MNS VNN1B DMZ VF 1"}};
+ }
+
+ @Test(dataProvider = "oldCsarUuid")
+ public void csarWithVnfWithVfModuleInModel(String oldCsarUuid, String vnfName) throws Exception {
+ testWithSystemProperty("asdc.model.namespace", "com.att.d2.", ()-> {
+ ToscaParser tosca = new ToscaParserImpl();
+ final UUID uuid = UUID.fromString(oldCsarUuid);
+ final ServiceModel serviceModel = tosca.makeServiceModel(oldCsarUuid, asdcClient.getServiceToscaModel(uuid), asdcClient.getService(uuid));
+ assertThat(serviceModel.getVnfs(), aMapWithSize(1));
+ assertThat(serviceModel.getVfModules(), aMapWithSize(2));
+ assertThat(serviceModel.getVolumeGroups(), aMapWithSize(0));
+ assertThat(serviceModel.getVnfs().get(vnfName).getVfModules(), aMapWithSize(2));
+ });
+ }
+
@Test
public void modelWithNfNamingWithToValues_ecompGeneratedNamingIsExtracted() throws Exception {
final ToscaParserMockHelper mockHelper = new ToscaParserMockHelper("90fe6842-aa76-4b68-8329-5c86ff564407", "empty.json");
@@ -309,6 +333,19 @@ public class ToscaParserImpl2Test {
JsonAssert.assertJsonEquals(actualVnfGroups, expectedVnfGroups);
}
+ @Test
+ public void assertEqualsBetweenVrfs() throws Exception {
+ ToscaParserMockHelper mockHelper = new ToscaParserMockHelper(Constants.vrfUuid, Constants.vrfFilePath);
+ ServiceModel serviceModel = toscaParserImpl2.makeServiceModel(getCsarPath(mockHelper.getUuid()), getServiceByUuid(mockHelper.getUuid()));
+ Map<String, Node> actualVrfs = serviceModel.getVrfs();
+ Map<String, Node> expectedVrfs = mockHelper.getServiceModel().getVrfs();
+ JsonAssert.assertJsonEquals(expectedVrfs, actualVrfs);
+ //assert that vrf isn't returned also as configuration (because it's type is configuration)
+ Map<String, PortMirroringConfig> actualConfigurations = serviceModel.getConfigurations();
+ Map<String, PortMirroringConfig> expectedConfigurations = mockHelper.getServiceModel().getConfigurations();
+ JsonAssert.assertJsonEquals(expectedConfigurations, actualConfigurations );
+ }
+
private void verifyBaseNodeMetadata(Node expectedNode, Node actualNode) {
Assert.assertEquals(expectedNode.getName(), actualNode.getName());
Assert.assertEquals(expectedNode.getCustomizationUuid(), actualNode.getCustomizationUuid());
@@ -337,9 +374,9 @@ public class ToscaParserImpl2Test {
new ToscaParserMockHelper(Constants.vfWithAnnotationUuid, Constants.vfWithAnnotationFilePath),
new ToscaParserMockHelper(Constants.vfWithVfcGroup, Constants.vfWithVfcGroupFilePath),
new ToscaParserMockHelper(Constants.configurationUuid, Constants.configurationFilePath),
-// new ToscaParserMockHelper(Constants.fabricConfigurationUuid, Constants.fabricConfigurationFilePath),
-// new ToscaParserMockHelper(Constants.vlanTaggingUuid, Constants.vlanTaggingFilePath),
-// new ToscaParserMockHelper(Constants.vnfGroupingUuid, Constants.vnfGroupingFilePath)
+ new ToscaParserMockHelper(Constants.fabricConfigurationUuid, Constants.fabricConfigurationFilePath),
+ new ToscaParserMockHelper(Constants.vlanTaggingUuid, Constants.vlanTaggingFilePath),
+ new ToscaParserMockHelper(Constants.vnfGroupingUuid, Constants.vnfGroupingFilePath),
new ToscaParserMockHelper("3f6bd9e9-0942-49d3-84e8-6cdccd6de339", "./vLoadBalancerMS-with-policy.TOSCA.json"),
};
@@ -371,12 +408,14 @@ public class ToscaParserImpl2Test {
static final String vfWithVfcGroupFilePath = "vf-with-vfcInstanceGroups.json";
public static final String configurationByPolicyFalseUuid = "ee6d61be-4841-4f98-8f23-5de9da845544";
public static final String configurationByPolicyFalseFilePath = "policy-configuration-by-policy-false.JSON";
- //public static final String fabricConfigurationUuid = "12344bb4-a416-4b4e-997e-0059973630b9";
- //public static final String fabricConfigurationFilePath = "fabric-configuration.json";
- //public static final String vlanTaggingUuid = "1837481c-fa7d-4362-8ce1-d05fafc87bd1";
- //public static final String vlanTaggingFilePath = "vlan-tagging.json";
- //public static final String vnfGroupingUuid = "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc";
- //public static final String vnfGroupingFilePath = "vnf-grouping-csar.json";
+ public static final String fabricConfigurationUuid = "12344bb4-a416-4b4e-997e-0059973630b9";
+ public static final String fabricConfigurationFilePath = "fabric-configuration.json";
+ public static final String vlanTaggingUuid = "1837481c-fa7d-4362-8ce1-d05fafc87bd1";
+ public static final String vlanTaggingFilePath = "vlan-tagging.json";
+ public static final String vnfGroupingUuid = "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc";
+ public static final String vnfGroupingFilePath = "vnf-grouping-csar.json";
+ public static final String vrfUuid = "f028b2e2-7080-4b13-91b2-94944d4c42d8";
+ public static final String vrfFilePath = "vrf-csar.json";
public static final String QUANTITY = "quantity";
@@ -409,22 +448,30 @@ public class ToscaParserImpl2Test {
));
}
-// @DataProvider
-// public Object[][] expectedPoliciesTargets() {
-// return new Object[][] {
-// {Constants.vnfGroupingUuid, newArrayList("groupingservicefortest..ResourceInstanceGroup..0", "groupingservicefortest..ResourceInstanceGroup..1")},
-// {Constants.vfUuid, newArrayList()},
-// {Constants.vlanTaggingUuid, newArrayList()}
-// };
-// }
-//
-// @Test(dataProvider = "expectedPoliciesTargets")
-// public void testExtractNamingPoliciesTargets(String uuid, ArrayList<String> expectedTargets) throws AsdcCatalogException, SdcToscaParserException {
-// ISdcCsarHelper sdcCsarHelper = toscaParserImpl2.getSdcCsarHelper(getCsarPath(uuid));
-// List<String> policiesTargets = toscaParserImpl2.extractNamingPoliciesTargets(sdcCsarHelper);
-//
-// assertEquals(expectedTargets, policiesTargets);
-// }
+ @DataProvider
+ public Object[][] expectedPoliciesTargets() {
+ return new Object[][] {
+ {Constants.vnfGroupingUuid, newArrayList("groupingservicefortest..ResourceInstanceGroup..0", "groupingservicefortest..ResourceInstanceGroup..1")},
+ {Constants.vfUuid, newArrayList()},
+ {Constants.vlanTaggingUuid, newArrayList()}
+ };
+ }
+
+ @Test(dataProvider = "expectedPoliciesTargets")
+ public void testExtractNamingPoliciesTargets(String uuid, ArrayList<String> expectedTargets) throws AsdcCatalogException, SdcToscaParserException {
+ ISdcCsarHelper sdcCsarHelper = toscaParserImpl2.getSdcCsarHelper(getCsarPath(uuid));
+ List<String> policiesTargets = toscaParserImpl2.extractNamingPoliciesTargets(sdcCsarHelper);
+
+ assertEquals(expectedTargets, policiesTargets);
+ }
+
+ @Test
+ public void testScalingPolicyOfVnfGroup() throws AsdcCatalogException, SdcToscaParserException {
+ String vnfGroupingUuid = "4117a0b6-e234-467d-b5b9-fe2f68c8b0fc";
+ Map<String, ResourceGroup> actualVnfGroups = toscaParserImpl2.makeServiceModel(getCsarPath(vnfGroupingUuid), getServiceByUuid(vnfGroupingUuid)).getVnfGroups();
+ assertFalse(actualVnfGroups.get("groupingservicefortest..ResourceInstanceGroup..0").getProperties().containsKey(Constants.QUANTITY));
+ assertEquals(3, actualVnfGroups.get("groupingservicefortest..ResourceInstanceGroup..1").getProperties().get(Constants.QUANTITY));
+ }
@DataProvider
public Object[][] expectedEcompGeneratedNaming() {
diff --git a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
index 5fc583274..58ee2d38d 100644
--- a/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
+++ b/vid-app-common/src/test/java/org/onap/vid/testUtils/TestUtils.java
@@ -68,6 +68,7 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.onap.portalsdk.core.util.SystemProperties;
+import org.onap.vid.asdc.AsdcCatalogException;
import org.onap.vid.asdc.beans.Service;
import org.onap.vid.mso.model.CloudConfiguration;
import org.springframework.core.env.Environment;
@@ -279,7 +280,7 @@ public class TestUtils {
public interface Test {
- void apply();
+ void apply() throws AsdcCatalogException;
}
public static void testWithSystemProperty(String key, String value, Test test) throws Exception {
diff --git a/vid-app-common/src/test/resources/csars/service-MnsVnn1bDmzSvc-csar.csar b/vid-app-common/src/test/resources/csars/service-MnsVnn1bDmzSvc-csar.csar
new file mode 100644
index 000000000..b7b011a07
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-MnsVnn1bDmzSvc-csar.csar
Binary files differ
diff --git a/vid-app-common/src/test/resources/csars/service-MnsVnn1bExnSvc-csar.csar b/vid-app-common/src/test/resources/csars/service-MnsVnn1bExnSvc-csar.csar
new file mode 100644
index 000000000..c680bc47f
--- /dev/null
+++ b/vid-app-common/src/test/resources/csars/service-MnsVnn1bExnSvc-csar.csar
Binary files differ
diff --git a/vid-app-common/src/test/resources/vlan-tagging.json b/vid-app-common/src/test/resources/vlan-tagging.json
index 454327aa3..6789e646b 100644
--- a/vid-app-common/src/test/resources/vlan-tagging.json
+++ b/vid-app-common/src/test/resources/vlan-tagging.json
@@ -138,7 +138,7 @@
}
},
"networks": {},
- "collectionResource": {},
+ "collectionResources": {},
"configurations": {},
"fabricConfigurations": {},
"serviceProxies": {},
@@ -219,4 +219,4 @@
"volumeGroups": {},
"pnfs": {},
"vnfGroups": {}
-} \ No newline at end of file
+}
diff --git a/vid-app-common/src/test/resources/vrf-csar.json b/vid-app-common/src/test/resources/vrf-csar.json
new file mode 100644
index 000000000..b1d4e4508
--- /dev/null
+++ b/vid-app-common/src/test/resources/vrf-csar.json
@@ -0,0 +1,84 @@
+{
+ "service":{
+ "uuid":"f028b2e2-7080-4b13-91b2-94944d4c42d8",
+ "invariantUuid":"dfc2c44c-2429-44ca-ae26-1e6dc1f207fb",
+ "name":"infraVPN",
+ "version":"1.0",
+ "toscaModelURL":null,
+ "category":"Network Service",
+ "serviceType":"INFRASTRUCTURE-VPN",
+ "serviceRole":"BONDING",
+ "description":"ddd",
+ "serviceEcompNaming":"true",
+ "instantiationType":"A-La-Carte",
+ "inputs":{
+
+ }
+ },
+ "vnfs":{
+
+ },
+ "networks":{
+
+ },
+ "collectionResources": {
+ },
+ "configurations":{
+
+ },
+ "fabricConfigurations":{
+
+ },
+ "serviceProxies":{
+ "misvpn_service_proxy 0":{
+ "uuid":"35186eb0-e6b6-4fa5-86bb-1501b342a7b1",
+ "invariantUuid":"73f89e21-b96c-473f-8884-8b93bcbd2f76",
+ "description":"A Proxy for Service MISVPN_SERVICE",
+ "name":"MISVPN_SERVICE Service Proxy",
+ "version":"3.0",
+ "customizationUuid":"4c2fb7e0-a0a5-4b32-b6ed-6a974e55d923",
+ "inputs":{
+
+ },
+ "commands":{
+
+ },
+ "properties":{
+ "ecomp_generated_naming":"false"
+ },
+ "type":"Service Proxy",
+ "sourceModelUuid":"d5cc7d15-c842-450e-95ae-2a69e66dd23b",
+ "sourceModelInvariant":"c126ec86-59fe-48c0-9532-e39a9b3e5272",
+ "sourceModelName":"MISVPN_SERVICE"
+ }
+ },
+ "vfModules":{
+ },
+ "volumeGroups":{
+
+ },
+ "pnfs":{
+
+ },
+ "vnfGroups":{
+
+ },
+ "vrfs":{
+ "VRF Entry Configuration 0": {
+ "uuid": "9cac02be-2489-4374-888d-2863b4511a59",
+ "invariantUuid": "b67a289b-1688-496d-86e8-1583c828be0a",
+ "description": "VRF Entry configuration object",
+ "name": "VRF Entry Configuration",
+ "version": "30.0",
+ "customizationUuid": "dd024d73-9bd1-425d-9db5-476338d53433",
+ "inputs": {},
+ "commands": {},
+ "properties": {
+ "ecomp_generated_naming": "false",
+ "role":"INFRASTRUCTURE-CLOUD-VPN",
+ "type":"VRF-ENTRY"
+ },
+ "type": "Configuration"
+ }
+ }
+} \ No newline at end of file