aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2022-07-05 18:43:07 +0100
committerKrupa Nagabhushan <krupa.nagabhushan@est.tech>2022-08-02 21:10:26 +0000
commit7c7680d767bce8625c9c7ad69009fb73ae849809 (patch)
treefc3cb8f1482ac8c6dfcb22feb085757ea180cfa0 /catalog-be/src/test/java
parenta9d0bcd206b7a677b82e5e9b497a8b52b38e3a43 (diff)
Service Import - Node Template Relationship Template
Issue-ID: SDC-4083 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Signed-off-by: andre.schmid <andre.schmid@est.tech> Change-Id: Ia0f3635df969c44de5aba2d672fad34f0855e4e2
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java29
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java2
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java12
3 files changed, 42 insertions, 1 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java
index edf17b7e61..6d779a192e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandlerTest.java
@@ -32,6 +32,7 @@ import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.ARTIFACTS;
import java.io.File;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -40,6 +41,7 @@ import java.util.Optional;
import java.util.stream.Collectors;
import mockit.Deencapsulation;
import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Lists;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
@@ -65,8 +67,10 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.UploadArtifactInfo;
import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadReqInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations;
+import org.openecomp.sdc.be.ui.model.OperationUi;
import org.openecomp.sdc.common.zip.ZipUtils;
import org.openecomp.sdc.common.zip.exception.ZipException;
import org.springframework.test.util.ReflectionTestUtils;
@@ -175,6 +179,31 @@ public class YamlTemplateParsingHandlerTest {
}
@Test
+ void parseRelationshipTemplateInfoFromYamlTest() {
+ when(groupTypeBusinessLogic.getLatestGroupTypeByType(eq(HEAT_GROUP_TYPE), any())).thenReturn(heatGroupType);
+ String main_template_content = new String(csar.get(MAIN_TEMPLATE_NAME));
+ CsarInfo csarInfo = new CsarInfo(user, CSAR_UUID, csar, RESOURCE_NAME,
+ MAIN_TEMPLATE_NAME, main_template_content, true);
+
+ Service service = new Service();
+ ParsedToscaYamlInfo parsedYaml = handler.parseResourceInfoFromYAML(FILE_NAME, resourceYml, new HashMap<>(),
+ csarInfo.extractTypesInfo(), NODE_NAME, service, getInterfaceTemplateYaml(csarInfo).get());
+
+ assertThat(parsedYaml.getInstances()).isNotNull();
+ final Map<String, List<OperationUi>> operations = new HashMap<>();
+ for (UploadComponentInstanceInfo instance : parsedYaml.getInstances().values()) {
+ final Map<String, List<UploadReqInfo>> requirements = instance.getRequirements();
+ if (MapUtils.isNotEmpty(requirements)) {
+ requirements.values()
+ .forEach(requirementInfoList -> requirementInfoList.stream()
+ .filter(requirement -> StringUtils.isNotEmpty(requirement.getRelationshipTemplate()))
+ .forEach(requirement -> operations.putAll(instance.getOperations())));
+ }
+ }
+ assertEquals(1, operations.size());
+ }
+
+ @Test
void parseResourceInfoFromYAMLTest() {
stubGetGroupType();
stubGetPolicyType();
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index dcc0289822..1f45f77f3f 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -1571,6 +1571,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition);
when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat);
Assertions.assertNotNull(sIBL.addRelationToRI(yamlName, service, nodesInfoValue, relations));
+ Assertions.assertNotNull(relations.get(0).getRelationships().get(0).getOperations());
}
@Test
@@ -1584,7 +1585,6 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat);
Assertions.assertNotNull(sIBL.addRelationToRI(yamlName, service, nodesInfoValue, relations));
-
}
@Test
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
index beaa695fe4..c8fd87ca3b 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBussinessLogicBaseTestSetup.java
@@ -102,6 +102,7 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
+import org.openecomp.sdc.be.ui.model.OperationUi;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
@@ -433,15 +434,26 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM
uploadReqInfo.setName("uploadReqInfo");
uploadReqInfo.setNode("zxjTestImportServiceAb");
uploadReqInfo.setCapabilityName("tosca.capabilities.Node");
+ uploadReqInfo.setRelationshipTemplate("ExtCP 0.dependency.1");
uploadReqInfoList.add(uploadReqInfo);
requirements.put("requirements", uploadReqInfoList);
uploadNodeFilterInfo.setName("mme_ipu_vdu.virtualbinding");
uploadComponentInstanceInfo.setCapabilities(getCapabilities());
uploadComponentInstanceInfo.setRequirements(requirements);
uploadComponentInstanceInfo.setName("zxjTestImportServiceAb");
+ uploadComponentInstanceInfo.setOperations(getOperations());
return uploadComponentInstanceInfo;
}
+ protected Map<String, List<OperationUi>> getOperations() {
+ String relationshipTemplate = "ExtCP 0.dependency.1";
+ OperationUi operationUi = new OperationUi();
+ operationUi.setOperationType("change_external_connectivity_start");
+ operationUi.setInterfaceType("tosca.interfaces.nfv.Vnflcm");
+ operationUi.setImplementation("impl");
+ return Map.of(relationshipTemplate, List.of(operationUi));
+ }
+
protected Map<String, List<UploadCapInfo>> getCapabilities() {
List<UploadCapInfo> uploadCapInfoList = new ArrayList<>();
UploadCapInfo uploadCapInfo = new UploadCapInfo();