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