diff options
Diffstat (limited to 'catalog-be/src/test')
4 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(); diff --git a/catalog-be/src/test/resources/csars/with_groups.csar b/catalog-be/src/test/resources/csars/with_groups.csar Binary files differindex dd7f5dfb69..cd701a2078 100644 --- a/catalog-be/src/test/resources/csars/with_groups.csar +++ b/catalog-be/src/test/resources/csars/with_groups.csar |