From 7c7680d767bce8625c9c7ad69009fb73ae849809 Mon Sep 17 00:00:00 2001 From: KrupaNagabhushan Date: Tue, 5 Jul 2022 18:43:07 +0100 Subject: Service Import - Node Template Relationship Template Issue-ID: SDC-4083 Signed-off-by: KrupaNagabhushan Signed-off-by: andre.schmid Change-Id: Ia0f3635df969c44de5aba2d672fad34f0855e4e2 --- .../openecomp/sdc/be/model/UploadReqInfoTest.java | 33 --------------- .../jsonjanusgraph/utils/ModelConverterTest.java | 48 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 34 deletions(-) delete mode 100644 catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java (limited to 'catalog-model/src/test') diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java deleted file mode 100644 index 8ce7d8db57..0000000000 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 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.openecomp.sdc.be.model; - -import static com.google.code.beanmatchers.BeanMatchers.hasValidGettersAndSetters; -import static org.hamcrest.MatcherAssert.assertThat; - -import org.junit.Test; - -public class UploadReqInfoTest { - - @Test - public void shouldHaveValidGettersAndSetters() { - assertThat(UploadReqInfo.class, hasValidGettersAndSetters()); - } -} diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java index 5aa742a540..871a43016f 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java @@ -29,7 +29,6 @@ */ package org.openecomp.sdc.be.model.jsonjanusgraph.utils; - import java.util.HashMap; import org.junit.jupiter.api.Test; @@ -38,6 +37,7 @@ import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; +import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition; @@ -72,6 +72,9 @@ import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum; import java.util.LinkedList; import java.util.List; import java.util.Map; +import org.openecomp.sdc.be.model.tosca.ToscaType; +import org.openecomp.sdc.be.ui.model.OperationUi; +import org.openecomp.sdc.be.ui.model.PropertyAssignmentUi; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -276,6 +279,49 @@ public class ModelConverterTest { assertEquals("toNode", result.get(0).getToId()); } + @Test + void testConvertRelationTemplateToToscaRelation() + { + RequirementCapabilityRelDef reqCap = new RequirementCapabilityRelDef(); + reqCap.setOriginUI(true); + reqCap.setFromNode("fromNode"); + reqCap.setToNode("toNode"); + List list = new LinkedList<>(); + CapabilityRequirementRelationship relationship = new CapabilityRequirementRelationship(); + RelationshipInfo info = new RelationshipInfo(); + info.setCapabilityOwnerId("capOwnerId"); + info.setId("id"); + info.setCapabilityUid("capUid"); + info.setRequirementOwnerId("reqOwnerId"); + info.setRequirementUid("reqUid"); + info.setRequirement("req"); + info.setCapability("cap"); + RelationshipImpl relationshipImpl = new RelationshipImpl(); + relationshipImpl.setType("type"); + info.setRelationships(relationshipImpl); + relationship.setRelation(info); + OperationUi operationUi = new OperationUi(); + operationUi.setInterfaceType("tosca.interfaces.relationship.Configure"); + operationUi.setOperationType("add_source"); + final ArtifactDataDefinition artifactDataDefinition = new ArtifactDataDefinition(); + artifactDataDefinition.setArtifactName("impl"); + operationUi.setImplementation(artifactDataDefinition); + PropertyAssignmentUi propertyAssignmentUi = new PropertyAssignmentUi(); + propertyAssignmentUi.setName("strInput1"); + propertyAssignmentUi.setType(ToscaType.STRING.getType()); + propertyAssignmentUi.setValue("inputValue"); + operationUi.setInputs(List.of(propertyAssignmentUi)); + relationship.setOperations(List.of(operationUi)); + list.add(relationship); + reqCap.setRelationships(list); + + List result = ModelConverter.convertRelationToToscaRelation(reqCap); + assertEquals(1, result.size()); + assertEquals(false, result.get(0).getInterfaces().isEmpty()); + assertEquals(false, result.get(0).getInterfaces().getListToscaDataDefinition().get(0).getOperations().isEmpty()); + assertEquals(false, result.get(0).getInterfaces().getListToscaDataDefinition().get(0).getOperations().get("add_source").getInputs().isEmpty()); + } + @Test public void testConvertToMapOfMapCapabilityPropertiesonvertRelation() { -- cgit 1.2.3-korg