aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2022-09-21 13:21:40 +0100
committerKrupaNagabhushan <krupa.nagabhushan@est.tech>2022-09-27 09:45:27 +0100
commit6fa01940a1dec7a323f87f7a141dbef04d8af3d3 (patch)
tree4354c3515911d2c9a7cf5552262e1fbc3a2c2356 /catalog-be/src/test
parent467338ad23721809b1f95cb9d2920740b83acb5f (diff)
Service import - Import unknown interface types
Issue-ID: SDC-4186 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: Idfbce90e795136ef2ea1a96f65e458db9206339f
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java14
-rw-r--r--catalog-be/src/test/resources/csars/service-Ser09080002-csar.csarbin63922 -> 63966 bytes
-rw-r--r--catalog-be/src/test/resources/csars/serviceWithUnknownTypes.csar (renamed from catalog-be/src/test/resources/csars/serviceWithUnknownDataTypes.csar)bin56980 -> 57080 bytes
4 files changed, 27 insertions, 1 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java
index 80ecc212f1..add427d164 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfoTest.java
@@ -47,7 +47,7 @@ class ServiceCsarInfoTest {
private User user;
private static final String CSAR_UUID = "csarUUID";
- private static final String PAYLOAD_NAME = "csars/serviceWithUnknownDataTypes.csar";
+ private static final String PAYLOAD_NAME = "csars/serviceWithUnknownTypes.csar";
private static final String SERVICE_NAME = "serviceWithDataType";
private static final String MAIN_TEMPLATE_NAME = "Definitions/service-Servicewithdatatype-template.yml";
@@ -78,4 +78,16 @@ return new ServiceCsarInfo(user, CSAR_UUID, payload, SERVICE_NAME, mainTemplateN
((Map<String, Object>) ((Map<String, Object>) dataTypeDefinition.get("properties")).get("prop2")).get("type"));
}
+ @SuppressWarnings("unchecked")
+ @Test
+ void testGetInterfaceTypes() {
+ final Map<String, Object> interfaceTypes = csarInfo.getInterfaceTypes();
+ assertEquals(9, interfaceTypes.size());
+ final Map<String, Object> interfaceTypeDefinition = (Map<String, Object>) interfaceTypes.get(
+ "tosca.interfaces.test.node.lifecycle.Reconfigure");
+ assertNotNull(interfaceTypeDefinition);
+ assertEquals("tosca.interfaces.Root", interfaceTypeDefinition.get("derived_from"));
+ assertEquals("reconfigure", ((Map<String, Object>) interfaceTypeDefinition.get("Reconfigure")).get("description"));
+ }
+
}
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 944f51c244..faaa7e3162 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
@@ -143,6 +143,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
private final GroupTypeOperation groupTypeOperation = mock(GroupTypeOperation.class);
private final CapabilityTypeOperation capabilityTypeOperation = mock(CapabilityTypeOperation.class);
private final CapabilityTypeImportManager capabilityTypeImportManager = mock(CapabilityTypeImportManager.class);
+ private final InterfaceLifecycleTypeImportManager interfaceLifecycleTypeImportManager = mock(InterfaceLifecycleTypeImportManager.class);
@InjectMocks
private ServiceImportBusinessLogic sIBL;
@@ -256,6 +257,10 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
when(artifactTypeOperation.getArtifactTypeByUid(contains("tosca.testartifacts.Name"))).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
when(artifactTypeOperation.getArtifactTypeByUid(contains("tosca.artifacts"))).thenReturn(Either.left(null));
+ when(interfaceLifecycleTypeOperation.getInterface(contains("tosca.interfaces"))).thenReturn(Either.left(new InterfaceDefinition()));
+ when(interfaceLifecycleTypeOperation.getInterface(contains("tosca.interfaces.test"))).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+
+
when(capabilityTypeOperation.getCapabilityType(anyString()))
.thenReturn(Either.left(new CapabilityTypeDefinition()));
when(capabilityTypeOperation.getCapabilityType(contains("tosca.testcapabilitytypes.Name")))
@@ -313,6 +318,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
Map<String, Object> nodeTypesMap = nodeTypes.getValue();
Map<String, Object> newUpdatedNodeType = (Map<String, Object>) nodeTypesMap.get(updatedNodeType);
assertEquals(8, ((Map<String, Object>) newUpdatedNodeType.get("properties")).size());
+
+ ArgumentCaptor<String> interfaceTypes = ArgumentCaptor.forClass(String.class);
+ verify(interfaceLifecycleTypeImportManager).createLifecycleTypes(interfaceTypes.capture(), any(), anyBoolean());
+ Map<String, Object> yamlInterfaceMap = new Yaml().load(interfaceTypes.getValue());
+ assertEquals(3, yamlInterfaceMap.size());
+ assertNotNull(yamlInterfaceMap.get("tosca.interfaces.test.node.lifecycle.Attach"));
+ assertNotNull(yamlInterfaceMap.get("tosca.interfaces.test.node.lifecycle.Detach"));
+ assertNotNull(yamlInterfaceMap.get("tosca.interfaces.test.node.lifecycle.Reconfigure"));
+
}
@Test
diff --git a/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar b/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar
index c780e3484c..de7d71fc37 100644
--- a/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar
+++ b/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar
Binary files differ
diff --git a/catalog-be/src/test/resources/csars/serviceWithUnknownDataTypes.csar b/catalog-be/src/test/resources/csars/serviceWithUnknownTypes.csar
index ffd209978f..b50113c2d2 100644
--- a/catalog-be/src/test/resources/csars/serviceWithUnknownDataTypes.csar
+++ b/catalog-be/src/test/resources/csars/serviceWithUnknownTypes.csar
Binary files differ