diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2022-09-21 15:39:47 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-09-26 15:57:27 +0000 |
commit | 467338ad23721809b1f95cb9d2920740b83acb5f (patch) | |
tree | 762c7d8501c5d49d0d4d30408f3a96533095526b /catalog-be/src/test | |
parent | 02b910764f71ce7ad64a582e91bcb92c73fd33a6 (diff) |
Service import - Import unknown capability types
When an unknown capability is found in the csar
used to import a service, this capability will
be added to the model to which the service is
being imported
Issue-ID: SDC-4187
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: If43b14008e18195bff237c35c5fc1154e57239ff
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java | 24 | ||||
-rw-r--r-- | catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar | bin | 63901 -> 63922 bytes |
2 files changed, 20 insertions, 4 deletions
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 e4b6dd4021..944f51c244 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 @@ -80,9 +80,9 @@ import org.openecomp.sdc.be.externalapi.servlet.ArtifactExternalServlet; import org.openecomp.sdc.be.impl.ServletUtils; import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts; import org.openecomp.sdc.be.model.ArtifactDefinition; -import org.openecomp.sdc.be.model.ArtifactTypeDefinition; import org.openecomp.sdc.be.model.AttributeDefinition; import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.CapabilityTypeDefinition; import org.openecomp.sdc.be.model.Component; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.ComponentInstanceInput; @@ -114,8 +114,9 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache; import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation; import org.openecomp.sdc.be.model.operations.impl.ArtifactTypeOperation; +import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation; +import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.servlets.AbstractValidationsServlet; import org.openecomp.sdc.be.tosca.CsarUtils; @@ -130,8 +131,6 @@ import org.yaml.snakeyaml.Yaml; class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTestSetup { - private static final String DEFAULT_ICON = "defaulticon"; - private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class); private final ResourceImportManager resourceImportManager = mock(ResourceImportManager.class); private final ServletUtils servletUtils = mock(ServletUtils.class); @@ -142,6 +141,8 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest private final DataTypeBusinessLogic dataTypeBusinessLogic = mock(DataTypeBusinessLogic.class); private final ArtifactTypeImportManager artifactTypeImportManager = mock(ArtifactTypeImportManager.class); private final GroupTypeOperation groupTypeOperation = mock(GroupTypeOperation.class); + private final CapabilityTypeOperation capabilityTypeOperation = mock(CapabilityTypeOperation.class); + private final CapabilityTypeImportManager capabilityTypeImportManager = mock(CapabilityTypeImportManager.class); @InjectMocks private ServiceImportBusinessLogic sIBL; @@ -254,6 +255,12 @@ 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(capabilityTypeOperation.getCapabilityType(anyString())) + .thenReturn(Either.left(new CapabilityTypeDefinition())); + when(capabilityTypeOperation.getCapabilityType(contains("tosca.testcapabilitytypes.Name"))) + .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); + when(toscaOperationFacade.getLatestByToscaResourceName(contains("org.openecomp.resource"), isNull())) .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); when(toscaOperationFacade.getLatestByToscaResourceName(contains("tosca.nodes."), isNull())) @@ -291,6 +298,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest assertEquals(1, artifactTypesMap.size()); assertNotNull(artifactTypesMap.get("tosca.testartifacts.Name")); + ArgumentCaptor<String> capabilityTypes = ArgumentCaptor.forClass(String.class); + verify(capabilityTypeImportManager).createCapabilityTypes( + capabilityTypes.capture(), + isNull(), + anyBoolean()); + Map<String, Object> capabilityTypesMap = new Yaml().load(capabilityTypes.getValue()); + assertEquals(1, capabilityTypesMap.size()); + assertNotNull(capabilityTypesMap.get("tosca.testcapabilitytypes.Name")); + ArgumentCaptor<Map<String, Object>> nodeTypes = ArgumentCaptor.forClass(Map.class); verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(), anyBoolean(), anyBoolean()); diff --git a/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar b/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar Binary files differindex 815b798ec3..c780e3484c 100644 --- a/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar +++ b/catalog-be/src/test/resources/csars/service-Ser09080002-csar.csar |