aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java/org
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-model/src/test/java/org
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-model/src/test/java/org')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/UploadReqInfoTest.java33
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverterTest.java48
2 files changed, 47 insertions, 34 deletions
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;
@@ -277,6 +280,49 @@ public class ModelConverterTest {
}
@Test
+ void testConvertRelationTemplateToToscaRelation()
+ {
+ RequirementCapabilityRelDef reqCap = new RequirementCapabilityRelDef();
+ reqCap.setOriginUI(true);
+ reqCap.setFromNode("fromNode");
+ reqCap.setToNode("toNode");
+ List<CapabilityRequirementRelationship> 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<RelationshipInstDataDefinition> 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()
{
Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();