diff options
Diffstat (limited to 'catalog-be/src/test/java')
3 files changed, 41 insertions, 4 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java index 04a87e1db4..9c583729f0 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java @@ -494,7 +494,7 @@ class ResourceImportManagerTest { .createOrUpdateResourceByImport(any(Resource.class), any(User.class), eq(true), eq(true), eq(false), eq(null), eq(null), eq(false))) .thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK)).thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK)); - importManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, false, false); + importManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, "", false, false); verify(janusGraphDao).commit(); } 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 3f8f9c382c..a77ef5bd76 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 @@ -115,6 +115,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.servlets.AbstractValidationsServlet; import org.openecomp.sdc.be.tosca.CsarUtils; +import org.openecomp.sdc.be.tosca.ToscaExportHandler; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.common.api.Constants; @@ -173,6 +174,18 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest jsonObject.put(ToscaGetFunctionType.GET_INPUT.getFunctionName(), "zxjTestImportServiceAb_propertiesName"); componentInstanceProperty.setValue(jsonObject.toJSONString()); + Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>(); + ArtifactDefinition artifactDef = new ArtifactDefinition(); + String artifactUniqueId = "test_extcp_resource.assettoscatemplate"; + artifactDef.setUniqueId(artifactUniqueId); + toscaArtifacts.put(ToscaExportHandler.ASSET_TOSCA_TEMPLATE, artifactDef); + Resource resource = new Resource(); + String resourceUniqueId = "extcp_resource"; + resource.setUniqueId(resourceUniqueId); + resource.setToscaArtifacts(toscaArtifacts); + ImmutablePair<String, byte[]> resourceTemplate = getNodeType(); + String updatedNodeType = "org.openecomp.resource.cp.extCP"; + newService.setComponentInstancesProperties( Collections.singletonMap(COMPONENT_ID + "." + "zxjTestImportServiceAb", Collections.singletonList(componentInstanceProperty))); newService.setProperties(getProperties()); @@ -234,8 +247,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest - when(toscaOperationFacade.getLatestByToscaResourceName(contains("org.openecomp.resource"), isNull())).thenReturn(Either.left(null)); - when(toscaOperationFacade.getLatestByToscaResourceName(contains("tosca.nodes."), isNull())).thenReturn(Either.left(null)); + when(toscaOperationFacade.getLatestByToscaResourceName(contains("org.openecomp.resource"), isNull())) + .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); + when(toscaOperationFacade.getLatestByToscaResourceName(contains("tosca.nodes."), isNull())) + .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); + when(toscaOperationFacade.getLatestByToscaResourceName(contains(updatedNodeType), isNull())).thenReturn(Either.left(resource)); + when(artifactsBusinessLogic.handleDownloadRequestById(resourceUniqueId, artifactUniqueId, user.getUserId(), ComponentTypeEnum.RESOURCE, null, null)) + .thenReturn(resourceTemplate); when(toscaOperationFacade.updatePropertyOfComponent(eq(oldService), any(PropertyDefinition.class))).thenReturn(Either.left(null)); when(toscaOperationFacade.updateComponentInstancePropsToComponent(anyMap(), anyString())).thenReturn(Either.left(null)); @@ -258,6 +276,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest assertNotNull(yamlMap.get("tosca.datatypes.test_a")); assertNotNull(yamlMap.get("tosca.datatypes.test_b")); assertNotNull(yamlMap.get("onap.datatypes.ToscaConceptIdentifier")); + + ArgumentCaptor<Map<String, Object>> nodeTypes = ArgumentCaptor.forClass(Map.class); + verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(), + anyBoolean(), anyBoolean()); + 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()); } @Test @@ -2431,6 +2456,19 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest return null; } + private ImmutablePair<String, byte[]> getNodeType() { + try { + File resource = new File( + ServiceImportBusinessLogicTest.class.getClassLoader().getResource("node-types/resource-Extcp-template.yml").toURI()); + byte[] extcpResource = Files.readAllBytes(resource.toPath()); + + return new ImmutablePair<>("org.openecomp.resource.cp.extCP", extcpResource); + } catch (URISyntaxException | IOException e) { + fail(e); + } + return null; + } + protected CsarUtils.NonMetaArtifactInfo getNonMetaArtifactInfo() { String artifactName = "artifactName", path = "/src/test/resources/valid_vf.csar", artifactType = "AAI_SERVICE_MODEL"; ArtifactGroupTypeEnum artifactGroupType = ArtifactGroupTypeEnum.TOSCA; 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 fd39b65db0..ecec834599 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 @@ -131,7 +131,6 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM private static final String RESOURCE_SUBCATEGORY = "Router"; private final ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class); - private final ResourceImportManager resourceImportManager = mock(ResourceImportManager.class); private final ServletUtils servletUtils = mock(ServletUtils.class); protected final ServletContext servletContext = mock(ServletContext.class); |