X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Ftest%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fcomponents%2Fimpl%2FServiceImportBusinessLogicTest.java;h=fc709ceaead1344eaacd80c6d9156ec50978d274;hb=7c61c7bb0369bc27d05c8801c8cb0cca41e494bf;hp=dc8e6176b012b7dae7b74f55ba1d98e8b6b744e1;hpb=630e46ef816ea2d16d358ed3fab0d9ebed884c19;p=sdc.git 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 dc8e6176b0..fc709ceaea 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 @@ -27,6 +27,7 @@ import static org.mockito.Mockito.anyList; import static org.mockito.Mockito.anyMap; import static org.mockito.Mockito.contains; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.isNull; import static org.mockito.Mockito.matches; @@ -117,6 +118,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; 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.model.operations.impl.ModelOperation; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.servlets.AbstractValidationsServlet; import org.openecomp.sdc.be.tosca.CsarUtils; @@ -207,14 +209,14 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest .thenReturn(Either.left(newService)); when(toscaOperationFacade.validateCsarUuidUniqueness(anyString())).thenReturn(StorageOperationStatus.OK); ServiceCsarInfo csarInfo = getCsarInfo(); - when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString())).thenReturn(csarInfo); + when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString(), any())).thenReturn(csarInfo); when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), any(Service.class))) .thenReturn(Either.left(new HashMap>>())); - when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), any(), any(Service.class))) - .thenReturn(getParsedToscaYamlInfo()); + doReturn(getParsedToscaYamlInfo()).when(csarBusinessLogic).getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), any(), any(Service.class)); + doReturn(getParsedToscaYamlInfo()).when(csarBusinessLogic).getParsedToscaYamlInfo(any(ServiceCsarInfo.class), any(Service.class)); when(serviceBusinessLogic.lockComponentByName(newService.getSystemName(), oldService, CREATE_RESOURCE)).thenReturn(Either.left(true)); when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(createOldResource())); - when(serviceImportParseLogic.createServiceTransaction(oldService, csarInfo.getModifier(), false)).thenReturn(newService); + when(serviceImportParseLogic.createServiceTransaction(oldService, csarInfo.getModifier(), false, AuditingActionEnum.CREATE_RESOURCE)).thenReturn(newService); when(serviceImportParseLogic.createInputsOnService(eq(oldService), anyMap())).thenReturn(newService); Assertions.assertDoesNotThrow(() -> { when(serviceImportParseLogic.createSubstitutionFilterOnService(eq(oldService), any())).thenReturn(newService); @@ -317,7 +319,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest assertNotNull(capabilityTypesMap.get("tosca.testcapabilitytypes.Name")); ArgumentCaptor> nodeTypes = ArgumentCaptor.forClass(Map.class); - verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(), + verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(), any(), anyBoolean(), anyBoolean()); Map nodeTypesMap = nodeTypes.getValue(); Map newUpdatedNodeType = (Map) nodeTypesMap.get(updatedNodeType); @@ -347,7 +349,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest when(serviceBusinessLogic.validateServiceBeforeCreate(any(Service.class), any(User.class), any(AuditingActionEnum.class))) .thenReturn(Either.left(newService)); when(toscaOperationFacade.validateCsarUuidUniqueness(anyString())).thenReturn(StorageOperationStatus.OK); - when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString())).thenReturn(getCsarInfo()); + when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), any(Map.class), anyString(), any())).thenReturn(getCsarInfo()); when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), any(Service.class))) .thenReturn(Either.right(ActionStatus.GENERAL_ERROR)); when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), anyString(), @@ -367,11 +369,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest new HashedMap(); when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), - any(Map.class), anyString())).thenReturn(csarInfo); + any(Map.class), anyString(), any())).thenReturn(csarInfo); when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), any(Service.class))).thenReturn(Either.left(map)); Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceFromCsar(oldService, - user, payload, csarUUID)); + user, payload, csarUUID, null)); } @Test @@ -397,7 +399,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceFromYaml(oldService, topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, - nodeTypesArtifactsToCreate, false, true, nodeName, user.getUserId())); + nodeTypesArtifactsToCreate, false, true, nodeName, user.getUserId(), null)); } @Test @@ -416,7 +418,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo); when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService, - false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId())); + false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId(), null)); } @Test @@ -435,7 +437,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo); when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIBL.createServiceAndRIsFromYaml(oldService, - false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId())); + false, nodeTypesArtifactsToCreate, false, true, csfyp, user.getUserId(), null)); } @Test @@ -673,16 +675,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest artifactDefinition.setArtifactName("artifactDefinition"); deploymentArtifacts.put("deploymentArtifacts", artifactDefinition); preparedService.setDeploymentArtifacts(deploymentArtifacts); - String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; - Map>> nodeTypesArtifactsToHandle = new HashMap<>(); - NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName, nodeTypesArtifactsToHandle); when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(createServiceObject(true))); when(csarArtifactsAndGroupsBusinessLogic.updateResourceArtifactsFromCsar(any(CsarInfo.class), any(Service.class), anyString(), anyString(), anyList(), anyBoolean(), anyBoolean())).thenReturn(Either.left(preparedService)); Assertions.assertNotNull( sIBL.createOrUpdateArtifacts(operation, createdArtifacts, yamlFileName, csarInfo, - preparedService, nodeTypeInfoToUpdateArtifacts, true, true)); + preparedService, true, true)); } @Test @@ -1277,7 +1276,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition); when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat); when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(service)); - Assertions.assertNotNull(sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap)); + Assertions.assertNotNull(sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap, null)); } @Test @@ -1288,7 +1287,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map uploadResInstancesMap = new HashMap<>(); Assertions.assertThrows(ComponentException.class, - () -> sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap)); + () -> sIBL.createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap, null)); } @Test @@ -2500,7 +2499,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest assertNotNull(mainTemplateService); final String mainTemplateContent = new String(mainTemplateService); - return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, null, mainTemplateName, mainTemplateContent, false); + return new ServiceCsarInfo(user, csarUuid, csar, vfReousrceName, null, mainTemplateName, mainTemplateContent, false, mock(ModelOperation.class)); } catch (URISyntaxException | ZipException e) { fail(e); }