From 2dcfb0996a8345de5c8be73a5600ee995309664a Mon Sep 17 00:00:00 2001 From: vasraz Date: Tue, 21 Jun 2022 12:16:22 +0100 Subject: Support Groups during Import Service Signed-off-by: Vasyl Razinkov Change-Id: I6752ebf23920fda1395f4cb7f458ecb29f8ecd51 Issue-ID: SDC-4054 --- .../csar/CsarArtifactsAndGroupsBusinessLogic.java | 71 +- .../csar/YamlTemplateParsingHandler.java | 36 +- .../be/components/impl/GroupTypeImportManager.java | 26 +- .../be/components/impl/ResourceBusinessLogic.java | 96 +-- .../impl/ServiceImportBusinessLogic.java | 18 +- .../components/impl/ServiceImportParseLogic.java | 97 +-- .../impl/ServiceImportBusinessLogicTest.java | 779 ++++++++++----------- .../ServiceImportBussinessLogicBaseTestSetup.java | 208 +++--- .../impl/ServiceImportParseLogicTest.java | 74 +- 9 files changed, 569 insertions(+), 836 deletions(-) (limited to 'catalog-be') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java index eefe47f69c..448077b6b5 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarArtifactsAndGroupsBusinessLogic.java @@ -135,22 +135,16 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { } private Either checkoutRes(Component component) { - Either checkoutRes = getResourcetFromGraph(component); - Resource resource1 = (Resource) checkoutRes.left().value(); - Either checkoutRes1 = Either.left(resource1); - return checkoutRes1; + return Either.left((Resource) getResourcetFromGraph(component).left().value()); } public Either createResourceArtifactsFromCsar(CsarInfo csarInfo, Service resource, String artifactsMetaFile, String artifactsMetaFileName, List createdArtifacts) { log.debug("parseResourceArtifactsInfoFromFile start"); return parseResourceArtifactsInfoFromFile(resource, artifactsMetaFile, artifactsMetaFileName).left() - .bind(p -> createResourceArtifacts(csarInfo, resource, p, createdArtifacts)).right().map(rf -> rf).left().bind(c -> { - Either checkoutRes = getResourcetFromGraph(c); - Service resource1 = (Service) checkoutRes.left().value(); - Either checkoutRes1 = Either.left(resource1); - return checkoutRes1; - }); + .bind(p -> createResourceArtifacts(csarInfo, resource, p, createdArtifacts)).right().map(rf -> rf).left().bind(c -> + Either.left((Service) getResourcetFromGraph(c).left().value()) + ); } public Either updateResourceArtifactsFromCsar(CsarInfo csarInfo, Component resource, String artifactsMetaFile, @@ -1040,8 +1034,6 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { private void findArtifactToDelete(Map> parsedGroup, Set artifactsToDelete, ArtifactDefinition artifact, List createdDeploymentArtifacts) { - boolean isNeedToDeleteArtifact = true; - String artifactType = artifact.getArtifactType(); ArtifactDefinition generatedFromArt = null; if (artifact.getGeneratedFromId() != null && !artifact.getGeneratedFromId().isEmpty()) { Optional op = createdDeploymentArtifacts.stream().filter(p -> p.getUniqueId().equals(artifact.getGeneratedFromId())) @@ -1050,23 +1042,25 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { generatedFromArt = op.get(); } } - isNeedToDeleteArtifact(parsedGroup, artifactsToDelete, artifact, isNeedToDeleteArtifact, artifactType, generatedFromArt); + isNeedToDeleteArtifact(parsedGroup, artifactsToDelete, artifact, generatedFromArt); } private void isNeedToDeleteArtifact(Map> parsedGroup, Set artifactsToDelete, - ArtifactDefinition artifact, boolean isNeedToDeleteArtifact, String artifactType, - ArtifactDefinition generatedFromArt) { - for (Entry> parsedGroupSetEntry : parsedGroup.entrySet()) { - Set artifactsNames = parsedGroupSetEntry.getValue(); - for (ArtifactTemplateInfo template : artifactsNames) { - if (artifact.getArtifactName().equalsIgnoreCase(template.getFileName()) && artifactType.equalsIgnoreCase(template.getType())) { - isNeedToDeleteArtifact = false; - break; - } else { - if (generatedFromArt != null && generatedFromArt.getArtifactName().equalsIgnoreCase(template.getFileName()) && generatedFromArt - .getArtifactType().equalsIgnoreCase(template.getType())) { - isNeedToDeleteArtifact = false; - break; + ArtifactDefinition artifact, ArtifactDefinition generatedFromArt) { + final String artifactType = artifact.getArtifactType(); + final String artifactName = artifact.getArtifactName(); + boolean isNeedToDeleteArtifact = true; + for (final Entry> parsedGroupSetEntry : parsedGroup.entrySet()) { + if (isNeedToDeleteArtifact) { + for (final ArtifactTemplateInfo template : parsedGroupSetEntry.getValue()) { + if (isNeedToDeleteArtifact) { + final String fileName = template.getFileName(); + final String type = template.getType(); + if ((artifactName.equalsIgnoreCase(fileName) && artifactType.equalsIgnoreCase(type)) + || (generatedFromArt != null && generatedFromArt.getArtifactName().equalsIgnoreCase(fileName) && + generatedFromArt.getArtifactType().equalsIgnoreCase(type))) { + isNeedToDeleteArtifact = false; + } } } } @@ -1559,19 +1553,20 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { if (groupsToDelete != null && !groupsToDelete.isEmpty()) { List vfGroupsToDelete = groupsToDelete.stream().filter(g -> g.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) .collect(Collectors.toList()); - Either eitherGetResource = deleteVfGroups(vfGroupsToDelete, updatedResource, csarInfo, shouldLock, - inTransaction); - if (eitherGetResource.isRight()) { - return Either.right(eitherGetResource.right().value()); + if (CollectionUtils.isNotEmpty(vfGroupsToDelete)) { + Either eitherGetResource = deleteVfGroups(vfGroupsToDelete, updatedResource, csarInfo, shouldLock, + inTransaction); + if (eitherGetResource.isRight()) { + return Either.right(eitherGetResource.right().value()); + } + updatedResource = eitherGetResource.left().value(); } - updatedResource = eitherGetResource.left().value(); } return Either.left(updatedResource); } private Either deleteVfGroups(List vfGroupsToDelete, Service resource, CsarInfo csarInfo, boolean shouldLock, boolean inTransaction) { - ResponseFormat responseFormat; if (vfGroupsToDelete != null && !vfGroupsToDelete.isEmpty()) { for (GroupDefinition gr : vfGroupsToDelete) { List artifacts = gr.getArtifacts(); @@ -1587,16 +1582,12 @@ public class CsarArtifactsAndGroupsBusinessLogic extends BaseBusinessLogic { groupBusinessLogic.deleteGroups(resource, vfGroupsToDelete); Either eitherGetResource = toscaOperationFacade.getToscaElement(resource.getUniqueId()); if (eitherGetResource.isRight()) { - responseFormat = componentsUtils - .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource, - resource.getComponentType()); - return Either.right(responseFormat); + return Either.right(componentsUtils.getResponseFormatByComponent( + componentsUtils.convertFromStorageResponse(eitherGetResource.right().value()), resource, resource.getComponentType())); } - resource = eitherGetResource.left().value(); - return Either.left(resource); + return Either.left(eitherGetResource.left().value()); } - responseFormat = componentsUtils.getResponseFormatByComponent(ActionStatus.INVALID_CONTENT, resource, resource.getComponentType()); - return Either.right(responseFormat); + return Either.right(componentsUtils.getResponseFormatByComponent(ActionStatus.INVALID_CONTENT, resource, resource.getComponentType())); } private Either getResourcetFromGraph(Component component) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java index 3faf750a73..6752586b80 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java @@ -138,11 +138,13 @@ public class YamlTemplateParsingHandler { log.debug("#parseResourceInfoFromYAML - Going to parse yaml {} ", fileName); Map mappedToscaTemplate = getMappedToscaTemplate(fileName, resourceYml, nodeTypesInfo, nodeName); ParsedToscaYamlInfo parsedToscaYamlInfo = new ParsedToscaYamlInfo(); - Map mappedTopologyTemplate = (Map) findToscaElement(mappedToscaTemplate, TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL).left().on(err -> failIfNotTopologyTemplate(fileName)); - Map mappedTopologyTemplateInputs = mappedTopologyTemplate.entrySet().stream().filter(entry -> entry.getKey().equals(INPUTS.getElementName())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + Map mappedTopologyTemplate = (Map) findToscaElement(mappedToscaTemplate, TOPOLOGY_TEMPLATE, + ToscaElementTypeEnum.ALL).left().on(err -> failIfNotTopologyTemplate(fileName)); + Map mappedTopologyTemplateInputs = mappedTopologyTemplate.entrySet().stream() + .filter(entry -> entry.getKey().equals(INPUTS.getElementName())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); parsedToscaYamlInfo.setInputs(getInputs(mappedTopologyTemplateInputs)); - parsedToscaYamlInfo.setInstances(getInstances(fileName, mappedToscaTemplate, createdNodesToscaResourceNames)); - parsedToscaYamlInfo.setGroups(getGroups(fileName, mappedToscaTemplate, component.getModel())); + parsedToscaYamlInfo.setInstances(getInstances(mappedToscaTemplate, createdNodesToscaResourceNames)); + parsedToscaYamlInfo.setGroups(getGroups(mappedToscaTemplate, component.getModel())); if (component instanceof Resource) { parsedToscaYamlInfo.setPolicies(getPolicies(fileName, mappedToscaTemplate, component.getModel())); } @@ -319,7 +321,7 @@ public class YamlTemplateParsingHandler { return targets; } - private Map getInstances(String yamlName, Map toscaJson, + private Map getInstances(Map toscaJson, Map createdNodesToscaResourceNames) { Map nodeTemplates = findFirstToscaMapElement(toscaJson, NODE_TEMPLATES).left().on(err -> new HashMap<>()); if (nodeTemplates.isEmpty()) { @@ -330,27 +332,26 @@ public class YamlTemplateParsingHandler { private Map getInstances(Map toscaJson, Map createdNodesToscaResourceNames, Map nodeTemplates) { - Map moduleComponentInstances; Map substitutionMappings = getSubstitutionMappings(toscaJson); - moduleComponentInstances = nodeTemplates.entrySet().stream() + return nodeTemplates.entrySet().stream() .map(node -> buildModuleComponentInstanceInfo(node, substitutionMappings, createdNodesToscaResourceNames)) .collect(Collectors.toMap(UploadComponentInstanceInfo::getName, i -> i)); - return moduleComponentInstances; } private Map getSubstitutionMappings(Map toscaJson) { - Map substitutionMappings = null; Either, ResultStatusEnum> eitherSubstitutionMappings = findFirstToscaMapElement(toscaJson, SUBSTITUTION_MAPPINGS); if (eitherSubstitutionMappings.isLeft()) { - substitutionMappings = eitherSubstitutionMappings.left().value(); + return eitherSubstitutionMappings.left().value(); } - return substitutionMappings; + return null; } @SuppressWarnings("unchecked") - private Map getGroups(String fileName, Map toscaJson, String model) { - Map foundGroups = findFirstToscaMapElement(toscaJson, GROUPS).left().on(err -> logGroupsNotFound(fileName)); - if (MapUtils.isNotEmpty(foundGroups) && matcheKey(foundGroups)) { + private Map getGroups(Map toscaJson, String model) { + Map mappedTopologyTemplate = (Map) findToscaElement(toscaJson, TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL) + .left().on(err -> new HashMap<>()); + Map foundGroups = (Map) mappedTopologyTemplate.get(GROUPS.getElementName()); + if (MapUtils.isNotEmpty(foundGroups)) { Map groups = foundGroups.entrySet().stream().map(groupToCreate -> createGroup(groupToCreate, model)) .collect(Collectors.toMap(GroupDefinition::getName, g -> g)); Map substitutionMappings = getSubstitutionMappings(toscaJson); @@ -411,7 +412,7 @@ public class YamlTemplateParsingHandler { rollbackWithException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE); } } catch (ClassCastException e) { - log.debug("#createGroup - Failed to create the group {}. The exception occure", groupNameValue.getKey(), e); + log.debug("#createGroup - Failed to create the group {}. The exception occurres", groupNameValue.getKey(), e); rollbackWithException(ActionStatus.INVALID_YAML); } return group; @@ -1088,11 +1089,6 @@ public class YamlTemplateParsingHandler { return propValue == null || !pattern.matcher(propValue.toString()).find(); } - private Map failIfNoNodeTemplates(String fileName) { - janusGraphDao.rollback(); - throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, fileName); - } - private Object failIfNotTopologyTemplate(String fileName) { janusGraphDao.rollback(); throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, fileName); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java index 8ff7d994e2..135003e7f8 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java @@ -25,6 +25,9 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.components.impl.model.ToscaTypeImportData; @@ -116,11 +119,9 @@ public class GroupTypeImportManager { } private Either validateGroupType(GroupTypeDefinition groupType) { - Either result = Either.left(ActionStatus.OK); if (groupType.getMembers() != null) { if (groupType.getMembers().isEmpty()) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GROUP_MEMBER_EMPTY, groupType.getType()); - result = Either.right(responseFormat); + return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_MEMBER_EMPTY, groupType.getType())); } else { for (String member : groupType.getMembers()) { // Verify that such Resource exist @@ -131,13 +132,12 @@ public class GroupTypeImportManager { log.debug("Error when fetching parent resource {}, error: {}", member, operationStatus); ActionStatus convertFromStorageResponse = componentsUtils.convertFromStorageResponse(operationStatus); BeEcompErrorManager.getInstance().logBeComponentMissingError("Import GroupType", "resource", member); - result = Either.right(componentsUtils.getResponseFormat(convertFromStorageResponse, member)); - break; + return Either.right(componentsUtils.getResponseFormat(convertFromStorageResponse, member)); } } } } - return result; + return Either.left(ActionStatus.OK); } private GroupTypeDefinition createGroupType(String groupTypeName, Map toscaJson) { @@ -152,8 +152,7 @@ public class GroupTypeImportManager { // Metadata commonImportManager.setField(toscaJson, TypeUtils.ToscaTagNamesEnum.METADATA.getElementName(), groupType::setMetadata); // Capabilities - Map capabilities = createCapabilities(toscaJson); - groupType.setCapabilities(capabilities); + groupType.setCapabilities(createCapabilities(toscaJson)); // Members commonImportManager.setField(toscaJson, TypeUtils.ToscaTagNamesEnum.MEMBERS.getElementName(), groupType::setMembers); groupType.setType(groupTypeName); @@ -198,18 +197,13 @@ public class GroupTypeImportManager { return pl.stream().map(ComponentInstanceProperty::new).collect(Collectors.toList()); } + @NoArgsConstructor + @Getter + @Setter private class CapabilityTypeToscaJsonHolder { private Map capabilityTypeToscaJson; - public Map getCapabilityTypeToscaJson() { - return capabilityTypeToscaJson; - } - - public void setCapabilityTypeToscaJson(Map capabilityTypeToscaJson) { - this.capabilityTypeToscaJson = capabilityTypeToscaJson; - } - public boolean isEmpty() { return capabilityTypeToscaJson == null; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java index d916dc6f64..6d5829e0fd 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java @@ -21,7 +21,6 @@ package org.openecomp.sdc.be.components.impl; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; -import static java.util.stream.Collectors.toSet; import static org.apache.commons.collections.CollectionUtils.isNotEmpty; import static org.apache.commons.collections.MapUtils.isEmpty; import static org.apache.commons.collections.MapUtils.isNotEmpty; @@ -220,12 +219,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { private final PropertyBusinessLogic propertyBusinessLogic; private final PolicyBusinessLogic policyBusinessLogic; private final ModelBusinessLogic modelBusinessLogic; - private IInterfaceLifecycleOperation interfaceTypeOperation; - private LifecycleBusinessLogic lifecycleBusinessLogic; private final DataTypeBusinessLogic dataTypeBusinessLogic; private final PolicyTypeBusinessLogic policyTypeBusinessLogic; private final ModelOperation modelOperation; - + private IInterfaceLifecycleOperation interfaceTypeOperation; + private LifecycleBusinessLogic lifecycleBusinessLogic; @Autowired private ICapabilityTypeOperation capabilityTypeOperation; @Autowired @@ -1945,14 +1943,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { List result = new ArrayList<>(); List componentInstances = component.getComponentInstances(); if (groups != null) { - Either validateCyclicGroupsDependencies = validateCyclicGroupsDependencies(groups); - if (validateCyclicGroupsDependencies.isRight()) { - throw new ByResponseFormatComponentException(validateCyclicGroupsDependencies.right().value()); - } for (Entry entry : groups.entrySet()) { String groupName = entry.getKey(); GroupDefinition groupDefinition = entry.getValue(); GroupDefinition updatedGroupDefinition = new GroupDefinition(groupDefinition); + updatedGroupDefinition.setMembers(null); Map members = groupDefinition.getMembers(); if (members != null) { @@ -1990,91 +1985,6 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { updatedGroupDefinition.setMembers(relevantInstances); } - /** - * This Method validates that there is no cyclic group dependencies. meaning group A as member in group B which is member in group A - * - * @param allGroups - * @return - */ - private Either validateCyclicGroupsDependencies(Map allGroups) { - Either result = Either.left(true); - try { - Iterator> allGroupsItr = allGroups.entrySet().iterator(); - while (allGroupsItr.hasNext() && result.isLeft()) { - Entry groupAEntry = allGroupsItr.next(); - // Fetches a group member A - String groupAName = groupAEntry.getKey(); - // Finds all group members in group A - Set allGroupAMembersNames = new HashSet<>(); - fillAllGroupMemebersRecursivly(groupAEntry.getKey(), allGroups, allGroupAMembersNames); - // If A is a group member of itself found cyclic dependency - if (allGroupAMembersNames.contains(groupAName)) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GROUP_HAS_CYCLIC_DEPENDENCY, groupAName); - result = Either.right(responseFormat); - } - } - } catch (Exception e) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR); - result = Either.right(responseFormat); - log.debug("Exception occurred when validateCyclicGroupsDependencies, error is:{}", e.getMessage(), e); - } - return result; - } - - /** - * This Method fills recursively the set groupMembers with all the members of the given group which are also of type group. - * - * @param groupName - * @param allGroups - * @param allGroupMembers - * @return - */ - private void fillAllGroupMemebersRecursivly(String groupName, Map allGroups, Set allGroupMembers) { - // Found Cyclic dependency - if (isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)) { - return; - } - GroupDefinition groupDefinition = allGroups.get(groupName); - // All Members Of Current Group Resource Instances & Other Groups - Set currGroupMembers = groupDefinition.getMembers().keySet(); - // Filtered Members Of Current Group containing only members which - - // are groups - List currGroupFilteredMembers = currGroupMembers.stream(). - // Keep Only Elements of type group and not Resource Instances - filter(allGroups::containsKey). - // Add Filtered Elements to main Set - peek(allGroupMembers::add). - // Collect results - collect(toList()); - // Recursively call the method for all the filtered group members - for (String innerGroupName : currGroupFilteredMembers) { - fillAllGroupMemebersRecursivly(innerGroupName, allGroups, allGroupMembers); - } - } - - private boolean isfillGroupMemebersRecursivlyStopCondition(String groupName, Map allGroups, - Set allGroupMembers) { - boolean stop = !allGroups.containsKey(groupName); - // In Case Not Group Stop - // In Case Group Has no members stop - if (!stop) { - GroupDefinition groupDefinition = allGroups.get(groupName); - stop = isEmpty(groupDefinition.getMembers()); - } - // In Case all group members already contained stop - if (!stop) { - final Set allMembers = allGroups.get(groupName).getMembers().keySet(); - Set membersOfTypeGroup = allMembers.stream(). - // Filter In Only Group members - filter(allGroups::containsKey). - // Collect - collect(toSet()); - stop = allGroupMembers.containsAll(membersOfTypeGroup); - } - return stop; - } - private Resource createRIAndRelationsFromYaml(String yamlName, Resource resource, Map uploadComponentInstanceInfoMap, String topologyTemplateYaml, List nodeTypesNewCreatedArtifacts, diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java index d7e5d0b9c1..9a8c181377 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java @@ -69,7 +69,6 @@ import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils; import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter; -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; @@ -917,10 +916,6 @@ public class ServiceImportBusinessLogic { List result = new ArrayList<>(); List componentInstances = component.getComponentInstances(); if (groups != null) { - Either validateCyclicGroupsDependencies = serviceImportParseLogic.validateCyclicGroupsDependencies(groups); - if (validateCyclicGroupsDependencies.isRight()) { - throw new ComponentException(validateCyclicGroupsDependencies.right().value()); - } for (Map.Entry entry : groups.entrySet()) { String groupName = entry.getKey(); GroupDefinition groupDefinition = entry.getValue(); @@ -1353,7 +1348,8 @@ public class ServiceImportBusinessLogic { uploadResInstancesMap.values().forEach( i -> processComponentInstance(yamlName, finalResource, componentInstancesList, componentsUtils.getAllDataTypes(applicationDataTypeCache, finalResource.getModel()), instProperties, - instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, instNodeFilter, i)); + instCapabilities, instRequirements, instDeploymentArtifacts, instArtifacts, instAttributes, originCompMap, instInputs, + instNodeFilter, i)); } serviceImportParseLogic.associateComponentInstancePropertiesToComponent(yamlName, service, instProperties); serviceImportParseLogic.associateComponentInstanceInputsToComponent(yamlName, service, instInputs); @@ -1698,7 +1694,7 @@ public class ServiceImportBusinessLogic { if (MapUtils.isNotEmpty(capabilitiesNamesToUpdate)) { for (Map.Entry> requirements : instance.getCapabilities().entrySet()) { updatedCapabilities.put(requirements.getKey(), requirements.getValue().stream().filter( - c -> capabilitiesNamesToUpdate.containsKey(c.getName()) && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName()))) + c -> capabilitiesNamesToUpdate.containsKey(c.getName()) && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName()))) .map(c -> { c.setParentName(c.getName()); c.setName(capabilitiesNamesToUpdate.get(c.getName())); @@ -1719,7 +1715,7 @@ public class ServiceImportBusinessLogic { if (MapUtils.isNotEmpty(requirementsNamesToUpdate)) { for (Map.Entry> requirements : instance.getRequirements().entrySet()) { updatedRequirements.put(requirements.getKey(), requirements.getValue().stream().filter( - r -> requirementsNamesToUpdate.containsKey(r.getName()) && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName()))) + r -> requirementsNamesToUpdate.containsKey(r.getName()) && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName()))) .map(r -> { r.setParentName(r.getName()); r.setName(requirementsNamesToUpdate.get(r.getName())); @@ -1790,7 +1786,7 @@ public class ServiceImportBusinessLogic { regCapRelDef.setFromNode(resourceInstanceId); log.debug("try to find available requirement {} ", regName); Either eitherReqStatus = serviceImportParseLogic - .findAviableRequiremen(regName, yamlName, nodesInfoValue, currentCompInstance, uploadRegInfo.getCapabilityName()); + .findAvailableRequirement(regName, yamlName, nodesInfoValue, currentCompInstance, uploadRegInfo.getCapabilityName()); if (eitherReqStatus.isRight()) { log.debug("failed to find available requirement {} status is {}", regName, eitherReqStatus.right().value()); return eitherReqStatus.right().value(); @@ -2316,10 +2312,6 @@ public class ServiceImportBusinessLogic { List result = new ArrayList<>(); List componentInstances = component.getComponentInstances(); if (groups != null) { - Either validateCyclicGroupsDependencies = serviceImportParseLogic.validateCyclicGroupsDependencies(groups); - if (validateCyclicGroupsDependencies.isRight()) { - throw new ComponentException(validateCyclicGroupsDependencies.right().value()); - } for (Map.Entry entry : groups.entrySet()) { String groupName = entry.getKey(); GroupDefinition groupDefinition = entry.getValue(); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java index 29758b6bc5..63abf26ef4 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java @@ -18,15 +18,12 @@ package org.openecomp.sdc.be.components.impl; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; -import static java.util.stream.Collectors.toSet; import static org.apache.commons.collections.CollectionUtils.isNotEmpty; import fj.data.Either; import java.util.ArrayList; -import java.util.Collections; import java.util.EnumMap; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -51,7 +48,6 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; -import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; @@ -451,31 +447,6 @@ public class ServiceImportParseLogic { return componentTypeForResponse; } - protected boolean isfillGroupMemebersRecursivlyStopCondition(String groupName, Map allGroups, - Set allGroupMembers) { - boolean stop = false; - // In Case Not Group Stop - if (!allGroups.containsKey(groupName)) { - stop = true; - } - // In Case Group Has no members stop - if (!stop) { - GroupDefinition groupDefinition = allGroups.get(groupName); - stop = MapUtils.isEmpty(groupDefinition.getMembers()); - } - // In Case all group members already contained stop - if (!stop) { - final Set allMembers = allGroups.get(groupName).getMembers().keySet(); - Set membersOfTypeGroup = allMembers.stream(). - // Filter In Only Group members - filter(allGroups::containsKey). - // Collect - collect(toSet()); - stop = allGroupMembers.containsAll(membersOfTypeGroup); - } - return stop; - } - public Resource buildValidComplexVfc(Resource resource, CsarInfo csarInfo, String nodeName, Map nodesInfo) { Resource complexVfc = buildComplexVfcMetadata(resource, csarInfo, nodeName, nodesInfo); log.debug("************* Going to validate complex VFC from yaml {}", complexVfc.getName()); @@ -1028,9 +999,9 @@ public class ServiceImportParseLogic { } } - public Either findAviableRequiremen(String regName, String yamlName, - UploadComponentInstanceInfo uploadComponentInstanceInfo, - ComponentInstance currentCompInstance, String capName) { + public Either findAvailableRequirement(String regName, String yamlName, + UploadComponentInstanceInfo uploadComponentInstanceInfo, + ComponentInstance currentCompInstance, String capName) { Map> comInstRegDefMap = currentCompInstance.getRequirements(); List list = comInstRegDefMap.get(capName); RequirementDefinition validRegDef = null; @@ -1232,7 +1203,7 @@ public class ServiceImportParseLogic { String propertyName = property.getName().toLowerCase(); String propertyType = property.getType(); ComponentInstanceProperty validProperty; - if (defaultProperties.containsKey(propertyName) && propertTypeEqualsTo(defaultProperties, propertyName, propertyType)) { + if (defaultProperties.containsKey(propertyName) && propertyTypeEqualsTo(defaultProperties, propertyName, propertyType)) { throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NAME_ALREADY_EXISTS, propertyName)); } validProperty = new ComponentInstanceProperty(); @@ -1247,7 +1218,7 @@ public class ServiceImportParseLogic { defaultCapability.setProperties(validProperties); } - private boolean propertTypeEqualsTo(Map defaultProperties, String propertyName, String propertyType) { + private boolean propertyTypeEqualsTo(Map defaultProperties, String propertyName, String propertyType) { return propertyType != null && !defaultProperties.get(propertyName).getType().equals(propertyType); } @@ -1710,10 +1681,6 @@ public class ServiceImportParseLogic { List result = new ArrayList<>(); List componentInstances = component.getComponentInstances(); if (groups != null) { - Either validateCyclicGroupsDependencies = validateCyclicGroupsDependencies(groups); - if (validateCyclicGroupsDependencies.isRight()) { - throw new ComponentException(validateCyclicGroupsDependencies.right().value()); - } for (Map.Entry entry : groups.entrySet()) { String groupName = entry.getKey(); GroupDefinition groupDefinition = entry.getValue(); @@ -1760,55 +1727,6 @@ public class ServiceImportParseLogic { updatedGroupDefinition.setMembers(relevantInstances); } - public Either validateCyclicGroupsDependencies(Map allGroups) { - Either result = Either.left(true); - try { - Iterator> allGroupsItr = allGroups.entrySet().iterator(); - while (allGroupsItr.hasNext() && result.isLeft()) { - Map.Entry groupAEntry = allGroupsItr.next(); - // Fetches a group member A - String groupAName = groupAEntry.getKey(); - // Finds all group members in group A - Set allGroupAMembersNames = new HashSet<>(); - fillAllGroupMemebersRecursivly(groupAEntry.getKey(), allGroups, allGroupAMembersNames); - // If A is a group member of itself found cyclic dependency - if (allGroupAMembersNames.contains(groupAName)) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GROUP_HAS_CYCLIC_DEPENDENCY, groupAName); - result = Either.right(responseFormat); - } - } - } catch (Exception e) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR); - result = Either.right(responseFormat); - log.debug("Exception occured when validateCyclicGroupsDependencies, error is:{}", e.getMessage(), e); - } - return result; - } - - protected void fillAllGroupMemebersRecursivly(String groupName, Map allGroups, Set allGroupMembers) { - // Found Cyclic dependency - if (isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)) { - return; - } - GroupDefinition groupDefinition = allGroups.get(groupName); - // All Members Of Current Group Resource Instances & Other Groups - Set currGroupMembers = groupDefinition.getMembers().keySet(); - // Filtered Members Of Current Group containing only members which - - // are groups - List currGroupFilteredMembers = currGroupMembers.stream(). - // Keep Only Elements of type group and not Resource Instances - filter(allGroups::containsKey). - // Add Filtered Elements to main Set - peek(allGroupMembers::add). - // Collect results - collect(toList()); - // Recursively call the method for all the filtered group members - for (String innerGroupName : currGroupFilteredMembers) { - fillAllGroupMemebersRecursivly(innerGroupName, allGroups, allGroupMembers); - } - } - public ImmutablePair createResourceFromNodeType(String nodeTypeYaml, UploadResourceInfo resourceMetaData, User creator, boolean isInTransaction, boolean needLock, Map> nodeTypeArtifactsToHandle, @@ -2157,7 +2075,8 @@ public class ServiceImportParseLogic { public void associateCINodeFilterToComponent(String yamlName, Service service, Map nodeFilter) { log.trace("************* Going to associate all resource node filters {}", yamlName); if (MapUtils.isNotEmpty(nodeFilter)) { - StorageOperationStatus status = componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(service.getUniqueId(), nodeFilter); + StorageOperationStatus status = componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(service.getUniqueId(), + nodeFilter); if (status != StorageOperationStatus.OK) { throw new ComponentException( componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName)); @@ -2342,7 +2261,7 @@ public class ServiceImportParseLogic { RequirementCapabilityRelDef regCapRelDef = new RequirementCapabilityRelDef(); regCapRelDef.setFromNode(resourceInstanceId); log.debug("try to find available requirement {} ", regName); - Either eitherReqStatus = findAviableRequiremen(regName, yamlName, nodesInfoValue, + Either eitherReqStatus = findAvailableRequirement(regName, yamlName, nodesInfoValue, currentCompInstance, uploadRegInfo.getCapabilityName()); if (eitherReqStatus.isRight()) { return eitherReqStatus.right().value(); 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 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 payload = crateCsarFromPayload(); CsarInfo csarInfo = getCsarInfo(); Map>> 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>> nodeTypesArtifactsToCreate = new HashMap<>(); String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; - Map nodeTypesInfo = getNodeTypesInfo(); Map 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 createdArtifacts = new ArrayList<>(); String yamlFileName = "group.yml"; @@ -284,28 +282,28 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test"; Map>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List 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 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 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 createdArtifacts = new ArrayList<>(); ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.UPDATE); Either 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 deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -405,13 +402,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List artifactPathAndNameList = new ArrayList<>(); Either>, - 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 artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List existingArtifactsToHandle = new ArrayList<>(); @@ -435,12 +431,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Resource resource = createParseResourceObject(false); Either>, 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 artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List 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 createdArtifacts = new ArrayList<>(); @@ -464,16 +461,16 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); EnumMap> 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 csar = csarInfo.getCsar(); @@ -496,16 +493,16 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest artifactDefinition.setArtifactName("artifactName"); Either 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> 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 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 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 deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -564,14 +560,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List 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 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 createdArtifacts = new ArrayList<>(); ArtifactOperationInfo artifactOperation = new ArtifactOperationInfo(true, true, ArtifactsBusinessLogic.ArtifactOperationEnum.CREATE); Either 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 deploymentArtifacts = new HashMap<>(); ArtifactDefinition artifactDefinition = new ArtifactDefinition(); @@ -627,12 +624,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List artifactPathAndNameList = new ArrayList<>(); Either>, - 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 artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List existingArtifactsToHandle = new ArrayList<>(); @@ -644,13 +641,13 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Service service = createServiceObject(true); Either>, 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 artifactPathAndNameList = new ArrayList<>(); artifactPathAndNameList.add(getNonMetaArtifactInfo()); List 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 createdArtifacts = new ArrayList<>(); Either resStatus = Either.left(service); EnumMap> vfCsarArtifactsToHandle = new - EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List 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>> collectedWarningMessages = new HashMap<>(); Either, 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 csar = csarInfo.getCsar(); @@ -715,16 +712,16 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest artifactDefinition.setArtifactName("artifactName"); Either 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 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 groups = new HashMap<>(); Assertions.assertNotNull( - sIB1.createGroupsOnResource(service, groups)); + sIB1.createGroupsOnResource(service, groups)); } @Test - public void testCreateGroupsOnResourceNull() { + void testCreateGroupsOnResourceNull() { Service service = createServiceObject(true); Map 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 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 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>> 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> properties = new HashMap<>(); List 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 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 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 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>> 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>> nodeTypesArtifactsToHandle = new HashMap<>(); List 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 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>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List 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 nodeTypesNewCreatedArtifacts = new ArrayList<>(); Map 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 nodeMap = new HashMap<>(); @@ -1107,22 +1091,23 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest resourceMetaData.setResourceType("VFC"); ImmutablePair 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 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 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> properties = new HashMap<>(); List uploadPropInfoList = new ArrayList<>(); @@ -1261,12 +1246,12 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map 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 inputs = new ArrayList<>(); ComponentInstance currentCompInstance = null; @@ -1296,17 +1281,17 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testProcessGetInput() { + void testProcessGetInput() { List getInputValues = new ArrayList<>(); List 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 getInputValues = new ArrayList<>(); List 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 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, JanusGraphOperationStatus> allDataTypes = null; Map>> 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, JanusGraphOperationStatus> allDataTypes = null; Map>> 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, JanusGraphOperationStatus> allDataTypes = null; Map> originCapabilities = new HashMap<>(); Map> newPropertiesMap = new HashMap<>(); @@ -1441,7 +1426,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testUpdatePropertyValues() { + void testUpdatePropertyValues() { List properties = new ArrayList<>(); Map newProperties = new HashMap<>(); Map 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 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 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 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 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 componentInstances = creatComponentInstances(); Map uploadResInstancesMap = getUploadResInstancesMap(); Map>> 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>> updatedInstCapabilties = new HashMap<>(); Map> capabilities = new HashMap<>(); List capabilityDefinitionList = new ArrayList<>(); @@ -1524,9 +1510,9 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testFillUpdatedInstRequirements() { + void testFillUpdatedInstRequirements() { Map>> updatedInstRequirements = new - HashMap<>(); + HashMap<>(); ComponentInstance instance = new ComponentInstance(); Map> requirements = new HashMap<>(); List requirementDefinitionList = new ArrayList<>(); @@ -1537,14 +1523,14 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest instance.setRequirements(requirements); Map 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 uploadResInstancesMap = new HashMap<>(); @@ -1589,11 +1575,11 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List 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 componentInstancesList = new ArrayList<>(); @@ -1627,23 +1613,23 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest List 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 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 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 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 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>> nodeTypesArtifactsToHandle = new HashMap<>(); List 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>> nodeTypesArtifactsToHandle = new HashMap<>(); List 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>> nodeTypesArtifactsToHandle = new HashMap<>(); List createdArtifacts = new ArrayList<>(); Map 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>> nodeTypesArtifactsToHandle = new HashMap<>(); List createdArtifacts = new ArrayList<>(); Map 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>> nodeTypesArtifactsToHandle = new HashMap<>(); List createdArtifacts = new ArrayList<>(); Map 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 groups = null; List 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 groups = null; @@ -1949,29 +1931,21 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest } @Test - public void testUpdateGroupsMembersUsingResource2() { + void testUpdateGroupsMembersUsingResource2() { Resource resource = createParseResourceObject(true); Map 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 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 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 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 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>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List 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 nodeTypesNewCreatedArtifacts = new ArrayList<>(); Map 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>> nodeTypesArtifactsToHandle = new HashMap<>(); EnumMap> enumListEnumMap = - new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); + new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); List 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 nodeTypesNewCreatedArtifacts = new ArrayList<>(); Map nodeTypesInfo = getNodeTypesInfo(); @@ -2131,15 +2105,15 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest Map 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 getNodeTypesInfo() { Map 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) 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 creatComponentInstances() { List 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 componentFieldValidators = Arrays.asList(componentContactIdValidator, - componentDescriptionValidator, - componentIconValidator, componentNameValidator, - new ComponentProjectCodeValidator(componentsUtils), - componentTagsValidator); + componentDescriptionValidator, + componentIconValidator, componentNameValidator, + new ComponentProjectCodeValidator(componentsUtils), + componentTagsValidator); List 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 findLatestGeneric = Either.left(genericService); when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_SERVICE_NAME)).thenReturn(findLatestGeneric); - when(serviceImportParseLogic.isArtifactDeletionRequired(anyString(),any(),anyBoolean())).thenReturn(true); - Either 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 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 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> requirements = new HashMap<>(); - List requirementDefinitionList= new ArrayList<>(); + List 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 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 directives = new Collection() { @@ -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> getCapabilities(){ + protected Map> getCapabilities() { List uploadCapInfoList = new ArrayList<>(); UploadCapInfo uploadCapInfo = new UploadCapInfo(); uploadCapInfo.setNode("tosca.nodes.Root"); uploadCapInfo.setName("mme_ipu_vdu.dependency"); uploadCapInfoList.add(uploadCapInfo); Map> uploadCapInfoMap = new HashMap<>(); - uploadCapInfoMap.put("tosca.capabilities.Node",uploadCapInfoList); + uploadCapInfoMap.put("tosca.capabilities.Node", uploadCapInfoList); return uploadCapInfoMap; } - protected List creatComponentInstances(){ + protected List creatComponentInstances() { List componentInstances = new ArrayList<>(); ComponentInstance componentInstance = new ComponentInstance(); Map> 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> requirements = new HashMap<>(); List 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 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 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 tags = new ArrayList<>(); List 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 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 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; @@ -373,27 +367,6 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet testSubject.getComponentTypeForResponse(service)); } - @Test - void testIsfillGroupMemebersRecursivlyStopCondition() { - String groupName = "groupName"; - Map allGroups = new HashMap<>(); - Set allGroupMembers = new HashSet<>(); - Assertions.assertTrue(testSubject.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)); - } - - @Test - void testIsfillGroupMemebersRecursivlyStopCondition2() { - String groupName = "groupName"; - Map allGroups = new HashMap<>(); - GroupDefinition groupDefinition = new GroupDefinition(); - Map members = new HashMap<>(); - members.put("members", "members"); - groupDefinition.setMembers(members); - allGroups.put(groupName, groupDefinition); - Set allGroupMembers = new HashSet<>(); - Assertions.assertTrue(testSubject.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)); - } - @Test void testBuildValidComplexVfc() { Resource resource = createParseResourceObject(true); @@ -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 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 nodeFilterMap = new HashMap<>(); @@ -1412,45 +1385,6 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet testSubject.updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members)); } - @Test - void testValidateCyclicGroupsDependencies() { - Service component = createServiceObject(true); - Map groups = new HashMap<>(); - String key = "098738485"; - GroupDefinition groupDefinition = new GroupDefinition(); - groups.put(key, groupDefinition); - - Assertions.assertNotNull( - testSubject.validateCyclicGroupsDependencies(groups)); - } - - @Test - void testFillAllGroupMemebersRecursivly() { - Map allGroups = new HashMap<>(); - Set allGroupMembers = new HashSet<>(); - String groupName = "groupName"; - Assertions.assertNotNull(groupName); - - testSubject.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers); - } - - @Test - void testFillAllGroupMemebersRecursivlyAllGroups() { - String groupName = "groupName"; - Map allGroups = new HashMap<>(); - GroupDefinition groupDefinition = new GroupDefinition(); - Map members = new HashMap<>(); - members.put("members", "members"); - groupDefinition.setMembers(members); - allGroups.put(groupName, groupDefinition); - allGroups.put("members", groupDefinition); - Set allGroupMembers = new HashSet<>(); - allGroupMembers.add("allGroupMembers"); - Assertions.assertNotNull(allGroups); - - testSubject.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers); - } - @Test void testFillResourceMetadataForServiceFailure() { String yamlName = "yamlName"; -- cgit 1.2.3-korg