diff options
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp')
3 files changed, 496 insertions, 565 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 884978a77f..ac73a0da99 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 @@ -16,7 +16,6 @@ package org.openecomp.sdc.be.components.impl; - import static org.assertj.core.api.Java6Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -51,7 +50,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.sdc.be.components.csar.CsarBusinessLogic; import org.openecomp.sdc.be.components.csar.CsarInfo; @@ -61,7 +59,6 @@ import org.openecomp.sdc.be.components.impl.utils.CreateServiceFromYamlParameter import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus; import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; @@ -112,30 +109,38 @@ import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.exception.ResponseFormat; class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTestSetup { - private final static String DEFAULT_ICON = "defaulticon"; @InjectMocks - static ServiceImportBusinessLogic serviceImportBusinessLogic; - - ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class); - CsarBusinessLogic csarBusinessLogic = Mockito.mock(CsarBusinessLogic.class); - ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class); - ServiceImportParseLogic serviceImportParseLogic = Mockito.mock(ServiceImportParseLogic.class); - ArtifactDefinition artifactDefinition = Mockito.mock(ArtifactDefinition.class); + private static ServiceImportBusinessLogic serviceImportBusinessLogic; + + private ServiceBusinessLogic serviceBusinessLogic = mock(ServiceBusinessLogic.class); + private CsarBusinessLogic csarBusinessLogic = mock(CsarBusinessLogic.class); + private ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class); + private ServiceImportParseLogic serviceImportParseLogic = mock(ServiceImportParseLogic.class); + private ArtifactDefinition artifactDefinition = mock(ArtifactDefinition.class); + private UserBusinessLogic userBusinessLogic = mock(UserBusinessLogic.class); + private ComponentInstanceBusinessLogic componentInstanceBusinessLogic = mock(ComponentInstanceBusinessLogic.class); + private ComponentsUtils componentsUtils = mock(ComponentsUtils.class); + private ServletUtils servletUtils = mock(ServletUtils.class); + private ResourceImportManager resourceImportManager = mock(ResourceImportManager.class); + private ArtifactsBusinessLogic artifactsBusinessLogic = mock(ArtifactsBusinessLogic.class); + + private AbstractValidationsServlet servlet = new ArtifactExternalServlet(userBusinessLogic, + componentInstanceBusinessLogic, componentsUtils, servletUtils, resourceImportManager, artifactsBusinessLogic); + public static String loadFileNameToJsonString(String fileName) throws IOException { + String sourceDir = "src/test/resources/normativeTypes"; + return loadFileNameToJsonString(sourceDir, fileName); + } - private static UserBusinessLogic userBusinessLogic = Mockito.mock(UserBusinessLogic.class); - private static ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class); - private static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class); - private static ServletUtils servletUtils = mock(ServletUtils.class); - private static ResourceImportManager resourceImportManager = mock(ResourceImportManager.class); - private static ArtifactsBusinessLogic artifactsBusinessLogic = mock(ArtifactsBusinessLogic.class); - - private static AbstractValidationsServlet servlet = new ArtifactExternalServlet(userBusinessLogic, - componentInstanceBusinessLogic, componentsUtils, servletUtils, resourceImportManager, artifactsBusinessLogic); + private static String loadFileNameToJsonString(String sourceDir, String fileName) throws IOException { + java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir, fileName); + byte[] fileContent = Files.readAllBytes(filePath); + return new String(fileContent); + } @BeforeEach - public void initMocks() { + void initMocks() { MockitoAnnotations.openMocks(this); when(artifactDefinition.getMandatory()).thenReturn(true); when(artifactDefinition.getArtifactName()).thenReturn("creatorFullName"); @@ -151,62 +156,56 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testGetComponentsUtils() { - ComponentsUtils result; - result = serviceImportBusinessLogic.getComponentsUtils(); - + void testGetComponentsUtils() { + assertNotNull(serviceImportBusinessLogic.getComponentsUtils()); } @Test - public void testSetComponentsUtils() { - ComponentsUtils componentsUtils = null; - - + void testSetComponentsUtils() { assertNotNull(serviceImportBusinessLogic); - } @Test - public void testCreateService() { + void testCreateService() { Service oldService = createServiceObject(true); String payloadName = "valid_vf"; Map<String, byte[]> payload = crateCsarFromPayload(); Service newService = createServiceObject(true); when(serviceBusinessLogic.validateServiceBeforeCreate(any(Service.class), any(User.class), any(AuditingActionEnum.class))) - .thenReturn(Either.left(newService)); + .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()); + any(User.class), any(Map.class), anyString())).thenReturn(getCsarInfo()); when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), - any(Service.class))).thenReturn(Either.right(ActionStatus.GENERAL_ERROR)); + any(Service.class))).thenReturn(Either.right(ActionStatus.GENERAL_ERROR)); when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), any(), - any(CsarInfo.class), anyString(), any(Service.class))).thenReturn(getParsedToscaYamlInfo()); + any(CsarInfo.class), anyString(), any(Service.class))).thenReturn(getParsedToscaYamlInfo()); Assertions.assertThrows(ComponentException.class, () -> sIB1.createService(oldService, - AuditingActionEnum.CREATE_RESOURCE, user, payload, payloadName)); + AuditingActionEnum.CREATE_RESOURCE, user, payload, payloadName)); } @Test - public void testCreateServiceFromCsar() { + void testCreateServiceFromCsar() { Service oldService = createServiceObject(true); String csarUUID = "valid_vf"; Map<String, byte[]> payload = crateCsarFromPayload(); CsarInfo csarInfo = getCsarInfo(); Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> map = - new HashedMap(); + new HashedMap(); when(csarBusinessLogic.getCsarInfo(any(Service.class), any(), any(User.class), - any(Map.class), anyString())).thenReturn(csarInfo); + any(Map.class), anyString())).thenReturn(csarInfo); when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), - any(Service.class))).thenReturn(Either.left(map)); + any(Service.class))).thenReturn(Either.left(map)); Assertions.assertThrows(ComponentException.class, () -> sIB1.createServiceFromCsar(oldService, - user, payload, csarUUID)); + user, payload, csarUUID)); } @Test - public void testCreateServiceFromYaml() { + void testCreateServiceFromYaml() { Service oldService = createServiceObject(true); Resource resource = createOldResource(); String topologyTemplateYaml = getMainTemplateContent("service_import_template.yml"); @@ -215,26 +214,25 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>(); String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; - Map<String, NodeTypeInfo> nodeTypesInfo = getNodeTypesInfo(); Map<String, Object> map = new HashMap<>(); map.put("tosca_definitions_version", "123"); nodeTypesInfo.get(nodeName).setMappedToscaTemplate(map); ParsedToscaYamlInfo parsedToscaYamlInfo = getParsedToscaYamlInfo(); when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), any(Map.class), - eq(csarInfo), anyString(), any(Component.class))).thenReturn(parsedToscaYamlInfo); + eq(csarInfo), anyString(), any(Component.class))).thenReturn(parsedToscaYamlInfo); when(serviceBusinessLogic.lockComponentByName(anyString(), any(Service.class), anyString())) - .thenReturn(Either.left(true)); + .thenReturn(Either.left(true)); Assertions.assertThrows(ComponentException.class, () -> sIB1.createServiceFromYaml(oldService, - topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, - nodeTypesArtifactsToCreate, false, true, nodeName)); + topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, + nodeTypesArtifactsToCreate, false, true, nodeName)); } @Test - public void testCreateServiceAndRIsFromYaml() { + void testCreateServiceAndRIsFromYaml() { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Service oldService = createServiceObject(true); Resource resource = createOldResource(); @@ -248,13 +246,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest csfyp.setNodeTypesInfo(nodeTypesInfo); csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo); when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIB1.createServiceAndRIsFromYaml(oldService, - false, nodeTypesArtifactsToCreate, false, true, csfyp)); + false, nodeTypesArtifactsToCreate, false, true, csfyp)); } @Test - public void testCreateServiceAndRIsFromYamlShoudLook() { + void testCreateServiceAndRIsFromYamlShoudLook() { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Service oldService = createServiceObject(true); Resource resource = createOldResource(); @@ -268,13 +266,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest csfyp.setNodeTypesInfo(nodeTypesInfo); csfyp.setParsedToscaYamlInfo(parsedToscaYamlInfo); when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIB1.createServiceAndRIsFromYaml(oldService, - false, nodeTypesArtifactsToCreate, false, true, csfyp)); + false, nodeTypesArtifactsToCreate, false, true, csfyp)); } @Test - public void testCreateOrUpdateArtifacts() { + void testCreateOrUpdateArtifacts() { ArtifactsBusinessLogic.ArtifactOperationEnum operation = ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE; List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); String yamlFileName = "group.yml"; @@ -284,28 +282,28 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List<ArtifactDefinition> artifactDefinitions = new ArrayList<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setArtifactName("artifactName"); artifactDefinitions.add(artifactDefinition); enumListEnumMap.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, - artifactDefinitions); + artifactDefinitions); nodeTypesArtifactsToHandle.put(nodeName, enumListEnumMap); NodeTypeInfoToUpdateArtifacts nodeTypeInfoToUpdateArtifacts = new NodeTypeInfoToUpdateArtifacts(nodeName, nodeTypesArtifactsToHandle); nodeTypeInfoToUpdateArtifacts.setNodeName(nodeName); nodeTypeInfoToUpdateArtifacts.setNodeTypesArtifactsToHandle(nodeTypesArtifactsToHandle); Assertions.assertNotNull( - sIB1.createOrUpdateArtifacts(operation, createdArtifacts, yamlFileName, csarInfo, - preparedResource, nodeTypeInfoToUpdateArtifacts, true, true) + sIB1.createOrUpdateArtifacts(operation, createdArtifacts, yamlFileName, csarInfo, + preparedResource, nodeTypeInfoToUpdateArtifacts, true, true) ); } @Test - public void testHandleVfCsarArtifacts() { + void testHandleVfCsarArtifacts() { Resource resource = createParseResourceObject(true); Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -323,15 +321,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE); when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(resource)); when(csarArtifactsAndGroupsBusinessLogic - .createResourceArtifactsFromCsar(any(CsarInfo.class), any(Resource.class), anyString(), anyString(), - anyList())).thenReturn(Either.left(resource)); + .createResourceArtifactsFromCsar(any(CsarInfo.class), any(Resource.class), anyString(), anyString(), + anyList())).thenReturn(Either.left(resource)); Assertions.assertNotNull( - sIB1.handleVfCsarArtifacts(resource, - csarInfo, createdArtifacts, artifactOperation, true, true)); + sIB1.handleVfCsarArtifacts(resource, + csarInfo, createdArtifacts, artifactOperation, true, true)); } @Test - public void testHandleVfCsarArtifactsGetToscaElement() { + void testHandleVfCsarArtifactsGetToscaElement() { Resource resource = createParseResourceObject(true); Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -349,15 +347,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE); when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(resource)); when(csarArtifactsAndGroupsBusinessLogic - .createResourceArtifactsFromCsar(any(CsarInfo.class), any(Resource.class), anyString(), anyString(), - anyList())).thenReturn(Either.left(resource)); + .createResourceArtifactsFromCsar(any(CsarInfo.class), any(Resource.class), anyString(), anyString(), + anyList())).thenReturn(Either.left(resource)); Assertions.assertNotNull( - sIB1.handleVfCsarArtifacts(resource, - csarInfo, createdArtifacts, artifactOperation, true, true)); + sIB1.handleVfCsarArtifacts(resource, + csarInfo, createdArtifacts, artifactOperation, true, true)); } @Test - public void testCreateOrUpdateSingleNonMetaArtifactToComstants() { + void testCreateOrUpdateSingleNonMetaArtifactToComstants() { Resource resource = createParseResourceObject(false); CsarInfo csarInfo = getCsarInfo(); ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE); @@ -372,21 +370,20 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } - @Test - public void testCreateOrUpdateNonMetaArtifacts() { + void testCreateOrUpdateNonMetaArtifacts() { CsarInfo csarInfo = getCsarInfo(); Resource resource = createParseResourceObject(false); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE); Either<Resource, ResponseFormat> result = sIB1.createOrUpdateNonMetaArtifacts(csarInfo, resource, - createdArtifacts, true, true, artifactOperation); + createdArtifacts, true, true, artifactOperation); assertEquals(result.left().value(), resource); } @Test - public void testFindVfCsarArtifactsToHandle() { + void testFindVfCsarArtifactsToHandle() { Resource resource = createParseResourceObject(false); Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -405,13 +402,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, - ResponseFormat> result = sIB1.findVfCsarArtifactsToHandle(resource, artifactPathAndNameList, user); + ResponseFormat> result = sIB1.findVfCsarArtifactsToHandle(resource, artifactPathAndNameList, user); assertNotNull(result.left().value()); } - @Test - public void testIsNonMetaArtifact() { + void testIsNonMetaArtifact() { ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setMandatory(false); artifactDefinition.setArtifactName("creatorFullName"); @@ -423,7 +419,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testOrganizeVfCsarArtifactsByArtifactOperation() { + void testOrganizeVfCsarArtifactsByArtifactOperation() { List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List<ArtifactDefinition> existingArtifactsToHandle = new ArrayList<>(); @@ -435,12 +431,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Resource resource = createParseResourceObject(false); Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> - enumMapResponseFormatEither = sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifactsToHandle, resource, user); + enumMapResponseFormatEither = sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifactsToHandle, + resource, user); assertNotNull(enumMapResponseFormatEither.left().value()); } @Test - public void testOrganizeVfCsarArtifactsByArtifactOperationElse() { + void testOrganizeVfCsarArtifactsByArtifactOperationElse() { List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List<ArtifactDefinition> existingArtifactsToHandle = new ArrayList<>(); @@ -451,12 +448,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest existingArtifactsToHandle.add(artifactDefinition); Resource resource = createParseResourceObject(false); Assertions.assertNotNull( - sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifactsToHandle, resource, user)); + sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifactsToHandle, resource, user)); } @Test - public void testProcessCsarArtifacts() { + void testProcessCsarArtifacts() { CsarInfo csarInfo = getCsarInfo(); Resource resource = createParseResourceObject(false); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); @@ -464,16 +461,16 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> vfCsarArtifactsToHandle = new - EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); vfCsarArtifactsToHandle.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, artifactPathAndNameList); Assertions.assertNotNull( - sIB1.processCsarArtifacts(csarInfo, - resource, createdArtifacts, true, true, resStatus, vfCsarArtifactsToHandle)); + sIB1.processCsarArtifacts(csarInfo, + resource, createdArtifacts, true, true, resStatus, vfCsarArtifactsToHandle)); } @Test - public void testCreateOrUpdateSingleNonMetaArtifact() { + void testCreateOrUpdateSingleNonMetaArtifact() { Resource resource = createParseResourceObject(false); CsarInfo csarInfo = getCsarInfo(); Map<String, byte[]> csar = csarInfo.getCsar(); @@ -496,16 +493,16 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest artifactDefinition.setArtifactName("artifactName"); Either<ArtifactDefinition, Operation> artifactDefinitionOperationEither = Either.left(artifactDefinition); when(csarArtifactsAndGroupsBusinessLogic.createOrUpdateCsarArtifactFromJson(any(Resource.class), any(User.class), - any(Map.class), any(ArtifactOperationInfo.class))).thenReturn(Either.left(artifactDefinitionOperationEither)); + any(Map.class), any(ArtifactOperationInfo.class))).thenReturn(Either.left(artifactDefinitionOperationEither)); Assertions.assertNotNull( - sIB1.createOrUpdateSingleNonMetaArtifact(resource, csarInfo, artifactPath, - artifactFileName, artifactType, artifactGroupType, artifactLabel, - artifactDisplayName, artifactDescription, artifactId, artifactOperation, - createdArtifacts, true, true, true)); + sIB1.createOrUpdateSingleNonMetaArtifact(resource, csarInfo, artifactPath, + artifactFileName, artifactType, artifactGroupType, artifactLabel, + artifactDisplayName, artifactDescription, artifactId, artifactOperation, + createdArtifacts, true, true, true)); } @Test - public void testHandleNodeTypeArtifacts() { + void testHandleNodeTypeArtifacts() { Resource nodeTypeResource = createParseResourceObject(true); nodeTypeResource.setLifecycleState(LifecycleStateEnum.CERTIFIED); Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = new HashMap<>(); @@ -514,16 +511,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest artifactDefinition.setArtifactName("artifactName"); artifactDefinitions.add(artifactDefinition); nodeTypeArtifactsToHandle.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, - artifactDefinitions); + artifactDefinitions); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); Assertions.assertNotNull( - sIB1.handleNodeTypeArtifacts(nodeTypeResource, nodeTypeArtifactsToHandle, - createdArtifacts, user, true, true)); + sIB1.handleNodeTypeArtifacts(nodeTypeResource, nodeTypeArtifactsToHandle, + createdArtifacts, user, true, true)); } - @Test - public void testCreateOrUpdateServiceArtifacts() throws IOException { + void testCreateOrUpdateServiceArtifacts() throws IOException { ArtifactsBusinessLogic.ArtifactOperationEnum operation = ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE; List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); String yamlFileName = "group.yml"; @@ -545,14 +541,14 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest 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)); + anyString(), anyString(), anyList(), anyBoolean(), anyBoolean())).thenReturn(Either.left(preparedService)); Assertions.assertNotNull( - sIB1.createOrUpdateArtifacts(operation, createdArtifacts, yamlFileName, csarInfo, - preparedService, nodeTypeInfoToUpdateArtifacts, true, true)); + sIB1.createOrUpdateArtifacts(operation, createdArtifacts, yamlFileName, csarInfo, + preparedService, nodeTypeInfoToUpdateArtifacts, true, true)); } @Test - public void testHandleVfCsarServiceArtifacts() { + void testHandleVfCsarServiceArtifacts() { Service service = createServiceObject(true); Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -564,14 +560,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE); when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(service)); - when(csarArtifactsAndGroupsBusinessLogic.deleteVFModules(any(Service.class), any(CsarInfo.class), anyBoolean(), anyBoolean())).thenReturn(Either.left(service)); + when(csarArtifactsAndGroupsBusinessLogic.deleteVFModules(any(Service.class), any(CsarInfo.class), anyBoolean(), anyBoolean())).thenReturn( + Either.left(service)); Assertions.assertNotNull( - sIB1.handleVfCsarArtifacts(service, csarInfo, createdArtifacts, artifactOperation, true, true)); + sIB1.handleVfCsarArtifacts(service, csarInfo, createdArtifacts, artifactOperation, true, true)); } @Test - public void testHandleVfCsarServiceArtifactsGetToscaElement() throws IOException { + void testHandleVfCsarServiceArtifactsGetToscaElement() throws IOException { Service service = createServiceObject(true); Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -589,26 +586,26 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE); when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(service)); when(csarArtifactsAndGroupsBusinessLogic.createResourceArtifactsFromCsar(any(CsarInfo.class), any(Service.class), - anyString(), anyString(), anyList())).thenReturn(Either.left(service)); + anyString(), anyString(), anyList())).thenReturn(Either.left(service)); Assertions.assertNotNull( - sIB1.handleVfCsarArtifacts(service, - csarInfo, createdArtifacts, artifactOperation, true, true)); + sIB1.handleVfCsarArtifacts(service, + csarInfo, createdArtifacts, artifactOperation, true, true)); } @Test - public void testCreateOrUpdateNonMetaServiceArtifacts() { + void testCreateOrUpdateNonMetaServiceArtifacts() { CsarInfo csarInfo = getCsarInfo(); Service service = createServiceObject(true); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE); Either<Service, ResponseFormat> result = sIB1.createOrUpdateNonMetaArtifacts(csarInfo, - service, createdArtifacts, true, true, artifactOperation); + service, createdArtifacts, true, true, artifactOperation); assertEquals(result.left().value(), service); } @Test - public void testFindServiceCsarArtifactsToHandle() { + void testFindServiceCsarArtifactsToHandle() { Service service = createServiceObject(true); Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -627,12 +624,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, - ResponseFormat> result = sIB1.findVfCsarArtifactsToHandle(service, artifactPathAndNameList, user); + ResponseFormat> result = sIB1.findVfCsarArtifactsToHandle(service, artifactPathAndNameList, user); assertNotNull(result.left().value()); } @Test - public void testOrganizeVfCsarArtifactsByServiceArtifactOperation() { + void testOrganizeVfCsarArtifactsByServiceArtifactOperation() { List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List<ArtifactDefinition> existingArtifactsToHandle = new ArrayList<>(); @@ -644,13 +641,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Service service = createServiceObject(true); Either<EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>>, ResponseFormat> - enumMapResponseFormatEither = sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, - existingArtifactsToHandle, service, user); + enumMapResponseFormatEither = sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, + existingArtifactsToHandle, service, user); assertNotNull(enumMapResponseFormatEither.left().value()); } @Test - public void testOrganizeVfCsarArtifactsByServiceArtifactOperationElse() { + void testOrganizeVfCsarArtifactsByServiceArtifactOperationElse() { List<CsarUtils.NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List<ArtifactDefinition> existingArtifactsToHandle = new ArrayList<>(); @@ -661,29 +658,29 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest existingArtifactsToHandle.add(artifactDefinition); Service service = createServiceObject(true); Assertions.assertNotNull( - sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifactsToHandle, service, user)); + sIB1.organizeVfCsarArtifactsByArtifactOperation(artifactPathAndNameList, existingArtifactsToHandle, service, user)); } @Test - public void testProcessServiceCsarArtifacts() { + void testProcessServiceCsarArtifacts() { CsarInfo csarInfo = getCsarInfo(); Service service = createServiceObject(true); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); Either<Service, ResponseFormat> resStatus = Either.left(service); EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<CsarUtils.NonMetaArtifactInfo>> vfCsarArtifactsToHandle = new - EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List<CsarUtils.NonMetaArtifactInfo> objects = new ArrayList<>(); objects.add(getNonMetaArtifactInfo()); vfCsarArtifactsToHandle.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, objects); Assertions.assertNotNull( - sIB1.processCsarArtifacts(csarInfo, - service, createdArtifacts, true, true, resStatus, vfCsarArtifactsToHandle)); + sIB1.processCsarArtifacts(csarInfo, + service, createdArtifacts, true, true, resStatus, vfCsarArtifactsToHandle)); } @Test - public void testGetValidArtifactNames() { + void testGetValidArtifactNames() { CsarInfo csarInfo = getCsarInfo(); Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>(); Either<List<CsarUtils.NonMetaArtifactInfo>, String> result = sIB1.getValidArtifactNames(csarInfo, collectedWarningMessages); @@ -691,7 +688,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testCreateOrUpdateSingleNonMetaServiceArtifact() { + void testCreateOrUpdateSingleNonMetaServiceArtifact() { Service service = createServiceObject(true); CsarInfo csarInfo = getCsarInfo(); Map<String, byte[]> csar = csarInfo.getCsar(); @@ -715,16 +712,16 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest artifactDefinition.setArtifactName("artifactName"); Either<ArtifactDefinition, Operation> artifactDefinitionOperationEither = Either.left(artifactDefinition); when(csarArtifactsAndGroupsBusinessLogic.createOrUpdateCsarArtifactFromJson(any(Service.class), any(User.class), - anyMap(), any(ArtifactOperationInfo.class))).thenReturn(Either.left(artifactDefinitionOperationEither)); + anyMap(), any(ArtifactOperationInfo.class))).thenReturn(Either.left(artifactDefinitionOperationEither)); Assertions.assertNotNull( - sIB1.createOrUpdateSingleNonMetaArtifact(service, csarInfo, artifactPath, artifactFileName, - artifactType, artifactGroupType, artifactLabel, artifactDisplayName, - artifactDescription, artifactId, artifactOperation, createdArtifacts, - true, true, true)); + sIB1.createOrUpdateSingleNonMetaArtifact(service, csarInfo, artifactPath, artifactFileName, + artifactType, artifactGroupType, artifactLabel, artifactDisplayName, + artifactDescription, artifactId, artifactOperation, createdArtifacts, + true, true, true)); } @Test - public void testCreateOrUpdateSingleNonMetaServiceArtifactNull() { + void testCreateOrUpdateSingleNonMetaServiceArtifactNull() { Service service = createServiceObject(true); CsarInfo csarInfo = getCsarInfo(); String artifactPath = "valid_vf.csar", artifactFileName = "", artifactType = ""; @@ -733,54 +730,43 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); Assertions.assertNotNull( - sIB1.createOrUpdateSingleNonMetaArtifact(service, csarInfo, artifactPath, artifactFileName, - artifactType, artifactGroupType, artifactLabel, artifactDisplayName, - artifactDescription, artifactId, artifactOperation, createdArtifacts, - true, true, true)); + sIB1.createOrUpdateSingleNonMetaArtifact(service, csarInfo, artifactPath, artifactFileName, + artifactType, artifactGroupType, artifactLabel, artifactDisplayName, + artifactDescription, artifactId, artifactOperation, createdArtifacts, + true, true, true)); } @Test - public void testCreateGroupsOnResource() { + void testCreateGroupsOnResource() { Service service = createServiceObject(true); Map<String, GroupDefinition> groups = new HashMap<>(); Assertions.assertNotNull( - sIB1.createGroupsOnResource(service, groups)); + sIB1.createGroupsOnResource(service, groups)); } @Test - public void testCreateGroupsOnResourceNull() { + void testCreateGroupsOnResourceNull() { Service service = createServiceObject(true); Map<String, GroupDefinition> groups = new HashMap<>(); - Assertions.assertNotNull( - sIB1.createGroupsOnResource(service, groups)); - - + Assertions.assertNotNull(sIB1.createGroupsOnResource(service, groups)); } @Test - public void testUpdateGroupsMembersUsingResource() { + void testUpdateGroupsMembersUsingResource() { Service service = createServiceObject(true); Map<String, GroupDefinition> groups = getGroups(); - when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())) - .thenReturn(Either.left(true)); - Assertions.assertNotNull( - sIB1.updateGroupsMembersUsingResource(groups, service)); - + Assertions.assertNotNull(sIB1.updateGroupsMembersUsingResource(groups, service)); } @Test - public void testUpdateGroupsMembersUsingResource_left() { + void testUpdateGroupsMembersUsingResource_left() { Service service = createServiceObject(true); Map<String, GroupDefinition> groups = getGroups(); - when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())) - .thenReturn(Either.left(true)); - Assertions.assertNotNull( - sIB1.updateGroupsMembersUsingResource(groups, service)); - + Assertions.assertNotNull(sIB1.updateGroupsMembersUsingResource(groups, service)); } @Test - public void testCreateRIAndRelationsFromResourceYaml() throws IOException { + void testCreateRIAndRelationsFromResourceYaml() throws IOException { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; String yamlName = "group.yml"; Resource resource = createParseResourceObject(true); @@ -797,14 +783,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = new HashMap<>(); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createRIAndRelationsFromYaml(yamlName, resource, uploadComponentInstanceInfoMap, - topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, - csarInfo, nodeTypesArtifactsToCreate, nodeName)); + .createRIAndRelationsFromYaml(yamlName, resource, uploadComponentInstanceInfoMap, + topologyTemplateYaml, nodeTypesNewCreatedArtifacts, nodeTypesInfo, + csarInfo, nodeTypesArtifactsToCreate, nodeName)); } - @Test - public void testCreateResourceInstancesRelations() { + void testCreateResourceInstancesRelations() { String yamlName = "group.yml"; Resource resource = createParseResourceObject(true); resource.setComponentInstances(creatComponentInstances()); @@ -814,11 +799,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest when(serviceImportParseLogic.getResourceAfterCreateRelations(any(Resource.class))).thenReturn(resource); when(toscaOperationFacade.getToscaFullElement(anyString())).thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createResourceInstancesRelations(user, yamlName, resource, uploadResInstancesMap)); + .createResourceInstancesRelations(user, yamlName, resource, uploadResInstancesMap)); } @Test - public void testCreateResourceInstancesRelations_Empty() { + void testCreateResourceInstancesRelations_Empty() { String yamlName = "group.yml"; Resource resource = createParseResourceObject(true); resource.setComponentInstances(creatComponentInstances()); @@ -828,12 +813,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest when(serviceImportParseLogic.getResourceAfterCreateRelations(any(Resource.class))).thenReturn(resource); when(toscaOperationFacade.getToscaFullElement(anyString())).thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createResourceInstancesRelations(user, yamlName, resource, uploadResInstancesMap)); + .createResourceInstancesRelations(user, yamlName, resource, uploadResInstancesMap)); } - @Test - public void testProcessComponentInstance1() { + void testProcessComponentInstance1() { String yamlName = "group.yml"; Resource resource = createParseResourceObject(true); Resource originResource = createParseResourceObject(false); @@ -859,12 +843,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Assertions.assertNotNull(resource); Assertions.assertNotNull(yamlName); sIB1.processComponentInstance(yamlName, resource, componentInstancesList, allDataTypes.left().value(), instProperties, - instCapabilties, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, - originCompMap, instInputs, instNodeFilter, uploadComponentInstanceInfo); + instCapabilties, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, + originCompMap, instInputs, instNodeFilter, uploadComponentInstanceInfo); } @Test - public void testProcessComponentInstance_null() { + void testProcessComponentInstance_null() { String yamlName = "group.yml"; Resource resource = createParseResourceObject(true); Resource originResource = createParseResourceObject(false); @@ -884,13 +868,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest uploadComponentInstanceInfo.setName("zxjTestImportServiceAb0"); Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName, - resource, componentInstancesList, null, instProperties, instCapabilties, - instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, - instInputs, instNodeFilter, uploadComponentInstanceInfo)); + resource, componentInstancesList, null, instProperties, instCapabilties, + instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, + instInputs, instNodeFilter, uploadComponentInstanceInfo)); } @Test - public void testAddInputsValuesToRi() { + void testAddInputsValuesToRi() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); Map<String, List<UploadPropInfo>> properties = new HashMap<>(); List<UploadPropInfo> uploadPropInfoList = getPropertyList(); @@ -913,12 +897,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest allDataTypes.put("dataTypeDefinitionMap", dataTypeDefinition); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, - currentCompInstance, instInputs, allDataTypes)); + .addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, + currentCompInstance, instInputs, allDataTypes)); } @Test - public void testProcessProperty() { + void testProcessProperty() { Resource resource = createParseResourceObject(true); List<InputDefinition> inputs = new ArrayList<>(); InputDefinition inputDefinition = new InputDefinition(); @@ -939,31 +923,31 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testHandleSubstitutionMappings() { + void testHandleSubstitutionMappings() { Resource resource = createParseResourceObject(true); resource.setResourceType(ResourceTypeEnum.VF); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>(); when(toscaOperationFacade.getToscaFullElement(anyString())) - .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); + .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .handleSubstitutionMappings(resource, uploadResInstancesMap)); + .handleSubstitutionMappings(resource, uploadResInstancesMap)); } @Test - public void testHandleSubstitutionMappings_left() { + void testHandleSubstitutionMappings_left() { Resource resource = createParseResourceObject(true); resource.setResourceType(ResourceTypeEnum.VF); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>(); when(toscaOperationFacade.getToscaFullElement(anyString())) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .handleSubstitutionMappings(resource, uploadResInstancesMap)); + .handleSubstitutionMappings(resource, uploadResInstancesMap)); } @Test - public void testCreateResourceInstances() { + void testCreateResourceInstances() { String yamlName = "group.yml"; Resource resource = createParseResourceObject(true); Resource originResource = createParseResourceObject(false); @@ -976,11 +960,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest nodeNamespaceMap.put("resources", originResource); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createResourceInstances(yamlName, resource, uploadResInstancesMap, nodeNamespaceMap)); + .createResourceInstances(yamlName, resource, uploadResInstancesMap, nodeNamespaceMap)); } @Test - public void testHandleNodeTypes() throws IOException { + void testHandleNodeTypes() throws IOException { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; String yamlName = "group.yml"; Resource resource = createParseResourceObject(true); @@ -997,11 +981,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Assertions.assertNotNull(resource); sIB1.handleNodeTypes(yamlName, resource, topologyTemplateYaml, needLock, nodeTypesArtifactsToHandle, - nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeName); + nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeName); } @Test - public void testHandleNestedVfc1() { + void testHandleNestedVfc1() { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Resource resource = createParseResourceObject(false); Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); @@ -1014,11 +998,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest CsarInfo csarInfo = getCsarInfo(); Assertions.assertThrows(ComponentException.class, () -> sIB1.handleNestedVfc(resource, - nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName)); + nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName)); } @Test - public void testHandleComplexVfc1() { + void testHandleComplexVfc1() { Resource resource = createParseResourceObject(true); Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); @@ -1027,18 +1011,18 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; String yamlName = "group.yml"; when(serviceImportParseLogic.buildValidComplexVfc(any(Resource.class), any(CsarInfo.class), anyString(), - anyMap())).thenReturn(createParseResourceObject(false)); + anyMap())).thenReturn(createParseResourceObject(false)); when(toscaOperationFacade.getFullLatestComponentByToscaResourceName(anyString())) - .thenReturn(Either.left(resource)); + .thenReturn(Either.left(resource)); when(serviceImportParseLogic.validateNestedDerivedFromDuringUpdate(any(Resource.class), any(Resource.class), - anyBoolean())).thenReturn(Either.left(true)); + anyBoolean())).thenReturn(Either.left(true)); Assertions.assertThrows(ComponentException.class, () -> sIB1.handleComplexVfc(resource, - nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName, yamlName)); + nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName, yamlName)); } @Test - public void testCreateResourcesFromYamlNodeTypesList1() { + void testCreateResourcesFromYamlNodeTypesList1() { String yamlName = "group.yml"; Resource resource = createParseResourceObject(false); Map<String, Object> mappedToscaTemplate = new HashMap<>(); @@ -1049,26 +1033,26 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest CsarInfo csarInfo = getCsarInfo(); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createResourcesFromYamlNodeTypesList(yamlName, resource, mappedToscaTemplate, needLock, - nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo)); + .createResourcesFromYamlNodeTypesList(yamlName, resource, mappedToscaTemplate, needLock, + nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo)); } @Test - public void testCreateNodeTypes1() { + void testCreateNodeTypes1() { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; String yamlName = "group.yml"; Resource resource = createParseResourceObject(false); boolean needLock = true; Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List<ArtifactDefinition> artifactDefinitions = new ArrayList<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setArtifactName("artifactName"); artifactDefinitions.add(artifactDefinition); enumListEnumMap.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, - artifactDefinitions); + artifactDefinitions); nodeTypesArtifactsToHandle.put("nodeTyp", enumListEnumMap); List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>(); Map<String, NodeTypeInfo> nodeTypesInfo = getNodeTypesInfo(); @@ -1084,12 +1068,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Assertions.assertNotNull(resource); sIB1.createNodeTypes(yamlName, - resource, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, - nodeTypesInfo, csarInfo, mapToConvert, nodeTypes); + resource, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, + nodeTypesInfo, csarInfo, mapToConvert, nodeTypes); } @Test - public void testCreateNodeTypeResourceFromYaml() throws IOException { + void testCreateNodeTypeResourceFromYaml() throws IOException { String yamlName = "group.yml"; String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Map<String, Object> nodeMap = new HashMap<>(); @@ -1107,22 +1091,23 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest resourceMetaData.setResourceType("VFC"); ImmutablePair<Resource, ActionStatus> immutablePair = new ImmutablePair<>(resourceVf, ActionStatus.CREATED); when(serviceImportParseLogic.fillResourceMetadata(anyString(), any(Resource.class), anyString(), any(User.class))) - .thenReturn(resourceMetaData); + .thenReturn(resourceMetaData); when(serviceImportParseLogic.buildNodeTypeYaml(any(Map.Entry.class), anyMap(), anyString(), any(CsarInfo.class))) - .thenReturn(nodeName); + .thenReturn(nodeName); when(serviceBusinessLogic.validateUser(any(User.class), anyString(), any(Component.class), any(AuditingActionEnum.class), - anyBoolean())).thenReturn(user); - when(serviceImportParseLogic.createResourceFromNodeType(anyString(), any(UploadResourceInfo.class), any(User.class), anyBoolean(), anyBoolean(), - anyMap(), anyList(), anyBoolean(), any(CsarInfo.class), - anyString(), anyBoolean())).thenReturn(immutablePair); + anyBoolean())).thenReturn(user); + when(serviceImportParseLogic.createResourceFromNodeType(anyString(), any(UploadResourceInfo.class), any(User.class), anyBoolean(), + anyBoolean(), + anyMap(), anyList(), anyBoolean(), any(CsarInfo.class), + anyString(), anyBoolean())).thenReturn(immutablePair); Assertions.assertNotNull( - sIB1.createNodeTypeResourceFromYaml(yamlName, nodeNameValue, user, mapToConvert, - resourceVf, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, - forceCertificationAllowed, csarInfo, isNested)); + sIB1.createNodeTypeResourceFromYaml(yamlName, nodeNameValue, user, mapToConvert, + resourceVf, needLock, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, + forceCertificationAllowed, csarInfo, isNested)); } @Test - public void testCreateRIAndRelationsFromYaml() { + void testCreateRIAndRelationsFromYaml() { String yamlName = "group.yml"; Service service = createServiceObject(true); Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap = new HashMap<>(); @@ -1141,7 +1126,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testCreateServiceInstancesRelations() { + void testCreateServiceInstancesRelations() { String yamlName = "group.yml"; Service service = createServiceObject(true); service.setComponentInstances(creatComponentInstances()); @@ -1158,30 +1143,30 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest when(serviceImportParseLogic.getResourceAfterCreateRelations(any(Resource.class))).thenReturn(newResource); when(serviceImportParseLogic.getComponentFilterAfterCreateRelations()).thenReturn(componentParametersView); when(toscaOperationFacade.getToscaElement(anyString(), any(ComponentParametersView.class))).thenReturn(Either.left(service)); - when(serviceImportParseLogic.findAviableRequiremen(anyString(), - anyString(), any(UploadComponentInstanceInfo.class), any(ComponentInstance.class), - anyString())).thenReturn(Either.left(requirementDefinition)); + when(serviceImportParseLogic.findAvailableRequirement(anyString(), + anyString(), any(UploadComponentInstanceInfo.class), any(ComponentInstance.class), + anyString())).thenReturn(Either.left(requirementDefinition)); when(serviceImportParseLogic.findAvailableCapabilityByTypeOrName(any(RequirementDefinition.class), - any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition); + 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(sIB1 - .createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap)); + .createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap)); } @Test - public void testCreateServiceInstancesRelations_Empty() { + void testCreateServiceInstancesRelations_Empty() { String yamlName = "group.yml"; Service service = createServiceObject(true); service.setComponentInstances(creatComponentInstances()); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>(); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap)); + .createServiceInstancesRelations(user, yamlName, service, uploadResInstancesMap)); } @Test - public void testProcessComponentInstance() { + void testProcessComponentInstance() { String yamlName = "group.yml"; Service service = createServiceObject(true); Resource originResource = createParseResourceObject(false); @@ -1207,13 +1192,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Assertions.assertNotNull(service); sIB1.processComponentInstance(yamlName, service, componentInstancesList, allDataTypes.left().value(), - instProperties, instCapabilties, instRequirements, instDeploymentArtifacts, - instArtifacts, instAttributes, originCompMap, instInputs, instNodeFilter, - uploadComponentInstanceInfo); + instProperties, instCapabilties, instRequirements, instDeploymentArtifacts, + instArtifacts, instAttributes, originCompMap, instInputs, instNodeFilter, + uploadComponentInstanceInfo); } @Test - public void testProcessComponentInstance_null2() { + void testProcessComponentInstance_null2() { String yamlName = "group.yml"; Service service = createServiceObject(true); Resource originResource = createParseResourceObject(false); @@ -1233,13 +1218,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest uploadComponentInstanceInfo.setName("zxjTestImportServiceAb0"); Assertions.assertThrows(ComponentException.class, () -> sIB1.processComponentInstance(yamlName, - service, componentInstancesList, null, instProperties, instCapabilties, - instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, - instInputs, instNodeFilter, uploadComponentInstanceInfo)); + service, componentInstancesList, null, instProperties, instCapabilties, + instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, + instInputs, instNodeFilter, uploadComponentInstanceInfo)); } @Test - public void testAddInputsValuesToRi2() { + void testAddInputsValuesToRi2() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); Map<String, List<UploadPropInfo>> properties = new HashMap<>(); List<UploadPropInfo> uploadPropInfoList = new ArrayList<>(); @@ -1261,12 +1246,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<String, DataTypeDefinition> allDataTypes = new HashMap<>(); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, - currentCompInstance, instInputs, allDataTypes)); + .addInputsValuesToRi(uploadComponentInstanceInfo, resource, originResource, + currentCompInstance, instInputs, allDataTypes)); } @Test - public void testProcessProperty2() { + void testProcessProperty2() { Service resource = createServiceObject(true); List<InputDefinition> inputs = new ArrayList<>(); ComponentInstance currentCompInstance = null; @@ -1296,17 +1281,17 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testProcessGetInput() { + void testProcessGetInput() { List<GetInputValueDataDefinition> getInputValues = new ArrayList<>(); List<InputDefinition> inputs = new ArrayList<>(); GetInputValueDataDefinition getInputIndex = new GetInputValueDataDefinition(); Assertions.assertThrows(ComponentException.class, () -> sIB1.processGetInput(getInputValues, - inputs, getInputIndex)); + inputs, getInputIndex)); } @Test - public void testProcessGetInput_optional() { + void testProcessGetInput_optional() { List<GetInputValueDataDefinition> getInputValues = new ArrayList<>(); List<InputDefinition> inputs = new ArrayList<>(); InputDefinition inputDefinition = new InputDefinition(); @@ -1321,7 +1306,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testAddPropertyValuesToRi() { + void testAddPropertyValuesToRi() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); uploadComponentInstanceInfo.setProperties(getUploadPropInfoProperties()); Resource resource = createParseResourceObject(true); @@ -1339,15 +1324,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<String, DataTypeDefinition> allDataTypes = new HashMap<>(); ResponseFormat responseFormat = new ResponseFormat(); when(serviceImportParseLogic.findInputByName(anyList(), any(GetInputValueDataDefinition.class))) - .thenReturn(inputDefinition); + .thenReturn(inputDefinition); when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(responseFormat); Assertions.assertNotNull( - sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource, - currentCompInstance, instProperties, allDataTypes)); + sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource, + currentCompInstance, instProperties, allDataTypes)); } @Test - public void testAddPropertyValuesToRi_else() { + void testAddPropertyValuesToRi_else() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); Resource resource = createParseResourceObject(true); Resource originResource = createParseResourceObject(false); @@ -1358,13 +1343,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest ResponseFormat responseFormat = new ResponseFormat(); when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(responseFormat); Assertions.assertNotNull( - sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, - instProperties, allDataTypes)); + sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, resource, originResource, currentCompInstance, + instProperties, allDataTypes)); } @Test - public void testAddPropertyValuesToRi2() { + void testAddPropertyValuesToRi2() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); uploadComponentInstanceInfo.setProperties(getUploadPropInfoProperties()); Service service = createServiceObject(true); @@ -1383,14 +1368,14 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest ResponseFormat responseFormat = new ResponseFormat(); when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(responseFormat); when(serviceImportParseLogic.findInputByName(anyList(), any(GetInputValueDataDefinition.class))) - .thenReturn(inputDefinition); + .thenReturn(inputDefinition); Assertions.assertNotNull( - sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, service, originResource, - currentCompInstance, instProperties, allDataTypes)); + sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, service, originResource, + currentCompInstance, instProperties, allDataTypes)); } @Test - public void testAddPropertyValuesToRi2_else() { + void testAddPropertyValuesToRi2_else() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); Service service = createServiceObject(true); Resource originResource = createParseResourceObject(false); @@ -1401,12 +1386,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest ResponseFormat responseFormat = new ResponseFormat(); when(componentsUtils.getResponseFormat(any(ActionStatus.class))).thenReturn(responseFormat); Assertions.assertNotNull( - sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, service, originResource, currentCompInstance, - instProperties, allDataTypes)); + sIB1.addPropertyValuesToRi(uploadComponentInstanceInfo, service, originResource, currentCompInstance, + instProperties, allDataTypes)); } @Test - public void testProcessComponentInstanceCapabilities() { + void testProcessComponentInstanceCapabilities() { Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null; Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>(); UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); @@ -1415,11 +1400,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Resource originResource = createParseResourceObject(false); Assertions.assertNotNull(originResource); sIB1.processComponentInstanceCapabilities(null, instCapabilties, - uploadComponentInstanceInfo, currentCompInstance, originResource); + uploadComponentInstanceInfo, currentCompInstance, originResource); } @Test - public void testProcessComponentInstanceCapabilities_null() { + void testProcessComponentInstanceCapabilities_null() { Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null; Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>(); UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); @@ -1428,11 +1413,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Assertions.assertNotNull(originResource); sIB1.processComponentInstanceCapabilities(null, instCapabilties, uploadComponentInstanceInfo, - currentCompInstance, originResource); + currentCompInstance, originResource); } @Test - public void testUpdateCapabilityPropertiesValues() { + void testUpdateCapabilityPropertiesValues() { Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = null; Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>(); Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>(); @@ -1441,7 +1426,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testUpdatePropertyValues() { + void testUpdatePropertyValues() { List<ComponentInstanceProperty> properties = new ArrayList<>(); Map<String, UploadPropInfo> newProperties = new HashMap<>(); Map<String, DataTypeDefinition> allDataTypes = new HashMap<>(); @@ -1450,31 +1435,32 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testUpdatePropertyValue() { + void testUpdatePropertyValue() { ComponentInstanceProperty property = new ComponentInstanceProperty(); property.setType("services"); UploadPropInfo propertyInfo = new UploadPropInfo(); propertyInfo.setValue("value"); Map<String, DataTypeDefinition> allDataTypes = new HashMap<>(); - when(serviceBusinessLogic.validatePropValueBeforeCreate(any(IPropertyInputCommon.class), anyString(), anyBoolean(), anyMap())).thenReturn("qw"); + when(serviceBusinessLogic.validatePropValueBeforeCreate(any(IPropertyInputCommon.class), anyString(), anyBoolean(), anyMap())).thenReturn( + "qw"); Assertions.assertNotNull( - sIB1.updatePropertyValue(property, propertyInfo, allDataTypes)); + sIB1.updatePropertyValue(property, propertyInfo, allDataTypes)); } @Test - public void testGetOriginResource() { + void testGetOriginResource() { String yamlName = "group.yml"; Map<String, Resource> originCompMap = new HashMap<>(); ComponentInstance currentCompInstance = new ComponentInstance(); currentCompInstance.setComponentUid("currentCompInstance"); when(toscaOperationFacade.getToscaFullElement(anyString())) - .thenReturn(Either.left(createParseResourceObject(true))); + .thenReturn(Either.left(createParseResourceObject(true))); Assertions.assertNotNull( - sIB1.getOriginResource(yamlName, originCompMap, currentCompInstance)); + sIB1.getOriginResource(yamlName, originCompMap, currentCompInstance)); } @Test - public void testHandleSubstitutionMappings2() { + void testHandleSubstitutionMappings2() { Service service = createServiceObject(true); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>(); Assertions.assertNotNull(service); @@ -1483,18 +1469,18 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testUpdateCalculatedCapReqWithSubstitutionMappings() { + void testUpdateCalculatedCapReqWithSubstitutionMappings() { Resource resource = createParseResourceObject(false); resource.setComponentInstances(creatComponentInstances()); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = getUploadResInstancesMap(); when(toscaOperationFacade.deleteAllCalculatedCapabilitiesRequirements(any())).thenReturn(StorageOperationStatus.OK); Assertions.assertNotNull( - sIB1.updateCalculatedCapReqWithSubstitutionMappings(resource, uploadResInstancesMap)); + sIB1.updateCalculatedCapReqWithSubstitutionMappings(resource, uploadResInstancesMap)); } @Test - public void testFillUpdatedInstCapabilitiesRequirements() { + void testFillUpdatedInstCapabilitiesRequirements() { List<ComponentInstance> componentInstances = creatComponentInstances(); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = getUploadResInstancesMap(); Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities = new HashMap<>(); @@ -1502,11 +1488,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Assertions.assertNotNull(componentInstances); sIB1.fillUpdatedInstCapabilitiesRequirements(componentInstances, uploadResInstancesMap, - updatedInstCapabilities, updatedInstRequirement); + updatedInstCapabilities, updatedInstRequirement); } @Test - public void testFillUpdatedInstCapabilities() { + void testFillUpdatedInstCapabilities() { Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilties = new HashMap<>(); Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>(); List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>(); @@ -1524,9 +1510,9 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testFillUpdatedInstRequirements() { + void testFillUpdatedInstRequirements() { Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements = new - HashMap<>(); + HashMap<>(); ComponentInstance instance = new ComponentInstance(); Map<String, List<RequirementDefinition>> requirements = new HashMap<>(); List<RequirementDefinition> requirementDefinitionList = new ArrayList<>(); @@ -1537,14 +1523,14 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest instance.setRequirements(requirements); Map<String, String> requirementsNamesToUpdate = new HashMap<>(); requirementsNamesToUpdate.put("zxjtestimportserviceab0.mme_ipu_vdu.dependency.test", - "requirementsNamesToUpdate"); + "requirementsNamesToUpdate"); Assertions.assertNotNull(instance); sIB1.fillUpdatedInstRequirements(updatedInstRequirements, instance, requirementsNamesToUpdate); } @Test - public void testAddRelationsToRI() { + void testAddRelationsToRI() { String yamlName = "group.yml"; Service service = createServiceObject(true); @@ -1567,11 +1553,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest capabilityDefinition.setOwnerId("6"); ResponseFormat responseFormat = new ResponseFormat(); responseFormat.setStatus(200); - when(serviceImportParseLogic.findAviableRequiremen(anyString(), - anyString(), any(UploadComponentInstanceInfo.class), any(ComponentInstance.class), - anyString())).thenReturn(Either.left(requirementDefinition)); + when(serviceImportParseLogic.findAvailableRequirement(anyString(), + anyString(), any(UploadComponentInstanceInfo.class), any(ComponentInstance.class), + anyString())).thenReturn(Either.left(requirementDefinition)); when(serviceImportParseLogic.findAvailableCapabilityByTypeOrName(any(RequirementDefinition.class), - any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition); + any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition); when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat); Assertions.assertNotNull(service); @@ -1579,7 +1565,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testAddRelationsToRI_null() { + void testAddRelationsToRI_null() { String yamlName = "group.yml"; Service service = createServiceObject(true); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>(); @@ -1589,11 +1575,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List<RequirementCapabilityRelDef> relations = new ArrayList<>(); Assertions.assertThrows(ComponentException.class, () -> sIB1.addRelationsToRI(yamlName, - service, uploadResInstancesMap, componentInstancesList, relations)); + service, uploadResInstancesMap, componentInstancesList, relations)); } @Test - public void testAddRelationToRI() { + void testAddRelationToRI() { String yamlName = "group.yml"; Service service = createServiceObject(true); service.setComponentInstances(creatComponentInstances()); @@ -1607,17 +1593,17 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest capabilityDefinition.setUniqueId("capabilityDefinitionUniqueId"); capabilityDefinition.setOwnerId("capabilityDefinitionOwnerId"); ResponseFormat responseFormat = new ResponseFormat(); - when(serviceImportParseLogic.findAviableRequiremen(anyString(), anyString(), any(UploadComponentInstanceInfo.class), - any(ComponentInstance.class), anyString())).thenReturn(Either.left(requirementDefinition)); + when(serviceImportParseLogic.findAvailableRequirement(anyString(), anyString(), any(UploadComponentInstanceInfo.class), + any(ComponentInstance.class), anyString())).thenReturn(Either.left(requirementDefinition)); when(serviceImportParseLogic.findAvailableCapabilityByTypeOrName(any(RequirementDefinition.class), - any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition); + any(ComponentInstance.class), any(UploadReqInfo.class))).thenReturn(capabilityDefinition); when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat); Assertions.assertNotNull( - sIB1.addRelationToRI(yamlName, service, nodesInfoValue, relations)); + sIB1.addRelationToRI(yamlName, service, nodesInfoValue, relations)); } @Test - public void testAddRelationToRI_null() { + void testAddRelationToRI_null() { String yamlName = "group.yml"; Service service = createServiceObject(true); List<ComponentInstance> componentInstancesList = new ArrayList<>(); @@ -1627,23 +1613,23 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List<RequirementCapabilityRelDef> relations = new ArrayList<>(); when(componentsUtils.getResponseFormat(any(ActionStatus.class), anyString())).thenReturn(responseFormat); Assertions.assertNotNull( - sIB1.addRelationToRI(yamlName, service, nodesInfoValue, relations)); + sIB1.addRelationToRI(yamlName, service, nodesInfoValue, relations)); } @Test - public void testGetResourceAfterCreateRelations() { + void testGetResourceAfterCreateRelations() { Service service = createServiceObject(true); ComponentParametersView componentParametersView = createComponentParametersView(); when(serviceImportParseLogic.getComponentFilterAfterCreateRelations()).thenReturn(componentParametersView); when(toscaOperationFacade.getToscaElement(anyString(), any(ComponentParametersView.class))) - .thenReturn(Either.left(createServiceObject(true))); + .thenReturn(Either.left(createServiceObject(true))); Assertions.assertNotNull( - sIB1.getResourceAfterCreateRelations(service)); + sIB1.getResourceAfterCreateRelations(service)); } @Test - public void testCreateServiceInstances() { + void testCreateServiceInstances() { String yamlName = "group.yml"; Service service = createServiceObject(true); Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>(); @@ -1655,11 +1641,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest nodeNamespaceMap.put("nodeNamespaceMap", resource); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createServiceInstances(yamlName, service, uploadResInstancesMap, nodeNamespaceMap)); + .createServiceInstances(yamlName, service, uploadResInstancesMap, nodeNamespaceMap)); } @Test - public void testCreateAndAddResourceInstance() { + void testCreateAndAddResourceInstance() { UploadComponentInstanceInfo uploadComponentInstanceInfo = getuploadComponentInstanceInfo(); String yamlName = "group.yml"; Resource resource = createParseResourceObject(false); @@ -1671,12 +1657,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<ComponentInstance, Resource> resourcesInstancesMap = new HashMap<>(); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createAndAddResourceInstance(uploadComponentInstanceInfo, yamlName, resource, - nodeNamespaceMap, existingnodeTypeMap, resourcesInstancesMap)); + .createAndAddResourceInstance(uploadComponentInstanceInfo, yamlName, resource, + nodeNamespaceMap, existingnodeTypeMap, resourcesInstancesMap)); } @Test - public void testCreateAndAddResourceInstances() { + void testCreateAndAddResourceInstances() { UploadComponentInstanceInfo uploadComponentInstanceInfo = getuploadComponentInstanceInfo(); String yamlName = "group.yml"; Service service = createServiceObject(true); @@ -1689,12 +1675,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<ComponentInstance, Resource> resourcesInstancesMap = new HashMap<>(); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createAndAddResourceInstance(uploadComponentInstanceInfo, yamlName, service, - nodeNamespaceMap, existingnodeTypeMap, resourcesInstancesMap)); + .createAndAddResourceInstance(uploadComponentInstanceInfo, yamlName, service, + nodeNamespaceMap, existingnodeTypeMap, resourcesInstancesMap)); } @Test - public void testValidateResourceInstanceBeforeCreate() { + void testValidateResourceInstanceBeforeCreate() { String yamlName = "group.yml"; UploadComponentInstanceInfo uploadComponentInstanceInfo = getuploadComponentInstanceInfo(); Resource originResource = createParseResourceObject(true); @@ -1709,13 +1695,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<String, Resource> nodeNamespaceMap = new HashMap<>(); nodeNamespaceMap.put("resources", originResource); when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())) - .thenReturn(Either.left(originResource)); + .thenReturn(Either.left(originResource)); Assertions.assertNotNull( - sIB1.validateResourceInstanceBeforeCreate(yamlName, uploadComponentInstanceInfo, nodeNamespaceMap)); + sIB1.validateResourceInstanceBeforeCreate(yamlName, uploadComponentInstanceInfo, nodeNamespaceMap)); } @Test - public void testHandleServiceNodeTypes() { + void testHandleServiceNodeTypes() { String yamlName = "group.yml"; Service service = createServiceObject(true); String topologyTemplateYaml = getMainTemplateContent("service_import_template.yml"); @@ -1727,23 +1713,23 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest CsarInfo csarInfo = getCsarInfo(); String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())) - .thenReturn(Either.left(createOldResource())); + .thenReturn(Either.left(createOldResource())); Assertions.assertNotNull(service); sIB1.handleServiceNodeTypes(yamlName, service, topologyTemplateYaml, needLock, - nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, - csarInfo, nodeName); + nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, + csarInfo, nodeName); } @Test - public void testValidateResourceNotExisted() { + void testValidateResourceNotExisted() { String type = "org.openecomp.resource.vf"; Assertions.assertThrows(ComponentException.class, () -> sIB1.validateResourceNotExisted(type)); } @Test - public void testHandleNestedVF() { + void testHandleNestedVF() { Service service = createServiceObject(true); Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); @@ -1752,11 +1738,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Assertions.assertThrows(ComponentException.class, () -> sIB1.handleNestedVF(service, - nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName)); + nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName)); } @Test - public void testHandleNestedVfc() { + void testHandleNestedVfc() { Service service = createServiceObject(true); Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); @@ -1765,11 +1751,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Assertions.assertThrows(ComponentException.class, () -> sIB1.handleNestedVfc(service, - nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName)); + nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, csarInfo, nodeName)); } @Test - public void testHandleComplexVfc() { + void testHandleComplexVfc() { Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); Map<String, NodeTypeInfo> nodesInfo = new HashMap<>(); @@ -1777,19 +1763,19 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; String yamlName = "group.yml"; when(serviceImportParseLogic.buildValidComplexVfc(any(CsarInfo.class), anyString(), anyMap())) - .thenReturn(createNewResource()); + .thenReturn(createNewResource()); when(toscaOperationFacade.getFullLatestComponentByToscaResourceName(anyString())) - .thenReturn(Either.left(createNewResource())); + .thenReturn(Either.left(createNewResource())); when(serviceImportParseLogic.validateNestedDerivedFromDuringUpdate(any(Resource.class), any(Resource.class), anyBoolean())) - .thenReturn(Either.left(true)); + .thenReturn(Either.left(true)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .handleComplexVfc(nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, - csarInfo, nodeName, yamlName)); + .handleComplexVfc(nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, + csarInfo, nodeName, yamlName)); } @Test - public void testHandleComplexVfcStatus() { + void testHandleComplexVfcStatus() { Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); Map<String, NodeTypeInfo> nodesInfo = new HashMap<>(); @@ -1797,17 +1783,17 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; String yamlName = "group.yml"; when(serviceImportParseLogic.buildValidComplexVfc(any(CsarInfo.class), anyString(), anyMap())) - .thenReturn(createNewResource()); + .thenReturn(createNewResource()); when(toscaOperationFacade.getFullLatestComponentByToscaResourceName(anyString())) - .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); + .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .handleComplexVfc(nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, - csarInfo, nodeName, yamlName)); + .handleComplexVfc(nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, + csarInfo, nodeName, yamlName)); } @Test - public void testHandleComplexVfc2() { + void testHandleComplexVfc2() { Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); List<ArtifactDefinition> createdArtifacts = new ArrayList<>(); Map<String, NodeTypeInfo> nodesInfo = getNodeTypesInfo(); @@ -1821,12 +1807,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Resource newComplexVfc = createParseResourceObject(true); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .handleComplexVfc(nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, - csarInfo, nodeName, yamlName, oldComplexVfc, newComplexVfc)); + .handleComplexVfc(nodeTypesArtifactsToHandle, createdArtifacts, nodesInfo, + csarInfo, nodeName, yamlName, oldComplexVfc, newComplexVfc)); } @Test - public void testUpdateResourceFromYaml() throws IOException { + void testUpdateResourceFromYaml() throws IOException { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Resource newResource = createNewResource(); Resource oldResource = createOldResource(); @@ -1843,21 +1829,21 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest boolean isNested = true; when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), anyMap(), any(CsarInfo.class), - anyString(), any(Component.class))).thenReturn(getParsedToscaYamlInfo()); + anyString(), any(Component.class))).thenReturn(getParsedToscaYamlInfo()); when(serviceImportParseLogic.prepareResourceForUpdate(any(Resource.class), any(Resource.class), - any(User.class), anyBoolean(), anyBoolean())).thenReturn(oldResource); + any(User.class), anyBoolean(), anyBoolean())).thenReturn(oldResource); when(serviceImportParseLogic.validateCapabilityTypesCreate(any(User.class), any(ICapabilityTypeOperation.class), - any(Resource.class), any(AuditingActionEnum.class), anyBoolean())).thenReturn(Either.left(true)); + any(Resource.class), any(AuditingActionEnum.class), anyBoolean())).thenReturn(Either.left(true)); when(toscaOperationFacade.overrideComponent(any(Resource.class), any(Resource.class))) - .thenReturn(Either.left(newResource)); + .thenReturn(Either.left(newResource)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .updateResourceFromYaml(oldResource, newResource, actionEnum, createdArtifacts, - yamlFileName, yamlFileContent, csarInfo, nodeTypesInfo, - nodeTypesArtifactsToHandle, nodeName, isNested)); + .updateResourceFromYaml(oldResource, newResource, actionEnum, createdArtifacts, + yamlFileName, yamlFileContent, csarInfo, nodeTypesInfo, + nodeTypesArtifactsToHandle, nodeName, isNested)); } @Test - public void testCreateResourceFromYaml() throws IOException { + void testCreateResourceFromYaml() throws IOException { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Resource resource = createParseResourceObject(true); String topologyTemplateYaml = getMainTemplateContent(); @@ -1873,21 +1859,20 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest boolean shouldLock = false; boolean inTransaction = true; - when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), anyMap(), any(CsarInfo.class), - anyString(), any(Component.class))).thenReturn(getParsedToscaYamlInfo()); + anyString(), any(Component.class))).thenReturn(getParsedToscaYamlInfo()); when(serviceBusinessLogic.fetchAndSetDerivedFromGenericType(any(Resource.class))).thenReturn(resource); when(toscaOperationFacade.validateComponentNameExists(anyString(), any(ResourceTypeEnum.class) - , any(ComponentTypeEnum.class))).thenReturn(Either.left(false)); + , any(ComponentTypeEnum.class))).thenReturn(Either.left(false)); when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIB1.createResourceFromYaml(resource, - topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, - nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeName)); + topologyTemplateYaml, yamlName, nodeTypesInfo, csarInfo, + nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeName)); } @Test - public void testCreateResourceAndRIsFromYaml() throws IOException { + void testCreateResourceAndRIsFromYaml() throws IOException { String yamlName = "group.yml"; String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Resource resource = createParseResourceObject(true); @@ -1908,24 +1893,24 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest boolean shouldLock = false; boolean inTransaction = true; when(serviceBusinessLogic.fetchAndSetDerivedFromGenericType(any(Resource.class))) - .thenReturn(resource); + .thenReturn(resource); when(serviceBusinessLogic.lockComponentByName(anyString(), any(), anyString())) - .thenReturn(Either.left(true)); + .thenReturn(Either.left(true)); when(toscaOperationFacade.validateComponentNameExists(anyString(), any(ResourceTypeEnum.class) - , any(ComponentTypeEnum.class))).thenReturn(Either.left(false)); + , any(ComponentTypeEnum.class))).thenReturn(Either.left(false)); when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(Either.left(resource)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createResourceAndRIsFromYaml(yamlName, resource, parsedToscaYamlInfo, actionEnum, - isNormative, createdArtifacts, topologyTemplateYaml, nodeTypesInfo, csarInfo, - nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeName)); + .createResourceAndRIsFromYaml(yamlName, resource, parsedToscaYamlInfo, actionEnum, + isNormative, createdArtifacts, topologyTemplateYaml, nodeTypesInfo, csarInfo, + nodeTypesArtifactsToCreate, shouldLock, inTransaction, nodeName)); } @Test - public void testCreateGroupsOnResource2() { + void testCreateGroupsOnResource2() { Resource resource = createParseResourceObject(false); Map<String, GroupDefinition> groups = null; List<GroupDefinition> groupDefinitionList = new ArrayList<>(); @@ -1933,14 +1918,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest groupDefinition.setUniqueId("groupDefinitionUniqueId"); groupDefinition.setName("groupDefinition"); groupDefinitionList.add(groupDefinition); - when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())) - .thenReturn(Either.left(true)); - Assertions.assertNotNull( - sIB1.createGroupsOnResource(resource, groups)); + Assertions.assertNotNull(sIB1.createGroupsOnResource(resource, groups)); } @Test - public void testCreateGroupsOnResource2_null() { + void testCreateGroupsOnResource2_null() { Resource resource = createParseResourceObject(false); Map<String, GroupDefinition> groups = null; @@ -1949,29 +1931,21 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testUpdateGroupsMembersUsingResource2() { + void testUpdateGroupsMembersUsingResource2() { Resource resource = createParseResourceObject(true); Map<String, GroupDefinition> groups = getGroups(); - when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())) - .thenReturn(Either.left(true)); - Assertions.assertNotNull( - sIB1.updateGroupsMembersUsingResource(groups, resource)); - + Assertions.assertNotNull(sIB1.updateGroupsMembersUsingResource(groups, resource)); } @Test - public void testUpdateGroupsMembersUsingResource_left2() { + void testUpdateGroupsMembersUsingResource_left2() { Resource resource = createParseResourceObject(true); Map<String, GroupDefinition> groups = getGroups(); - when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())) - .thenReturn(Either.left(true)); - Assertions.assertNotNull( - sIB1.updateGroupsMembersUsingResource(groups, resource)); - + Assertions.assertNotNull(sIB1.updateGroupsMembersUsingResource(groups, resource)); } @Test - public void testUpdateGroupMembers() throws IOException { + void testUpdateGroupMembers() throws IOException { Map<String, GroupDefinition> groups = new HashMap<>(); GroupDefinition updatedGroupDefinition = new GroupDefinition(); Resource component = createParseResourceObject(true); @@ -1985,7 +1959,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testUpdateGroupMembers_null() throws IOException { + void testUpdateGroupMembers_null() throws IOException { Map<String, GroupDefinition> groups = new HashMap<>(); GroupDefinition updatedGroupDefinition = new GroupDefinition(); Resource component = createParseResourceObject(true); @@ -1995,61 +1969,61 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest members.put("zxjTestImportServiceAb", getGroupsYaml()); Assertions.assertThrows(ComponentException.class, () -> sIB1.updateGroupMembers(groups, - updatedGroupDefinition, component, componentInstances, groupName, members)); + updatedGroupDefinition, component, componentInstances, groupName, members)); } @Test - public void setCreateResourceTransaction() { + void setCreateResourceTransaction() { Resource resource = createParseResourceObject(false); resource.setComponentType(ComponentTypeEnum.RESOURCE); boolean isNormative = true; when(toscaOperationFacade.validateComponentNameExists(anyString(), any(), any())) - .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); + .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST)); Assertions.assertThrows(ComponentException.class, () -> sIB1.createResourceTransaction(resource, - user, isNormative)); + user, isNormative)); } @Test - public void setCreateResourceTransaction_leftTrue() { + void setCreateResourceTransaction_leftTrue() { Resource resource = createParseResourceObject(false); resource.setComponentType(ComponentTypeEnum.RESOURCE); boolean isNormative = true; when(toscaOperationFacade.validateComponentNameExists(anyString(), any(), any())) - .thenReturn(Either.left(true)); + .thenReturn(Either.left(true)); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createResourceTransaction(resource, user, isNormative)); + .createResourceTransaction(resource, user, isNormative)); } @Test - public void setCreateResourceTransaction_Left() { + void setCreateResourceTransaction_Left() { Resource resource = createParseResourceObject(false); resource.setComponentType(ComponentTypeEnum.RESOURCE); when(toscaOperationFacade.validateComponentNameExists(anyString(), any(), any())) - .thenReturn(Either.left(false)); + .thenReturn(Either.left(false)); when(toscaOperationFacade.createToscaComponent(any(Resource.class))).thenReturn(Either.left(resource)); Assertions.assertNotNull( - sIB1.createResourceTransaction(resource, user, false)); + sIB1.createResourceTransaction(resource, user, false)); } @Test - public void testUpdateExistingResourceByImport() { + void testUpdateExistingResourceByImport() { Resource newResource = createNewResource(); Resource oldResource = createOldResource(); when(serviceImportParseLogic.prepareResourceForUpdate(any(Resource.class), any(Resource.class), - any(User.class), anyBoolean(), anyBoolean())).thenReturn(oldResource); + any(User.class), anyBoolean(), anyBoolean())).thenReturn(oldResource); when(serviceImportParseLogic.validateCapabilityTypesCreate(any(User.class), any(ICapabilityTypeOperation.class), - any(Resource.class), any(AuditingActionEnum.class), anyBoolean())).thenReturn(Either.left(true)); + any(Resource.class), any(AuditingActionEnum.class), anyBoolean())).thenReturn(Either.left(true)); when(toscaOperationFacade.overrideComponent(any(Resource.class), any(Resource.class))) - .thenReturn(Either.left(newResource)); + .thenReturn(Either.left(newResource)); Assertions.assertNotNull( - sIB1.updateExistingResourceByImport(newResource, oldResource, user, - true, false, true)); + sIB1.updateExistingResourceByImport(newResource, oldResource, user, + true, false, true)); } @Test - public void testCreateNewResourceToOldResource() { + void testCreateNewResourceToOldResource() { Resource newResource = createNewResource(); Resource oldResource = createOldResource(); @@ -2058,7 +2032,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testCreateResourcesFromYamlNodeTypesList() { + void testCreateResourcesFromYamlNodeTypesList() { String yamlName = "group.yml"; Service service = createServiceObject(true); Map<String, Object> mappedToscaTemplate = new HashMap<>(); @@ -2069,24 +2043,24 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest CsarInfo csarInfo = getCsarInfo(); Assertions.assertThrows(ComponentException.class, () -> sIB1 - .createResourcesFromYamlNodeTypesList(yamlName, service, mappedToscaTemplate, needLock, - nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo)); + .createResourcesFromYamlNodeTypesList(yamlName, service, mappedToscaTemplate, needLock, + nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo)); } @Test - public void testCreateNodeTypes() { + void testCreateNodeTypes() { String yamlName = "group.yml"; Service service = createServiceObject(true); boolean needLock = true; Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List<ArtifactDefinition> artifactDefinitions = new ArrayList<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setArtifactName("artifactName"); artifactDefinitions.add(artifactDefinition); enumListEnumMap.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, - artifactDefinitions); + artifactDefinitions); nodeTypesArtifactsToHandle.put("nodeTyp", enumListEnumMap); List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>(); Map<String, NodeTypeInfo> nodeTypesInfo = getNodeTypesInfo(); @@ -2096,28 +2070,28 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest NodeTypeInfo nodeTypeInfo = new NodeTypeInfo(); nodeTypesInfo.put("nodeTyp", nodeTypeInfo); nodeTypes.put("org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test", - nodeTypeInfo); + nodeTypeInfo); Assertions.assertThrows(ComponentException.class, () -> sIB1.createNodeTypes(yamlName, - service, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, - nodeTypesInfo, csarInfo, mapToConvert, nodeTypes)); + service, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, + nodeTypesInfo, csarInfo, mapToConvert, nodeTypes)); } @Test - public void testCreateNodeTypesElse() { + void testCreateNodeTypesElse() { String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; String yamlName = "group.yml"; Service service = createServiceObject(true); boolean needLock = true; Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List<ArtifactDefinition> artifactDefinitions = new ArrayList<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); artifactDefinition.setArtifactName("artifactName"); artifactDefinitions.add(artifactDefinition); enumListEnumMap.put(ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE, - artifactDefinitions); + artifactDefinitions); nodeTypesArtifactsToHandle.put("nodeTyp", enumListEnumMap); List<ArtifactDefinition> nodeTypesNewCreatedArtifacts = new ArrayList<>(); Map<String, NodeTypeInfo> nodeTypesInfo = getNodeTypesInfo(); @@ -2131,15 +2105,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map<String, Object> nodeTypes = new HashMap<>(); NodeTypeInfo nodeTypeInfo = new NodeTypeInfo(); nodeTypes.put("org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test", - nodeTypeInfo); + nodeTypeInfo); when(serviceImportParseLogic.createNodeTypeResourceFromYaml(anyString(), any(Map.Entry.class), any(User.class), - anyMap(), any(Service.class), anyBoolean(), anyMap(), anyList(), anyBoolean(), any(CsarInfo.class), - anyBoolean())).thenReturn(getResourceCreated()); + anyMap(), any(Service.class), anyBoolean(), anyMap(), anyList(), anyBoolean(), any(CsarInfo.class), + anyBoolean())).thenReturn(getResourceCreated()); Assertions.assertNotNull(service); sIB1.createNodeTypes(yamlName, - service, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, - nodeTypesInfo, csarInfo, mapToConvert, nodeTypes); + service, needLock, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, + nodeTypesInfo, csarInfo, mapToConvert, nodeTypes); } @@ -2232,7 +2206,6 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest return propertyList; } - protected Map<String, NodeTypeInfo> getNodeTypesInfo() { Map<String, NodeTypeInfo> nodeTypesInfo = new HashMap<>(); NodeTypeInfo nodeTypeInfo = new NodeTypeInfo(); @@ -2319,13 +2292,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest privateMethod = AbstractValidationsServlet.class.getDeclaredMethod("getCsarFromPayload", UploadResourceInfo.class); privateMethod.setAccessible(true); returnValue = (Map<String, byte[]>) privateMethod.invoke(servlet, resourceInfo); - } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } catch (IOException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | + InvocationTargetException e) { e.printStackTrace(); } return returnValue; } - protected List<ComponentInstance> creatComponentInstances() { List<ComponentInstance> componentInstances = new ArrayList<>(); ComponentInstance componentInstance = new ComponentInstance(); @@ -2405,18 +2378,6 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest return csarInfo; } - public static String loadFileNameToJsonString(String fileName) throws IOException { - String sourceDir = "src/test/resources/normativeTypes"; - return loadFileNameToJsonString(sourceDir, fileName); - } - - private static String loadFileNameToJsonString(String sourceDir, String fileName) throws IOException { - java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir, fileName); - byte[] fileContent = Files.readAllBytes(filePath); - return new String(fileContent); - } - - protected CsarUtils.NonMetaArtifactInfo getNonMetaArtifactInfo() { String artifactName = "artifactName", path = "/src/test/resources/valid_vf.csar", artifactType = "AAI_SERVICE_MODEL"; ArtifactGroupTypeEnum artifactGroupType = ArtifactGroupTypeEnum.TOSCA; @@ -2432,14 +2393,14 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String artifactUniqueId = "artifactUniqueId"; boolean isFromCsar = true; CsarUtils.NonMetaArtifactInfo nonMetaArtifactInfo = new CsarUtils.NonMetaArtifactInfo(artifactName, - path, artifactType, artifactGroupType, data, artifactUniqueId, isFromCsar); + path, artifactType, artifactGroupType, data, artifactUniqueId, isFromCsar); return nonMetaArtifactInfo; } protected void assertComponentException(ComponentException e, ActionStatus expectedStatus, String... variables) { ResponseFormat actualResponse = e.getResponseFormat() != null ? - e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()); + e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()); assertParseResponse(actualResponse, expectedStatus, variables); } 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 d309ccedd8..5dfa28765b 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 @@ -15,7 +15,27 @@ */ package org.openecomp.sdc.be.components.impl; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + import fj.data.Either; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.servlet.ServletContext; import org.junit.jupiter.api.BeforeEach; import org.mockito.Mockito; import org.openecomp.sdc.ElementOperationMock; @@ -30,8 +50,23 @@ import org.openecomp.sdc.be.components.path.ForwardingPathValidator; import org.openecomp.sdc.be.components.validation.NodeFilterValidator; import org.openecomp.sdc.be.components.validation.ServiceDistributionValidation; import org.openecomp.sdc.be.components.validation.UserValidations; -import org.openecomp.sdc.be.components.validation.component.*; -import org.openecomp.sdc.be.components.validation.service.*; +import org.openecomp.sdc.be.components.validation.component.ComponentContactIdValidator; +import org.openecomp.sdc.be.components.validation.component.ComponentDescriptionValidator; +import org.openecomp.sdc.be.components.validation.component.ComponentFieldValidator; +import org.openecomp.sdc.be.components.validation.component.ComponentIconValidator; +import org.openecomp.sdc.be.components.validation.component.ComponentNameValidator; +import org.openecomp.sdc.be.components.validation.component.ComponentProjectCodeValidator; +import org.openecomp.sdc.be.components.validation.component.ComponentTagsValidator; +import org.openecomp.sdc.be.components.validation.component.ComponentValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceCategoryValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceEnvironmentContextValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceFieldValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceFunctionValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceInstantiationTypeValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceNamingPolicyValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceRoleValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceTypeValidator; +import org.openecomp.sdc.be.components.validation.service.ServiceValidator; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.cassandra.AuditCassandraDao; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao; @@ -39,11 +74,33 @@ import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; -import org.openecomp.sdc.be.externalapi.servlet.representation.*; +import org.openecomp.sdc.be.externalapi.servlet.representation.AbstractResourceInfo; +import org.openecomp.sdc.be.externalapi.servlet.representation.AbstractTemplateInfo; +import org.openecomp.sdc.be.externalapi.servlet.representation.ArtifactMetadata; +import org.openecomp.sdc.be.externalapi.servlet.representation.CopyServiceInfo; +import org.openecomp.sdc.be.externalapi.servlet.representation.ReplaceVNFInfo; +import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceInstanceMetadata; import org.openecomp.sdc.be.facade.operations.CatalogOperation; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.WebAppContextWrapper; -import org.openecomp.sdc.be.model.*; +import org.openecomp.sdc.be.model.ArtifactDefinition; +import org.openecomp.sdc.be.model.CapabilityDefinition; +import org.openecomp.sdc.be.model.Component; +import org.openecomp.sdc.be.model.ComponentInstance; +import org.openecomp.sdc.be.model.GroupDefinition; +import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.NodeTypeInfo; +import org.openecomp.sdc.be.model.ParsedToscaYamlInfo; +import org.openecomp.sdc.be.model.RequirementCapabilityRelDef; +import org.openecomp.sdc.be.model.RequirementDefinition; +import org.openecomp.sdc.be.model.Resource; +import org.openecomp.sdc.be.model.Service; +import org.openecomp.sdc.be.model.UploadCapInfo; +import org.openecomp.sdc.be.model.UploadComponentInstanceInfo; +import org.openecomp.sdc.be.model.UploadNodeFilterInfo; +import org.openecomp.sdc.be.model.UploadReqInfo; +import org.openecomp.sdc.be.model.UploadServiceInfo; +import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.category.CategoryDefinition; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.NodeFilterOperation; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; @@ -59,22 +116,24 @@ import org.openecomp.sdc.common.api.UploadArtifactInfo; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.web.context.WebApplicationContext; -import javax.servlet.ServletContext; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.*; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.when; - public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicMock { - protected ServiceImportBusinessLogic sIB1; + protected static final String SERVICE_CATEGORY = "Mobility"; protected static final String INSTANTIATION_TYPE = "A-la-carte"; + protected static final String CERTIFIED_VERSION = "1.0"; + protected static final String UNCERTIFIED_VERSION = "0.2"; + protected static final String COMPONNET_ID = "myUniqueId"; + protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service"; + protected static final String SERVICE_ROLE = JsonPresentationFields.SERVICE_ROLE.getPresentation(); + protected static final String SERVICE_TYPE = JsonPresentationFields.SERVICE_TYPE.getPresentation(); + protected static final String SERVICE_FUNCTION = JsonPresentationFields.SERVICE_FUNCTION.getPresentation(); + private static final String RESOURCE_NAME = "My-Resource_Name with space"; + private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name"; + private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3"; + private static final String RESOURCE_SUBCATEGORY = "Router"; protected final ServletContext servletContext = Mockito.mock(ServletContext.class); + protected final ComponentValidator componentValidator = Mockito.mock(ComponentValidator.class); + protected ServiceImportBusinessLogic sIB1; protected UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class); protected WebAppContextWrapper webAppContextWrapper = Mockito.mock(WebAppContextWrapper.class); protected WebApplicationContext webAppContext = Mockito.mock(WebApplicationContext.class); @@ -93,16 +152,7 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM protected ResourceAdminEvent auditArchive2 = Mockito.mock(ResourceAdminEvent.class); protected ResourceAdminEvent auditRestore = Mockito.mock(ResourceAdminEvent.class); protected ServiceImportParseLogic serviceImportParseLogic = Mockito.mock(ServiceImportParseLogic.class); - IElementOperation mockElementDao = new ElementOperationMock(); - DistributionEngine distributionEngine = Mockito.mock(DistributionEngine.class); - ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class); - ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class); - ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class); - UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class); - NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class); - NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class); protected ServiceTypeValidator serviceTypeValidator = new ServiceTypeValidator(componentsUtils); - protected ServiceCategoryValidator serviceCategoryValidator = new ServiceCategoryValidator(componentsUtils, mockElementDao); protected ServiceRoleValidator serviceRoleValidator = new ServiceRoleValidator(componentsUtils); protected ServiceFunctionValidator serviceFunctionValidator = new ServiceFunctionValidator(componentsUtils); protected ServiceInstantiationTypeValidator serviceInstantiationTypeValidator = new ServiceInstantiationTypeValidator(componentsUtils); @@ -112,24 +162,18 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM protected ComponentContactIdValidator componentContactIdValidator = new ComponentContactIdValidator(componentsUtils); protected ComponentTagsValidator componentTagsValidator = new ComponentTagsValidator(componentsUtils); protected ComponentNameValidator componentNameValidator = new ComponentNameValidator(componentsUtils, toscaOperationFacade); - protected final ComponentValidator componentValidator = Mockito.mock(ComponentValidator.class); - protected ServiceValidator serviceValidator = createServiceValidator(); - protected User user = null; protected Resource genericService = null; - - private static final String RESOURCE_NAME = "My-Resource_Name with space"; - private static final String RESOURCE_TOSCA_NAME = "My-Resource_Tosca_Name"; - private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3"; - private static final String RESOURCE_SUBCATEGORY = "Router"; - protected static final String CERTIFIED_VERSION = "1.0"; - protected static final String UNCERTIFIED_VERSION = "0.2"; - protected static final String COMPONNET_ID = "myUniqueId"; - protected static final String GENERIC_SERVICE_NAME = "org.openecomp.resource.abstract.nodes.service"; - - protected static final String SERVICE_ROLE = JsonPresentationFields.SERVICE_ROLE.getPresentation(); - protected static final String SERVICE_TYPE = JsonPresentationFields.SERVICE_TYPE.getPresentation(); - protected static final String SERVICE_FUNCTION = JsonPresentationFields.SERVICE_FUNCTION.getPresentation(); + IElementOperation mockElementDao = new ElementOperationMock(); + protected ServiceCategoryValidator serviceCategoryValidator = new ServiceCategoryValidator(componentsUtils, mockElementDao); + protected ServiceValidator serviceValidator = createServiceValidator(); + DistributionEngine distributionEngine = Mockito.mock(DistributionEngine.class); + ServiceDistributionValidation serviceDistributionValidation = Mockito.mock(ServiceDistributionValidation.class); + ComponentInstanceBusinessLogic componentInstanceBusinessLogic = Mockito.mock(ComponentInstanceBusinessLogic.class); + ForwardingPathValidator forwardingPathValidator = Mockito.mock(ForwardingPathValidator.class); + UiComponentDataConverter uiComponentDataConverter = Mockito.mock(UiComponentDataConverter.class); + NodeFilterOperation serviceFilterOperation = Mockito.mock(NodeFilterOperation.class); + NodeFilterValidator serviceFilterValidator = Mockito.mock(NodeFilterValidator.class); public ServiceImportBussinessLogicBaseTestSetup() { @@ -137,14 +181,14 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM protected ServiceValidator createServiceValidator() { List<ComponentFieldValidator> componentFieldValidators = Arrays.asList(componentContactIdValidator, - componentDescriptionValidator, - componentIconValidator, componentNameValidator, - new ComponentProjectCodeValidator(componentsUtils), - componentTagsValidator); + componentDescriptionValidator, + componentIconValidator, componentNameValidator, + new ComponentProjectCodeValidator(componentsUtils), + componentTagsValidator); List<ServiceFieldValidator> serviceFieldValidators = Arrays.asList(serviceCategoryValidator, new ServiceEnvironmentContextValidator(), - serviceInstantiationTypeValidator, new ServiceNamingPolicyValidator(componentsUtils), - serviceRoleValidator, serviceTypeValidator); + serviceInstantiationTypeValidator, new ServiceNamingPolicyValidator(componentsUtils), + serviceRoleValidator, serviceTypeValidator); return new ServiceValidator(componentsUtils, componentFieldValidators, serviceFieldValidators); } @@ -162,12 +206,10 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM user.setRole(Role.ADMIN.name()); when(mockUserAdmin.getUser("jh0003", false)).thenReturn(user); - when(userValidations.validateUserExists(eq("jh0003"))).thenReturn(user); + when(userValidations.validateUserExists("jh0003")).thenReturn(user); when(userValidations.validateUserNotEmpty(eq(user), anyString())).thenReturn(user); -// when(userValidations.validateUserRole(user)) // Servlet Context attributes when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager); -// when(servletContext.getAttribute(Constants.SERVICE_OPERATION_MANAGER)).thenReturn(new ServiceOperation()); when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper); when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext); when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao); @@ -176,7 +218,8 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM when(catalogOperation.updateCatalog(Mockito.any(), Mockito.any())).thenReturn(ActionStatus.OK); // artifact bussinesslogic ArtifactDefinition artifactDef = new ArtifactDefinition(); - when(artifactBl.createArtifactPlaceHolderInfo(Mockito.any(), Mockito.anyString(), Mockito.anyMap(), Mockito.any(User.class), Mockito.any(ArtifactGroupTypeEnum.class))).thenReturn(artifactDef); + when(artifactBl.createArtifactPlaceHolderInfo(Mockito.any(), Mockito.anyString(), Mockito.anyMap(), Mockito.any(User.class), + Mockito.any(ArtifactGroupTypeEnum.class))).thenReturn(artifactDef); // createService Service serviceResponse = createServiceObject(true); @@ -205,18 +248,15 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM Either<Resource, StorageOperationStatus> findLatestGeneric = Either.left(genericService); when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_SERVICE_NAME)).thenReturn(findLatestGeneric); - when(serviceImportParseLogic.isArtifactDeletionRequired(anyString(),any(),anyBoolean())).thenReturn(true); - Either<Boolean, ResponseFormat> validateCGD = Either.left(true); - when(serviceImportParseLogic.validateCyclicGroupsDependencies(any())).thenReturn(validateCGD); + when(serviceImportParseLogic.isArtifactDeletionRequired(anyString(), any(), anyBoolean())).thenReturn(true); sIB1 = new ServiceImportBusinessLogic(elementDao, groupOperation, groupInstanceOperation, - groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, - artifactBl, distributionEngine, componentInstanceBusinessLogic, - serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter, serviceFilterOperation, - serviceFilterValidator, artifactToscaOperation, componentContactIdValidator, - componentNameValidator, componentTagsValidator, componentValidator, - componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator); - + groupTypeOperation, groupBusinessLogic, interfaceOperation, interfaceLifecycleTypeOperation, + artifactBl, distributionEngine, componentInstanceBusinessLogic, + serviceDistributionValidation, forwardingPathValidator, uiComponentDataConverter, serviceFilterOperation, + serviceFilterValidator, artifactToscaOperation, componentContactIdValidator, + componentNameValidator, componentTagsValidator, componentValidator, + componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator); mockAbstract(); @@ -239,10 +279,7 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM List<String> tgs = new ArrayList<>(); tgs.add(service.getName()); service.setTags(tgs); - // service.setVendorName("Motorola"); - // service.setVendorRelease("1.0.0"); service.setIcon("defaulticon"); - // service.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); service.setContactId("aa1234"); service.setProjectCode("12345"); service.setEcompGeneratedNaming(true); @@ -267,7 +304,6 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM categories.add(category); resource.setCategories(categories); - resource.setDescription("description"); List<String> tgs = new ArrayList<>(); tgs.add(resource.getName()); @@ -276,7 +312,6 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM resource.setContactId("aa1234"); resource.setProjectCode("12345"); - if (afterCreate) { resource.setVersion("0.1"); resource.setUniqueId(resource.getName() + ":" + resource.getVersion()); @@ -285,8 +320,8 @@ public class ServiceImportBussinessLogicBaseTestSetup extends BaseBusinessLogicM } return resource; } - -protected Resource createParseResourceObject(boolean afterCreate) { + + protected Resource createParseResourceObject(boolean afterCreate) { Resource resource = new Resource(); resource.setName(RESOURCE_NAME); resource.setToscaResourceName(RESOURCE_TOSCA_NAME); @@ -304,7 +339,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { resource.setContactId("ya5467"); resource.setIcon("defaulticon"); Map<String, List<RequirementDefinition>> requirements = new HashMap<>(); - List<RequirementDefinition> requirementDefinitionList= new ArrayList<>(); + List<RequirementDefinition> requirementDefinitionList = new ArrayList<>(); requirements.put("test", requirementDefinitionList); resource.setRequirements(requirements); @@ -312,13 +347,14 @@ protected Resource createParseResourceObject(boolean afterCreate) { resource.setName(resource.getName()); resource.setVersion("0.1"); resource.setUniqueId(resource.getName() - .toLowerCase() + ":" + resource.getVersion()); + .toLowerCase() + ":" + resource.getVersion()); resource.setCreatorUserId(user.getUserId()); resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName()); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); } return resource; } + protected Resource setupGenericServiceMock() { Resource genericService = new Resource(); genericService.setVersion("1.0"); @@ -331,11 +367,11 @@ protected Resource createParseResourceObject(boolean afterCreate) { Map<String, GroupDefinition> groups = new HashMap<>(); GroupDefinition groupDefinition = new GroupDefinition(); groupDefinition.setName("groupDefinitionName"); - groups.put("groupsMap",groupDefinition); + groups.put("groupsMap", groupDefinition); return groups; } - protected UploadComponentInstanceInfo getuploadComponentInstanceInfo(){ + protected UploadComponentInstanceInfo getuploadComponentInstanceInfo() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); uploadComponentInstanceInfo.setType("resources"); Collection<String> directives = new Collection<String>() { @@ -413,7 +449,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { uploadReqInfo.setNode("zxjTestImportServiceAb"); uploadReqInfo.setCapabilityName("tosca.capabilities.Node"); uploadReqInfoList.add(uploadReqInfo); - requirements.put("requirements",uploadReqInfoList); + requirements.put("requirements", uploadReqInfoList); uploadNodeFilterInfo.setName("mme_ipu_vdu.virtualbinding"); uploadComponentInstanceInfo.setCapabilities(getCapabilities()); uploadComponentInstanceInfo.setRequirements(requirements); @@ -421,18 +457,18 @@ protected Resource createParseResourceObject(boolean afterCreate) { return uploadComponentInstanceInfo; } - protected Map<String, List<UploadCapInfo>> getCapabilities(){ + protected Map<String, List<UploadCapInfo>> getCapabilities() { List<UploadCapInfo> uploadCapInfoList = new ArrayList<>(); UploadCapInfo uploadCapInfo = new UploadCapInfo(); uploadCapInfo.setNode("tosca.nodes.Root"); uploadCapInfo.setName("mme_ipu_vdu.dependency"); uploadCapInfoList.add(uploadCapInfo); Map<String, List<UploadCapInfo>> uploadCapInfoMap = new HashMap<>(); - uploadCapInfoMap.put("tosca.capabilities.Node",uploadCapInfoList); + uploadCapInfoMap.put("tosca.capabilities.Node", uploadCapInfoList); return uploadCapInfoMap; } - protected List<ComponentInstance> creatComponentInstances(){ + protected List<ComponentInstance> creatComponentInstances() { List<ComponentInstance> componentInstances = new ArrayList<>(); ComponentInstance componentInstance = new ComponentInstance(); Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>(); @@ -440,14 +476,14 @@ protected Resource createParseResourceObject(boolean afterCreate) { CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); capabilityDefinition.setName("mme_ipu_vdu.feature"); capabilityDefinitionList.add(capabilityDefinition); - capabilities.put("tosca.capabilities.Node",capabilityDefinitionList); + capabilities.put("tosca.capabilities.Node", capabilityDefinitionList); Map<String, List<RequirementDefinition>> requirements = new HashMap<>(); List<RequirementDefinition> requirementDefinitionList = new ArrayList<>(); RequirementDefinition requirementDefinition = new RequirementDefinition(); requirementDefinition.setName("zxjtestimportserviceab0.mme_ipu_vdu.dependency.test"); requirementDefinitionList.add(requirementDefinition); - requirements.put("tosca.capabilities.Node",requirementDefinitionList); + requirements.put("tosca.capabilities.Node", requirementDefinitionList); componentInstance.setRequirements(requirements); componentInstance.setCapabilities(capabilities); componentInstance.setUniqueId("uniqueId"); @@ -457,7 +493,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { return componentInstances; } - protected UploadComponentInstanceInfo createUploadComponentInstanceInfo(){ + protected UploadComponentInstanceInfo createUploadComponentInstanceInfo() { UploadComponentInstanceInfo uploadComponentInstanceInfo = new UploadComponentInstanceInfo(); uploadComponentInstanceInfo.setName("UploadComponentInstanceInfo"); return uploadComponentInstanceInfo; @@ -469,7 +505,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { checkCreateFile(); } - private void checkCreateAbstract(){ + private void checkCreateAbstract() { AbstractResourceInfo abstractResourceInfo = new AbstractResourceInfo(); List<RequirementCapabilityRelDef> componentInstancesRelations = new ArrayList<>(); abstractResourceInfo.setComponentInstancesRelations(componentInstancesRelations); @@ -519,7 +555,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { getReplaceVNFInfo.getRealVNFComponentInstance(); } - private void checkCreateOther(){ + private void checkCreateOther() { ResourceInstanceMetadata resourceInstanceMetadata = new ResourceInstanceMetadata(); List<ArtifactMetadata> artifacts = new ArrayList<>(); resourceInstanceMetadata.setArtifacts(artifacts); @@ -571,7 +607,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { uploadServiceInfo.setPayloadData("payloadData"); } - protected void checkGetUploadServiceInfo(){ + protected void checkGetUploadServiceInfo() { UploadServiceInfo uploadServiceInfo = new UploadServiceInfo(); List<String> tags = new ArrayList<>(); List<CategoryDefinition> categories = new ArrayList<>(); @@ -632,7 +668,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { getCsfy.getNodeName(); } - protected CsarInfo getCsarInfo () throws IOException { + protected CsarInfo getCsarInfo() throws IOException { String csarUuid = "0010"; User user = new User(); Map<String, byte[]> csar = crateCsarFromPayload(); @@ -640,7 +676,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { String mainTemplateName = "mainTemplateName"; String mainTemplateContent = getMainTemplateContent(); final Service service = createServiceObject(false); - CsarInfo csarInfo = new CsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false); + CsarInfo csarInfo = new CsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false); return csarInfo; } @@ -648,7 +684,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { String payloadName = "valid_vf.csar"; byte[] data = new byte[1024]; Map<String, byte[]> returnValue = new HashMap<>(); - returnValue.put(payloadName,data); + returnValue.put(payloadName, data); return returnValue; } @@ -679,7 +715,7 @@ protected Resource createParseResourceObject(boolean afterCreate) { protected void assertComponentException(ComponentException e, ActionStatus expectedStatus, String... variables) { ResponseFormat actualResponse = e.getResponseFormat() != null ? - e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()); + e.getResponseFormat() : componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()); assertResponse(actualResponse, expectedStatus, variables); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java index 368b3886dd..d16dc23905 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java @@ -37,12 +37,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.NoSuchElementException; -import java.util.Set; import org.apache.commons.collections.map.HashedMap; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.jupiter.api.Assertions; @@ -57,13 +55,10 @@ import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction; import org.openecomp.sdc.be.dao.api.ActionStatus; -import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterPropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; @@ -90,7 +85,6 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.UploadCapInfo; import org.openecomp.sdc.be.model.UploadComponentInstanceInfo; import org.openecomp.sdc.be.model.UploadNodeFilterInfo; -import org.openecomp.sdc.be.model.UploadNodeFilterPropertyInfo; import org.openecomp.sdc.be.model.UploadPropInfo; import org.openecomp.sdc.be.model.UploadReqInfo; import org.openecomp.sdc.be.model.User; @@ -374,27 +368,6 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet } @Test - void testIsfillGroupMemebersRecursivlyStopCondition() { - String groupName = "groupName"; - Map<String, GroupDefinition> allGroups = new HashMap<>(); - Set<String> allGroupMembers = new HashSet<>(); - Assertions.assertTrue(testSubject.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)); - } - - @Test - void testIsfillGroupMemebersRecursivlyStopCondition2() { - String groupName = "groupName"; - Map<String, GroupDefinition> allGroups = new HashMap<>(); - GroupDefinition groupDefinition = new GroupDefinition(); - Map<String, String> members = new HashMap<>(); - members.put("members", "members"); - groupDefinition.setMembers(members); - allGroups.put(groupName, groupDefinition); - Set<String> allGroupMembers = new HashSet<>(); - Assertions.assertTrue(testSubject.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)); - } - - @Test void testBuildValidComplexVfc() { Resource resource = createParseResourceObject(true); String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; @@ -871,7 +844,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet String capName = "capName"; Assertions.assertNotNull( - testSubject.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName)); + testSubject.findAvailableRequirement(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName)); } @Test @@ -894,7 +867,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet String capName = uniqueId; Assertions.assertNotNull( - testSubject.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName)); + testSubject.findAvailableRequirement(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName)); } @Test @@ -1163,7 +1136,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet } @Test - public void testAssociateCINodeFilterToComponent() { + void testAssociateCINodeFilterToComponent() { String yamlName = "yamlName.yml"; Service service = createServiceObject(true); Map<String, UploadNodeFilterInfo> nodeFilterMap = new HashMap<>(); @@ -1178,7 +1151,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet } @Test - public void testAssociateCINodeFilterToComponentFail() { + void testAssociateCINodeFilterToComponentFail() { String yamlName = "yamlName.yml"; Service service = createServiceObject(true); Map<String, UploadNodeFilterInfo> nodeFilterMap = new HashMap<>(); @@ -1413,45 +1386,6 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet } @Test - void testValidateCyclicGroupsDependencies() { - Service component = createServiceObject(true); - Map<String, GroupDefinition> groups = new HashMap<>(); - String key = "098738485"; - GroupDefinition groupDefinition = new GroupDefinition(); - groups.put(key, groupDefinition); - - Assertions.assertNotNull( - testSubject.validateCyclicGroupsDependencies(groups)); - } - - @Test - void testFillAllGroupMemebersRecursivly() { - Map<String, GroupDefinition> allGroups = new HashMap<>(); - Set<String> allGroupMembers = new HashSet<>(); - String groupName = "groupName"; - Assertions.assertNotNull(groupName); - - testSubject.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers); - } - - @Test - void testFillAllGroupMemebersRecursivlyAllGroups() { - String groupName = "groupName"; - Map<String, GroupDefinition> allGroups = new HashMap<>(); - GroupDefinition groupDefinition = new GroupDefinition(); - Map<String, String> members = new HashMap<>(); - members.put("members", "members"); - groupDefinition.setMembers(members); - allGroups.put(groupName, groupDefinition); - allGroups.put("members", groupDefinition); - Set<String> allGroupMembers = new HashSet<>(); - allGroupMembers.add("allGroupMembers"); - Assertions.assertNotNull(allGroups); - - testSubject.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers); - } - - @Test void testFillResourceMetadataForServiceFailure() { String yamlName = "yamlName"; Service resourceVf = createServiceObject(true); |