aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java1009
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java864
2 files changed, 925 insertions, 948 deletions
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 3c53c0ca50..6a5e5314f0 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
@@ -16,8 +16,24 @@
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.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.codec.binary.Base64;
@@ -33,13 +49,49 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
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.*;
+import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.CreatedFrom;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
+import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.NodeTypeInfo;
+import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.RelationshipImpl;
+import org.openecomp.sdc.be.model.RelationshipInfo;
+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.UploadInfo;
+import org.openecomp.sdc.be.model.UploadPropInfo;
+import org.openecomp.sdc.be.model.UploadReqInfo;
+import org.openecomp.sdc.be.model.UploadResourceInfo;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
@@ -64,12 +116,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
-import java.util.*;
-import java.util.function.Function;
-
-import static java.util.stream.Collectors.*;
-import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
-
@Getter
@Setter
@org.springframework.stereotype.Component
@@ -85,23 +131,13 @@ public class ServiceImportParseLogic {
private static final String PLACE_HOLDER_RESOURCE_TYPES = "validForResourceTypes";
private static final String CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES = "Create Resource - validateCapabilityTypesCreate";
private static final String CATEGORY_IS_EMPTY = "Resource category is empty";
-
-
+ private static final Logger log = Logger.getLogger(ServiceImportParseLogic.class);
@Autowired
private ServiceBusinessLogic serviceBusinessLogic;
- public ServiceBusinessLogic getServiceBusinessLogic() {
- return serviceBusinessLogic;
- }
-
- public void setServiceBusinessLogic(
- ServiceBusinessLogic serviceBusinessLogic) {
- this.serviceBusinessLogic = serviceBusinessLogic;
- }
-
@Autowired
- protected ComponentsUtils componentsUtils;
+ private ComponentsUtils componentsUtils;
@Autowired
- protected ToscaOperationFacade toscaOperationFacade;
+ private ToscaOperationFacade toscaOperationFacade;
@Autowired
private LifecycleBusinessLogic lifecycleBusinessLogic;
@Autowired
@@ -110,33 +146,24 @@ public class ServiceImportParseLogic {
private ResourceImportManager resourceImportManager;
@Autowired
private IInterfaceLifecycleOperation interfaceTypeOperation = null;
- private static final Logger log = Logger.getLogger(ServiceImportParseLogic.class);
-
@Autowired
private ICapabilityTypeOperation capabilityTypeOperation = null;
- public ICapabilityTypeOperation getCapabilityTypeOperation() {
- return capabilityTypeOperation;
- }
-
- public void setCapabilityTypeOperation(ICapabilityTypeOperation capabilityTypeOperation) {
- this.capabilityTypeOperation = capabilityTypeOperation;
- }
-
public Either<Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(
- Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, Service oldResource) {
+ Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, Service oldResource) {
Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
Either<Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> nodeTypesArtifactsToHandleRes
- = Either.left(nodeTypesArtifactsToHandle);
+ = Either.left(nodeTypesArtifactsToHandle);
try {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csarInfo.getCsar());
Map<String, ImmutablePair<String, String>> extractedVfcToscaNames =
- extractVfcToscaNames(nodeTypesInfo, oldResource.getName(), csarInfo);
+ extractVfcToscaNames(nodeTypesInfo, oldResource.getName(), csarInfo);
log.debug("Going to fetch node types for resource with name {} during import csar with UUID {}. ",
- oldResource.getName(), csarInfo.getCsarUUID());
- extractedVfcToscaNames.forEach((namespace, vfcToscaNames) -> findAddNodeTypeArtifactsToHandle(csarInfo, nodeTypesArtifactsToHandle, oldResource,
+ oldResource.getName(), csarInfo.getCsarUUID());
+ extractedVfcToscaNames
+ .forEach((namespace, vfcToscaNames) -> findAddNodeTypeArtifactsToHandle(csarInfo, nodeTypesArtifactsToHandle, oldResource,
extractedVfcsArtifacts,
namespace, vfcToscaNames));
} catch (Exception e) {
@@ -157,19 +184,19 @@ public class ServiceImportParseLogic {
while (nodesNameEntry.hasNext()) {
Map.Entry<String, Object> nodeType = nodesNameEntry.next();
ImmutablePair<String, String> toscaResourceName = buildNestedToscaResourceName(
- ResourceTypeEnum.VFC.name(), vfResourceName, nodeType.getKey());
+ ResourceTypeEnum.VFC.name(), vfResourceName, nodeType.getKey());
vfcToscaNames.put(nodeType.getKey(), toscaResourceName);
}
}
for (NodeTypeInfo cvfc : nodeTypesInfo.values()) {
vfcToscaNames.put(cvfc.getType(),
- buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), vfResourceName, cvfc.getType()));
+ buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), vfResourceName, cvfc.getType()));
}
return vfcToscaNames;
}
public String buildNodeTypeYaml(Map.Entry<String, Object> nodeNameValue, Map<String, Object> mapToConvert,
- String nodeResourceType, CsarInfo csarInfo) {
+ String nodeResourceType, CsarInfo csarInfo) {
// We need to create a Yaml from each node_types in order to create
// resource from each node type using import normative flow.
DumperOptions options = new DumperOptions();
@@ -178,7 +205,7 @@ public class ServiceImportParseLogic {
Map<String, Object> node = new HashMap<>();
node.put(buildNestedToscaResourceName(nodeResourceType, csarInfo.getVfResourceName(), nodeNameValue.getKey())
- .getLeft(), nodeNameValue.getValue());
+ .getLeft(), nodeNameValue.getValue());
mapToConvert.put(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName(), node);
return yaml.dumpAsMap(mapToConvert);
@@ -198,11 +225,11 @@ public class ServiceImportParseLogic {
String nameWithouNamespacePrefix;
try {
StringBuilder toscaResourceName = new StringBuilder(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
- if (!nodeTypeFullName.contains(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX)){
+ if (!nodeTypeFullName.contains(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX)) {
nameWithouNamespacePrefix = nodeTypeFullName;
} else {
nameWithouNamespacePrefix = nodeTypeFullName
- .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
+ .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
}
String[] findTypes = nameWithouNamespacePrefix.split("\\.");
String resourceType = findTypes[0];
@@ -210,18 +237,17 @@ public class ServiceImportParseLogic {
if (actualName.startsWith(Constants.ABSTRACT)) {
toscaResourceName.append(resourceType.toLowerCase()).append('.')
- .append(ValidationUtils.convertToSystemName(actualVfName));
+ .append(ValidationUtils.convertToSystemName(actualVfName));
} else {
toscaResourceName.append(actualType.toLowerCase()).append('.').append(ValidationUtils.convertToSystemName(actualVfName));
- //toscaResourceName.append(actualType.toLowerCase());
}
StringBuilder previousToscaResourceName = new StringBuilder(toscaResourceName);
return new ImmutablePair<>(toscaResourceName.append(actualName.toLowerCase()).toString(),
- previousToscaResourceName
- .append(actualName.substring(actualName.split("\\.")[1].length() + 1).toLowerCase())
- .toString());
+ previousToscaResourceName
+ .append(actualName.substring(actualName.split("\\.")[1].length() + 1).toLowerCase())
+ .toString());
} catch (Exception e) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
+ componentsUtils.getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
log.debug("Exception occured when buildNestedToscaResourceName, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE, vfResourceName);
}
@@ -238,14 +264,16 @@ public class ServiceImportParseLogic {
private void extractNodeTypes(Map<String, Object> nodes, Map<String, Object> mappedToscaTemplate) {
Either<Map<String, Object>, ImportUtils.ResultStatusEnum> eitherNodeTypes = ImportUtils
- .findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
+ .findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
if (eitherNodeTypes.isLeft()) {
nodes.putAll(eitherNodeTypes.left().value());
}
}
- protected void findAddNodeTypeArtifactsToHandle(CsarInfo csarInfo, Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
- Service resource, Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts, String namespace, ImmutablePair<String, String> vfcToscaNames){
+ protected void findAddNodeTypeArtifactsToHandle(CsarInfo csarInfo,
+ Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
+ Service resource, Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts, String namespace,
+ ImmutablePair<String, String> vfcToscaNames) {
EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> curNodeTypeArtifactsToHandle = null;
log.debug("Going to fetch node type with tosca name {}. ", vfcToscaNames.getLeft());
@@ -273,7 +301,7 @@ public class ServiceImportParseLogic {
.put(ArtifactsBusinessLogic.ArtifactOperationEnum.DELETE, artifactsToDelete);
}
} catch (Exception e) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
+ componentsUtils.getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE);
log.debug("Exception occured when findAddNodeTypeArtifactsToHandle, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE, vfcToscaNames.getLeft());
}
@@ -284,9 +312,9 @@ public class ServiceImportParseLogic {
}
protected void handleAndAddExtractedVfcsArtifacts(List<ArtifactDefinition> vfcArtifacts,
- List<ArtifactDefinition> artifactsToAdd) {
+ List<ArtifactDefinition> artifactsToAdd) {
List<String> vfcArtifactNames = vfcArtifacts.stream().map(ArtifactDataDefinition::getArtifactName)
- .collect(toList());
+ .collect(toList());
artifactsToAdd.stream().forEach(a -> {
if (!vfcArtifactNames.contains(a.getArtifactName())) {
vfcArtifacts.add(a);
@@ -296,20 +324,21 @@ public class ServiceImportParseLogic {
});
}
- protected Resource findVfcResource(CsarInfo csarInfo, Service resource, String currVfcToscaName, String previousVfcToscaName, StorageOperationStatus status) {
+ protected Resource findVfcResource(CsarInfo csarInfo, Service resource, String currVfcToscaName, String previousVfcToscaName,
+ StorageOperationStatus status) {
if (status != null && status != StorageOperationStatus.NOT_FOUND) {
log.debug("Error occured during fetching node type with tosca name {}, error: {}", currVfcToscaName, status);
throw new ComponentException(componentsUtils.convertFromStorageResponse(status), csarInfo.getCsarUUID());
} else if (org.apache.commons.lang.StringUtils.isNotEmpty(currVfcToscaName)) {
- return (Resource)toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName)
- .left()
- .on(st -> findVfcResource(csarInfo, resource, previousVfcToscaName, null, st));
+ return (Resource) toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName)
+ .left()
+ .on(st -> findVfcResource(csarInfo, resource, previousVfcToscaName, null, st));
}
return null;
}
protected EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> findNodeTypeArtifactsToHandle(
- Resource curNodeType, List<ArtifactDefinition> extractedArtifacts) {
+ Resource curNodeType, List<ArtifactDefinition> extractedArtifacts) {
EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = null;
try {
@@ -317,7 +346,7 @@ public class ServiceImportParseLogic {
List<ArtifactDefinition> artifactsToUpdate = new ArrayList<>();
List<ArtifactDefinition> artifactsToDelete = new ArrayList<>();
processExistingNodeTypeArtifacts(extractedArtifacts, artifactsToUpload, artifactsToUpdate, artifactsToDelete,
- collectExistingArtifacts(curNodeType));
+ collectExistingArtifacts(curNodeType));
nodeTypeArtifactsToHandle = putFoundArtifacts(artifactsToUpload, artifactsToUpdate, artifactsToDelete);
} catch (Exception e) {
log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage(), e);
@@ -336,15 +365,16 @@ public class ServiceImportParseLogic {
}
if (MapUtils.isNotEmpty(curNodeType.getArtifacts())) {
existingArtifacts
- .putAll(curNodeType.getArtifacts().entrySet()
- .stream()
- .filter(e -> e.getValue().getArtifactGroupType() == ArtifactGroupTypeEnum.INFORMATIONAL)
- .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)));
+ .putAll(curNodeType.getArtifacts().entrySet()
+ .stream()
+ .filter(e -> e.getValue().getArtifactGroupType() == ArtifactGroupTypeEnum.INFORMATIONAL)
+ .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)));
}
return existingArtifacts;
}
- protected EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> putFoundArtifacts(List<ArtifactDefinition> artifactsToUpload, List<ArtifactDefinition> artifactsToUpdate, List<ArtifactDefinition> artifactsToDelete) {
+ protected EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> putFoundArtifacts(
+ List<ArtifactDefinition> artifactsToUpload, List<ArtifactDefinition> artifactsToUpdate, List<ArtifactDefinition> artifactsToDelete) {
EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle = null;
if (!artifactsToUpload.isEmpty() || !artifactsToUpdate.isEmpty() || !artifactsToDelete.isEmpty()) {
nodeTypeArtifactsToHandle = new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class);
@@ -362,8 +392,8 @@ public class ServiceImportParseLogic {
}
protected void processExistingNodeTypeArtifacts(List<ArtifactDefinition> extractedArtifacts, List<ArtifactDefinition> artifactsToUpload,
- List<ArtifactDefinition> artifactsToUpdate, List<ArtifactDefinition> artifactsToDelete,
- Map<String, ArtifactDefinition> existingArtifacts) {
+ List<ArtifactDefinition> artifactsToUpdate, List<ArtifactDefinition> artifactsToDelete,
+ Map<String, ArtifactDefinition> existingArtifacts) {
try {
if (!existingArtifacts.isEmpty()) {
extractedArtifacts.stream()
@@ -377,11 +407,12 @@ public class ServiceImportParseLogic {
}
- protected void processNodeTypeArtifact(List<ArtifactDefinition> artifactsToUpload, List<ArtifactDefinition> artifactsToUpdate, Map<String, ArtifactDefinition> existingArtifacts, ArtifactDefinition currNewArtifact) {
+ protected void processNodeTypeArtifact(List<ArtifactDefinition> artifactsToUpload, List<ArtifactDefinition> artifactsToUpdate,
+ Map<String, ArtifactDefinition> existingArtifacts, ArtifactDefinition currNewArtifact) {
Optional<ArtifactDefinition> foundArtifact = existingArtifacts.values()
- .stream()
- .filter(a -> a.getArtifactName().equals(currNewArtifact.getArtifactName()))
- .findFirst();
+ .stream()
+ .filter(a -> a.getArtifactName().equals(currNewArtifact.getArtifactName()))
+ .findFirst();
if (foundArtifact.isPresent()) {
if (foundArtifact.get().getArtifactType().equals(currNewArtifact.getArtifactType())) {
updateFoundArtifact(artifactsToUpdate, currNewArtifact, foundArtifact.get());
@@ -390,28 +421,29 @@ public class ServiceImportParseLogic {
} else {
log.debug("Can't upload two artifact with the same name {}.", currNewArtifact.getArtifactName());
throw new ComponentException(ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR,
- currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(),
- foundArtifact.get().getArtifactType());
+ currNewArtifact.getArtifactName(), currNewArtifact.getArtifactType(),
+ foundArtifact.get().getArtifactType());
}
}
}
- protected void updateFoundArtifact(List<ArtifactDefinition> artifactsToUpdate, ArtifactDefinition currNewArtifact, ArtifactDefinition foundArtifact) {
+ protected void updateFoundArtifact(List<ArtifactDefinition> artifactsToUpdate, ArtifactDefinition currNewArtifact,
+ ArtifactDefinition foundArtifact) {
if (!foundArtifact.getArtifactChecksum().equals(currNewArtifact.getArtifactChecksum())) {
foundArtifact.setPayload(currNewArtifact.getPayloadData());
foundArtifact.setPayloadData(
- Base64.encodeBase64String(currNewArtifact.getPayloadData()));
+ Base64.encodeBase64String(currNewArtifact.getPayloadData()));
foundArtifact.setArtifactChecksum(GeneralUtility
- .calculateMD5Base64EncodedByByteArray(currNewArtifact.getPayloadData()));
+ .calculateMD5Base64EncodedByByteArray(currNewArtifact.getPayloadData()));
artifactsToUpdate.add(foundArtifact);
}
}
public void addNonMetaCreatedArtifactsToSupportRollback(ArtifactOperationInfo operation,
- List<ArtifactDefinition> createdArtifacts,
- Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts) {
+ List<ArtifactDefinition> createdArtifacts,
+ Either<Either<ArtifactDefinition, Operation>, ResponseFormat> eitherNonMetaArtifacts) {
if (ArtifactsBusinessLogic.ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()) && createdArtifacts != null
- && eitherNonMetaArtifacts.isLeft()) {
+ && eitherNonMetaArtifacts.isLeft()) {
Either<ArtifactDefinition, Operation> eitherResult = eitherNonMetaArtifacts.left().value();
if (eitherResult.isLeft()) {
createdArtifacts.add(eitherResult.left().value());
@@ -439,7 +471,7 @@ public class ServiceImportParseLogic {
}
protected boolean isfillGroupMemebersRecursivlyStopCondition(String groupName, Map<String, GroupDefinition> allGroups,
- Set<String> allGroupMembers) {
+ Set<String> allGroupMembers) {
boolean stop = false;
// In Case Not Group Stop
@@ -456,26 +488,27 @@ public class ServiceImportParseLogic {
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());
+ // 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) {
+ Map<String, NodeTypeInfo> nodesInfo) {
Resource complexVfc = buildComplexVfcMetadata(resource, csarInfo, nodeName, nodesInfo);
log.debug("************* Going to validate complex VFC from yaml {}", complexVfc.getName());
csarInfo.addNodeToQueue(nodeName);
return validateResourceBeforeCreate(complexVfc, csarInfo.getModifier(),
- AuditingActionEnum.IMPORT_RESOURCE, true, csarInfo);
+ AuditingActionEnum.IMPORT_RESOURCE, true, csarInfo);
}
- public Resource validateResourceBeforeCreate(Resource resource, User user, AuditingActionEnum actionEnum, boolean inTransaction, CsarInfo csarInfo) {
+ public Resource validateResourceBeforeCreate(Resource resource, User user, AuditingActionEnum actionEnum, boolean inTransaction,
+ CsarInfo csarInfo) {
validateResourceFieldsBeforeCreate(user, resource, actionEnum, inTransaction);
validateCapabilityTypesCreate(user, getCapabilityTypeOperation(), resource, actionEnum, inTransaction);
@@ -492,7 +525,7 @@ public class ServiceImportParseLogic {
resourceSystemName = resource.getSystemName();
}
resource.setToscaResourceName(CommonBeUtils
- .generateToscaResourceName(resource.getResourceType().name().toLowerCase(), resourceSystemName));
+ .generateToscaResourceName(resource.getResourceType().name().toLowerCase(), resourceSystemName));
}
// Generate invariant UUID - must be here and not in operation since it
@@ -505,7 +538,7 @@ public class ServiceImportParseLogic {
}
protected Either<Boolean, ResponseFormat> validateResourceType(User user, Resource resource,
- AuditingActionEnum actionEnum) {
+ AuditingActionEnum actionEnum) {
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
if (resource.getResourceType() == null) {
log.debug("Invalid resource type for resource");
@@ -517,7 +550,7 @@ public class ServiceImportParseLogic {
}
protected Either<Boolean, ResponseFormat> validateLifecycleTypesCreate(User user, Resource resource,
- AuditingActionEnum actionEnum) {
+ AuditingActionEnum actionEnum) {
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
if (resource.getInterfaces() != null && resource.getInterfaces().size() > 0) {
log.debug("validate interface lifecycle Types Exist");
@@ -526,20 +559,20 @@ public class ServiceImportParseLogic {
InterfaceDefinition interfaceDefinition = intItr.next();
String intType = interfaceDefinition.getUniqueId();
Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation
- .getInterface(intType);
+ .getInterface(intType);
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
BeEcompErrorManager.getInstance().logBeGraphObjectMissingError(
- "Create Resource - validateLifecycleTypesCreate", "Interface", intType);
+ "Create Resource - validateLifecycleTypesCreate", "Interface", intType);
log.debug("Lifecycle Type: {} is required by resource: {} but does not exist in the DB",
- intType, resource.getName());
+ intType, resource.getName());
BeEcompErrorManager.getInstance()
- .logBeDaoSystemError("Create Resource - validateLifecycleTypesCreate");
+ .logBeDaoSystemError("Create Resource - validateLifecycleTypesCreate");
log.debug("request to data model failed with error: {}",
- eitherCapTypeFound.right().value().name());
+ eitherCapTypeFound.right().value().name());
}
ResponseFormat errorResponse = componentsUtils
- .getResponseFormat(ActionStatus.MISSING_LIFECYCLE_TYPE, intType);
+ .getResponseFormat(ActionStatus.MISSING_LIFECYCLE_TYPE, intType);
eitherResult = Either.right(errorResponse);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
}
@@ -549,8 +582,9 @@ public class ServiceImportParseLogic {
}
public Either<Boolean, ResponseFormat> validateCapabilityTypesCreate(User user,
- ICapabilityTypeOperation capabilityTypeOperation, Resource resource, AuditingActionEnum actionEnum,
- boolean inTransaction) {
+ ICapabilityTypeOperation capabilityTypeOperation, Resource resource,
+ AuditingActionEnum actionEnum,
+ boolean inTransaction) {
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
if (resource.getCapabilities() != null && resource.getCapabilities().size() > 0) {
@@ -559,7 +593,7 @@ public class ServiceImportParseLogic {
for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
eitherResult = validateCapabilityTypeExists(user, capabilityTypeOperation, resource, actionEnum,
- eitherResult, typeEntry, inTransaction);
+ eitherResult, typeEntry, inTransaction);
if (eitherResult.isRight()) {
return Either.right(eitherResult.right().value());
}
@@ -569,7 +603,7 @@ public class ServiceImportParseLogic {
log.debug("validate capability Types Exist - requirements section");
for (String type : resource.getRequirements().keySet()) {
eitherResult = validateCapabilityTypeExists(user, capabilityTypeOperation, resource,
- resource.getRequirements().get(type), actionEnum, eitherResult, type, inTransaction);
+ resource.getRequirements().get(type), actionEnum, eitherResult, type, inTransaction);
if (eitherResult.isRight()) {
return Either.right(eitherResult.right().value());
}
@@ -579,24 +613,26 @@ public class ServiceImportParseLogic {
}
protected Either<Boolean, ResponseFormat> validateCapabilityTypeExists(User user,
- ICapabilityTypeOperation capabilityTypeOperation, Resource resource, AuditingActionEnum actionEnum,
- Either<Boolean, ResponseFormat> eitherResult, Map.Entry<String, List<CapabilityDefinition>> typeEntry,
- boolean inTransaction) {
+ ICapabilityTypeOperation capabilityTypeOperation, Resource resource,
+ AuditingActionEnum actionEnum,
+ Either<Boolean, ResponseFormat> eitherResult,
+ Map.Entry<String, List<CapabilityDefinition>> typeEntry,
+ boolean inTransaction) {
Either<CapabilityTypeDefinition, StorageOperationStatus> eitherCapTypeFound = capabilityTypeOperation
- .getCapabilityType(typeEntry.getKey(), inTransaction);
+ .getCapabilityType(typeEntry.getKey(), inTransaction);
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
BeEcompErrorManager.getInstance().logBeGraphObjectMissingError(
- CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES, "Capability Type", typeEntry.getKey());
+ CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES, "Capability Type", typeEntry.getKey());
log.debug("Capability Type: {} is required by resource: {} but does not exist in the DB",
- typeEntry.getKey(), resource.getName());
+ typeEntry.getKey(), resource.getName());
BeEcompErrorManager.getInstance()
- .logBeDaoSystemError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES);
+ .logBeDaoSystemError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES);
}
log.debug("Trying to get capability type {} failed with error: {}", typeEntry.getKey(),
- eitherCapTypeFound.right().value().name());
+ eitherCapTypeFound.right().value().name());
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_CAPABILITY_TYPE,
- typeEntry.getKey());
+ typeEntry.getKey());
eitherResult = Either.right(errorResponse);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
return Either.right(eitherResult.right().value());
@@ -633,9 +669,11 @@ public class ServiceImportParseLogic {
}
protected Either<Boolean, ResponseFormat> validateCapabilityTypeExists(User user,
- ICapabilityTypeOperation capabilityTypeOperation, Resource resource, List<?> validationObjects,
- AuditingActionEnum actionEnum, Either<Boolean, ResponseFormat> eitherResult, String type,
- boolean inTransaction) {
+ ICapabilityTypeOperation capabilityTypeOperation, Resource resource,
+ List<?> validationObjects,
+ AuditingActionEnum actionEnum,
+ Either<Boolean, ResponseFormat> eitherResult, String type,
+ boolean inTransaction) {
try {
Either<CapabilityTypeDefinition, StorageOperationStatus> eitherCapTypeFound = capabilityTypeOperation
.getCapabilityType(type, inTransaction);
@@ -669,7 +707,7 @@ public class ServiceImportParseLogic {
}
protected Either<Boolean, ResponseFormat> validateResourceFieldsBeforeCreate(User user, Resource resource,
- AuditingActionEnum actionEnum, boolean inTransaction) {
+ AuditingActionEnum actionEnum, boolean inTransaction) {
serviceBusinessLogic.validateComponentFieldsBeforeCreate(user, resource, actionEnum);
// validate category
log.debug("validate category");
@@ -717,19 +755,19 @@ public class ServiceImportParseLogic {
return Either.left(true);
}
- protected void validateDerivedFromExist(User user, Resource resource, AuditingActionEnum actionEnum) {
+ protected void validateDerivedFromExist(User user, Resource resource, AuditingActionEnum actionEnum) {
if (resource.getDerivedFrom() == null || resource.getDerivedFrom().isEmpty()) {
return;
}
String templateName = resource.getDerivedFrom().get(0);
Either<Boolean, StorageOperationStatus> dataModelResponse = toscaOperationFacade
- .validateToscaResourceNameExists(templateName);
+ .validateToscaResourceNameExists(templateName);
if (dataModelResponse.isRight()) {
StorageOperationStatus storageStatus = dataModelResponse.right().value();
BeEcompErrorManager.getInstance().logBeDaoSystemError("Create Resource - validateDerivedFromExist");
log.debug("request to data model failed with error: {}", storageStatus);
ResponseFormat responseFormat = componentsUtils
- .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus), resource);
+ .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus), resource);
log.trace("audit before sending response");
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw new ComponentException(componentsUtils.convertFromStorageResponse(storageStatus));
@@ -742,12 +780,12 @@ public class ServiceImportParseLogic {
}
protected void validateLicenseType(User user, Resource resource,
- AuditingActionEnum actionEnum) {
+ AuditingActionEnum actionEnum) {
log.debug("validate licenseType");
String licenseType = resource.getLicenseType();
if (licenseType != null) {
List<String> licenseTypes = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getLicenseTypes();
+ .getLicenseTypes();
if (!licenseTypes.contains(licenseType)) {
log.debug("License type {} isn't configured", licenseType);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
@@ -776,18 +814,18 @@ public class ServiceImportParseLogic {
if (!ValidationUtils.validateResourceVendorModelNumberLength(resourceVendorModelNumber)) {
log.info("resource vendor model number exceeds limit.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(
- ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
- "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
+ ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
+ "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
throw new ComponentException(ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
- "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
+ "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
}
// resource vendor model number is currently validated as vendor
// name
if (!ValidationUtils.validateVendorName(resourceVendorModelNumber)) {
log.info("resource vendor model number is not valid.");
ResponseFormat errorResponse = componentsUtils
- .getResponseFormat(ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER);
+ .getResponseFormat(ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
throw new ComponentException(ActionStatus.INVALID_RESOURCE_VENDOR_MODEL_NUMBER);
}
@@ -812,7 +850,7 @@ public class ServiceImportParseLogic {
if (!ValidationUtils.validateVendorReleaseLength(vendorRelease)) {
log.info("vendor release exceds limit.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(
- ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
+ ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
throw new ComponentException(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
}
@@ -827,16 +865,16 @@ public class ServiceImportParseLogic {
}
protected void validateCategory(User user, Resource resource,
- AuditingActionEnum actionEnum, boolean inTransaction) {
+ AuditingActionEnum actionEnum, boolean inTransaction) {
List<CategoryDefinition> categories = resource.getCategories();
if (CollectionUtils.isEmpty(categories)) {
log.debug(CATEGORY_IS_EMPTY);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw new ComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
if (categories.size() > 1) {
log.debug("Must be only one category for resource");
@@ -858,15 +896,15 @@ public class ServiceImportParseLogic {
if (!ValidationUtils.validateStringNotEmpty(category.getName())) {
log.debug(CATEGORY_IS_EMPTY);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw new ComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
if (!ValidationUtils.validateStringNotEmpty(subcategory.getName())) {
log.debug(CATEGORY_IS_EMPTY);
ResponseFormat responseFormat = componentsUtils.getResponseFormat(
- ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue());
+ ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw new ComponentException(ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -875,7 +913,7 @@ public class ServiceImportParseLogic {
}
protected void validateCategoryListed(CategoryDefinition category, SubCategoryDefinition subcategory,
- User user, Resource resource, AuditingActionEnum actionEnum, boolean inTransaction) {
+ User user, Resource resource, AuditingActionEnum actionEnum, boolean inTransaction) {
ResponseFormat responseFormat;
if (category != null && subcategory != null) {
try {
@@ -909,7 +947,7 @@ public class ServiceImportParseLogic {
subcategory, foundCategory.get().getSubcategories());
failOnInvalidCategory(user, resource, actionEnum);
}
- }catch(Exception e){
+ } catch (Exception e) {
log.debug("Exception occured when validateCategoryListed, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
@@ -919,14 +957,14 @@ public class ServiceImportParseLogic {
protected void failOnInvalidCategory(User user, Resource resource, AuditingActionEnum actionEnum) {
ResponseFormat responseFormat;
responseFormat = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INVALID_CATEGORY,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw new ComponentException(ActionStatus.COMPONENT_INVALID_CATEGORY,
- ComponentTypeEnum.RESOURCE.getValue());
+ ComponentTypeEnum.RESOURCE.getValue());
}
protected void validateVendorName(User user, Resource resource,
- AuditingActionEnum actionEnum) {
+ AuditingActionEnum actionEnum) {
String vendorName = resource.getVendorName();
if (!ValidationUtils.validateStringNotEmpty(vendorName)) {
log.info("vendor name is missing.");
@@ -938,15 +976,15 @@ public class ServiceImportParseLogic {
}
protected void validateVendorName(String vendorName, User user, Resource resource,
- AuditingActionEnum actionEnum) {
+ AuditingActionEnum actionEnum) {
if (vendorName != null) {
if (!ValidationUtils.validateVendorNameLength(vendorName)) {
log.info("vendor name exceds limit.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
- "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
+ "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
throw new ComponentException(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
- "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
+ "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
}
if (!ValidationUtils.validateVendorName(vendorName)) {
@@ -976,8 +1014,8 @@ public class ServiceImportParseLogic {
cvfc.setVendorRelease(resourceVf.getVendorRelease());
cvfc.setResourceVendorModelNumber(resourceVf.getResourceVendorModelNumber());
cvfc.setToscaResourceName(
- buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(), nodeName)
- .getLeft());
+ buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(), nodeName)
+ .getLeft());
cvfc.setInvariantUUID(UniqueIdBuilder.buildInvariantUUID());
List<String> tags = new ArrayList<>();
@@ -1002,7 +1040,7 @@ public class ServiceImportParseLogic {
private String buildCvfcName(String resourceVfName, String nodeName) {
String nameWithouNamespacePrefix = nodeName
- .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
+ .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
String[] findTypes = nameWithouNamespacePrefix.split("\\.");
String resourceType = findTypes[0];
String resourceName = resourceVfName + "-" + nameWithouNamespacePrefix.substring(resourceType.length() + 1);
@@ -1014,15 +1052,15 @@ public class ServiceImportParseLogic {
}
public UploadResourceInfo fillResourceMetadata(String yamlName, Resource resourceVf,
- String nodeName, User user) {
+ String nodeName, User user) {
UploadResourceInfo resourceMetaData = new UploadResourceInfo();
// validate nodetype name prefix
if (!nodeName.startsWith(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX)) {
log.debug("invalid nodeName:{} does not start with {}.", nodeName,
- Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
+ Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
throw new ComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
- yamlName, resourceMetaData.getName(), nodeName);
+ yamlName, resourceMetaData.getName(), nodeName);
}
String actualName = this.getNodeTypeActualName(nodeName);
@@ -1038,9 +1076,9 @@ public class ServiceImportParseLogic {
// validating type
if (!ResourceTypeEnum.containsName(resourceType.toUpperCase())) {
log.debug("invalid resourceType:{} the type is not one of the valide types:{}.", resourceType.toUpperCase(),
- ResourceTypeEnum.values());
+ ResourceTypeEnum.values());
throw new ComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
- yamlName, resourceMetaData.getName(), nodeName);
+ yamlName, resourceMetaData.getName(), nodeName);
}
// Setting name
@@ -1076,7 +1114,7 @@ public class ServiceImportParseLogic {
protected String getNodeTypeActualName(String fullName) {
String nameWithouNamespacePrefix = fullName
- .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
+ .substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length());
String[] findTypes = nameWithouNamespacePrefix.split("\\.");
String resourceType = findTypes[0];
return nameWithouNamespacePrefix.substring(resourceType.length());
@@ -1090,8 +1128,9 @@ public class ServiceImportParseLogic {
}
public Either<RequirementDefinition, ResponseFormat> findAviableRequiremen(String regName, String yamlName,
- UploadComponentInstanceInfo uploadComponentInstanceInfo, ComponentInstance currentCompInstance,
- String capName) {
+ UploadComponentInstanceInfo uploadComponentInstanceInfo,
+ ComponentInstance currentCompInstance,
+ String capName) {
Map<String, List<RequirementDefinition>> comInstRegDefMap = currentCompInstance.getRequirements();
List<RequirementDefinition> list = comInstRegDefMap.get(capName);
RequirementDefinition validRegDef = null;
@@ -1100,7 +1139,7 @@ public class ServiceImportParseLogic {
for (RequirementDefinition reqDef : entry.getValue()) {
if (reqDef.getName().equals(regName)) {
if (reqDef.getMaxOccurrences() != null
- && !reqDef.getMaxOccurrences().equals(RequirementDataDefinition.MAX_OCCURRENCES)) {
+ && !reqDef.getMaxOccurrences().equals(RequirementDataDefinition.MAX_OCCURRENCES)) {
String leftOccurrences = reqDef.getLeftOccurrences();
if (leftOccurrences == null) {
leftOccurrences = reqDef.getMaxOccurrences();
@@ -1129,7 +1168,7 @@ public class ServiceImportParseLogic {
for (RequirementDefinition reqDef : list) {
if (reqDef.getName().equals(regName)) {
if (reqDef.getMaxOccurrences() != null
- && !reqDef.getMaxOccurrences().equals(RequirementDataDefinition.MAX_OCCURRENCES)) {
+ && !reqDef.getMaxOccurrences().equals(RequirementDataDefinition.MAX_OCCURRENCES)) {
String leftOccurrences = reqDef.getLeftOccurrences();
if (leftOccurrences == null) {
leftOccurrences = reqDef.getMaxOccurrences();
@@ -1152,14 +1191,14 @@ public class ServiceImportParseLogic {
}
if (validRegDef == null) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE,
- yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
+ yamlName, uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
return Either.right(responseFormat);
}
return Either.left(validRegDef);
}
public CapabilityDefinition findAvailableCapabilityByTypeOrName(RequirementDefinition validReq,
- ComponentInstance currentCapCompInstance, UploadReqInfo uploadReqInfo) {
+ ComponentInstance currentCapCompInstance, UploadReqInfo uploadReqInfo) {
try {
if (null == uploadReqInfo.getCapabilityName()
|| validReq.getCapability().equals(uploadReqInfo.getCapabilityName())) {
@@ -1167,7 +1206,7 @@ public class ServiceImportParseLogic {
return findAvailableCapability(validReq, currentCapCompInstance);
}
return findAvailableCapability(validReq, currentCapCompInstance, uploadReqInfo);
- }catch (Exception e){
+ } catch (Exception e) {
log.debug("Exception occured when findAvailableCapabilityByTypeOrName, error is:{}", e.getMessage(), e);
throw new ComponentException(ActionStatus.GENERAL_ERROR);
}
@@ -1181,7 +1220,7 @@ public class ServiceImportParseLogic {
for (CapabilityDefinition cap : capList) {
if (isBoundedByOccurrences(cap)) {
String leftOccurrences = cap.getLeftOccurrences() != null ?
- cap.getLeftOccurrences() : cap.getMaxOccurrences();
+ cap.getLeftOccurrences() : cap.getMaxOccurrences();
int left = Integer.parseInt(leftOccurrences);
if (left > 0) {
--left;
@@ -1197,14 +1236,14 @@ public class ServiceImportParseLogic {
}
protected CapabilityDefinition findAvailableCapability(RequirementDefinition validReq,
- ComponentInstance currentCapCompInstance, UploadReqInfo uploadReqInfo) {
+ ComponentInstance currentCapCompInstance, UploadReqInfo uploadReqInfo) {
CapabilityDefinition cap = null;
Map<String, List<CapabilityDefinition>> capMap = currentCapCompInstance.getCapabilities();
if (!capMap.containsKey(validReq.getCapability())) {
return null;
}
Optional<CapabilityDefinition> capByName = capMap.get(validReq.getCapability()).stream()
- .filter(p -> p.getName().equals(uploadReqInfo.getCapabilityName())).findAny();
+ .filter(p -> p.getName().equals(uploadReqInfo.getCapabilityName())).findAny();
if (!capByName.isPresent()) {
return null;
}
@@ -1249,7 +1288,9 @@ public class ServiceImportParseLogic {
return parametersView;
}
- protected void addValidComponentInstanceCapabilities(String key, List<UploadCapInfo> capabilities, String resourceId, Map<String, List<CapabilityDefinition>> defaultCapabilities, Map<String, List<CapabilityDefinition>> validCapabilitiesMap){
+ protected void addValidComponentInstanceCapabilities(String key, List<UploadCapInfo> capabilities, String resourceId,
+ Map<String, List<CapabilityDefinition>> defaultCapabilities,
+ Map<String, List<CapabilityDefinition>> validCapabilitiesMap) {
String capabilityType = capabilities.get(0).getType();
if (defaultCapabilities.containsKey(capabilityType)) {
CapabilityDefinition defaultCapability = getCapability(resourceId, defaultCapabilities, capabilityType);
@@ -1262,18 +1303,19 @@ public class ServiceImportParseLogic {
}
}
- protected CapabilityDefinition getCapability(String resourceId, Map<String, List<CapabilityDefinition>> defaultCapabilities, String capabilityType) {
+ protected CapabilityDefinition getCapability(String resourceId, Map<String, List<CapabilityDefinition>> defaultCapabilities,
+ String capabilityType) {
CapabilityDefinition defaultCapability;
if (isNotEmpty(defaultCapabilities.get(capabilityType).get(0).getProperties())) {
defaultCapability = defaultCapabilities.get(capabilityType).get(0);
} else {
Either<Component, StorageOperationStatus> getFullComponentRes = toscaOperationFacade
- .getToscaFullElement(resourceId);
+ .getToscaFullElement(resourceId);
if (getFullComponentRes.isRight()) {
log.debug("Failed to get full component {}. Status is {}. ", resourceId,
- getFullComponentRes.right().value());
+ getFullComponentRes.right().value());
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_NOT_FOUND,
- resourceId));
+ resourceId));
}
defaultCapability = getFullComponentRes.left().value().getCapabilities().get(capabilityType).get(0);
}
@@ -1282,12 +1324,12 @@ public class ServiceImportParseLogic {
protected void validateCapabilityProperties(List<UploadCapInfo> capabilities, String resourceId, CapabilityDefinition defaultCapability) {
if (CollectionUtils.isEmpty(defaultCapability.getProperties())
- && isNotEmpty(capabilities.get(0).getProperties())) {
+ && isNotEmpty(capabilities.get(0).getProperties())) {
log.debug("Failed to validate capability {} of component {}. Property list is empty. ",
- defaultCapability.getName(), resourceId);
+ defaultCapability.getName(), resourceId);
log.debug(
- "Failed to update capability property values. Property list of fetched capability {} is empty. ",
- defaultCapability.getName());
+ "Failed to update capability property values. Property list of fetched capability {} is empty. ",
+ defaultCapability.getName());
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, resourceId));
} else if (isNotEmpty(capabilities.get(0).getProperties())) {
validateUniquenessUpdateUploadedComponentInstanceCapability(defaultCapability, capabilities.get(0));
@@ -1295,11 +1337,11 @@ public class ServiceImportParseLogic {
}
protected void validateUniquenessUpdateUploadedComponentInstanceCapability(
- CapabilityDefinition defaultCapability, UploadCapInfo uploadedCapability) {
+ CapabilityDefinition defaultCapability, UploadCapInfo uploadedCapability) {
List<ComponentInstanceProperty> validProperties = new ArrayList<>();
Map<String, PropertyDefinition> defaultProperties = defaultCapability.getProperties().stream()
- .collect(toMap(PropertyDefinition::getName, Function
- .identity()));
+ .collect(toMap(PropertyDefinition::getName, Function
+ .identity()));
List<UploadPropInfo> uploadedProperties = uploadedCapability.getProperties();
for (UploadPropInfo property : uploadedProperties) {
String propertyName = property.getName().toLowerCase();
@@ -1307,7 +1349,7 @@ public class ServiceImportParseLogic {
ComponentInstanceProperty validProperty;
if (defaultProperties.containsKey(propertyName) && propertTypeEqualsTo(defaultProperties, propertyName, propertyType)) {
throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NAME_ALREADY_EXISTS,
- propertyName));
+ propertyName));
}
validProperty = new ComponentInstanceProperty();
validProperty.setName(propertyName);
@@ -1326,24 +1368,24 @@ public class ServiceImportParseLogic {
}
public void setDeploymentArtifactsPlaceHolder(Component component, User user) {
- if(component instanceof Service){
+ if (component instanceof Service) {
Service service = (Service) component;
Map<String, ArtifactDefinition> artifactMap = service.getDeploymentArtifacts();
if (artifactMap == null) {
artifactMap = new HashMap<>();
}
service.setDeploymentArtifacts(artifactMap);
- }else if(component instanceof Resource){
+ } else if (component instanceof Resource) {
Resource resource = (Resource) component;
Map<String, ArtifactDefinition> artifactMap = resource.getDeploymentArtifacts();
if (artifactMap == null) {
artifactMap = new HashMap<>();
}
Map<String, Object> deploymentResourceArtifacts = ConfigurationManager.getConfigurationManager()
- .getConfiguration().getDeploymentResourceArtifacts();
+ .getConfiguration().getDeploymentResourceArtifacts();
if (deploymentResourceArtifacts != null) {
Map<String, ArtifactDefinition> finalArtifactMap = artifactMap;
- deploymentResourceArtifacts.forEach((k, v)->processDeploymentResourceArtifacts(user, resource, finalArtifactMap, k,v));
+ deploymentResourceArtifacts.forEach((k, v) -> processDeploymentResourceArtifacts(user, resource, finalArtifactMap, k, v));
}
resource.setDeploymentArtifacts(artifactMap);
}
@@ -1361,15 +1403,15 @@ public class ServiceImportParseLogic {
}
} else {
log.info("resource types for artifact placeholder {} were not defined. default is all resources",
- k);
+ k);
}
if (shouldCreateArtifact) {
if (serviceBusinessLogic.artifactsBusinessLogic != null) {
ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic.createArtifactPlaceHolderInfo(
- resource.getUniqueId(), k, (Map<String, Object>) v,
- user, ArtifactGroupTypeEnum.DEPLOYMENT);
+ resource.getUniqueId(), k, (Map<String, Object>) v,
+ user, ArtifactGroupTypeEnum.DEPLOYMENT);
if (artifactDefinition != null
- && !artifactMap.containsKey(artifactDefinition.getArtifactLabel())) {
+ && !artifactMap.containsKey(artifactDefinition.getArtifactLabel())) {
artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition);
}
}
@@ -1386,7 +1428,6 @@ public class ServiceImportParseLogic {
newResource.setDescription(oldResource.getDescription());
}
-
if (newResource.getContactId() == null) {
newResource.setContactId(oldResource.getContactId());
}
@@ -1396,7 +1437,7 @@ public class ServiceImportParseLogic {
}
protected Resource buildComplexVfcMetadata(CsarInfo csarInfo, String nodeName,
- Map<String, NodeTypeInfo> nodesInfo) {
+ Map<String, NodeTypeInfo> nodesInfo) {
Resource cvfc = new Resource();
NodeTypeInfo nodeTypeInfo = nodesInfo.get(nodeName);
cvfc.setName(buildCvfcName(csarInfo.getVfResourceName(), nodeName));
@@ -1413,8 +1454,8 @@ public class ServiceImportParseLogic {
cvfc.setVendorRelease("1.0");
cvfc.setResourceVendorModelNumber("");
cvfc.setToscaResourceName(
- buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(), nodeName)
- .getLeft());
+ buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(), nodeName)
+ .getLeft());
cvfc.setInvariantUUID(UniqueIdBuilder.buildInvariantUUID());
List<String> tags = new ArrayList<>();
@@ -1445,10 +1486,10 @@ public class ServiceImportParseLogic {
private void validateDerivedFromNotEmpty(User user, Resource resource, AuditingActionEnum actionEnum) {
log.debug("validate resource derivedFrom field");
if ((resource.getDerivedFrom() == null) || (resource.getDerivedFrom().isEmpty())
- || (resource.getDerivedFrom().get(0)) == null || (resource.getDerivedFrom().get(0).trim().isEmpty())) {
+ || (resource.getDerivedFrom().get(0)) == null || (resource.getDerivedFrom().get(0).trim().isEmpty())) {
log.info("derived from (template) field is missing for the resource");
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
+ .getResponseFormat(ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw new ComponentException(ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -1457,10 +1498,10 @@ public class ServiceImportParseLogic {
public Service createInputsOnService(Service service, Map<String, InputDefinition> inputs) {
List<InputDefinition> resourceProperties = service.getInputs();
- if (MapUtils.isNotEmpty(inputs)|| isNotEmpty(resourceProperties)) {
+ if (MapUtils.isNotEmpty(inputs) || isNotEmpty(resourceProperties)) {
Either<List<InputDefinition>, ResponseFormat> createInputs = inputsBusinessLogic.createInputsInGraph(inputs,
- service);
+ service);
if (createInputs.isRight()) {
throw new ComponentException(createInputs.right().value());
}
@@ -1468,10 +1509,10 @@ public class ServiceImportParseLogic {
return service;
}
Either<Service, StorageOperationStatus> updatedResource = toscaOperationFacade
- .getToscaElement(service.getUniqueId());
+ .getToscaElement(service.getUniqueId());
if (updatedResource.isRight()) {
throw new ComponentException(componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, ComponentTypeEnum.SERVICE));
+ componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, ComponentTypeEnum.SERVICE));
}
return updatedResource.left().value();
}
@@ -1481,18 +1522,18 @@ public class ServiceImportParseLogic {
// validate resource name uniqueness
log.debug("validate resource name");
Either<Boolean, StorageOperationStatus> eitherValidation = toscaOperationFacade.validateComponentNameExists(
- service.getName(), null, service.getComponentType());
+ service.getName(), null, service.getComponentType());
if (eitherValidation.isRight()) {
log.debug("Failed to validate component name {}. Status is {}. ", service.getName(),
- eitherValidation.right().value());
+ eitherValidation.right().value());
ResponseFormat errorResponse = componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(eitherValidation.right().value()));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(eitherValidation.right().value()));
throw new ComponentException(errorResponse);
}
if (eitherValidation.left().value()) {
log.debug("resource with name: {}, already exists", service.getName());
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,
- ComponentTypeEnum.RESOURCE.getValue(), service.getName());
+ ComponentTypeEnum.RESOURCE.getValue(), service.getName());
throw new ComponentException(errorResponse);
}
@@ -1507,13 +1548,13 @@ public class ServiceImportParseLogic {
service.setHighestVersion(true);
}
return toscaOperationFacade.createToscaComponent(service)
- .left()
- .on(r->throwComponentExceptionByResource(r, service));
+ .left()
+ .on(r -> throwComponentExceptionByResource(r, service));
}
public Service throwComponentExceptionByResource(StorageOperationStatus status, Service service) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByComponent(
- componentsUtils.convertFromStorageResponse(status), service, ComponentTypeEnum.SERVICE);
+ componentsUtils.convertFromStorageResponse(status), service, ComponentTypeEnum.SERVICE);
throw new ComponentException(responseFormat);
}
@@ -1527,79 +1568,81 @@ public class ServiceImportParseLogic {
@SuppressWarnings("unchecked")
protected void setInformationalArtifactsPlaceHolder(Service service, User user) {
- Map<String, ArtifactDefinition> artifactMap = service.getArtifacts();
- if (artifactMap == null) {
- artifactMap = new HashMap<>();
- }
- String resourceUniqueId = service.getUniqueId();
- List<String> exludeResourceCategory = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getExcludeResourceCategory();
- List<String> exludeResourceType = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getExcludeResourceType();
- Map<String, Object> informationalResourceArtifacts = ConfigurationManager.getConfigurationManager()
- .getConfiguration().getInformationalResourceArtifacts();
- List<CategoryDefinition> categories = service.getCategories();
- boolean isCreateArtifact = true;
- if (exludeResourceCategory != null) {
- String category = categories.get(0).getName();
- isCreateArtifact = exludeResourceCategory.stream().noneMatch(e -> e.equalsIgnoreCase(category));
- }
-
- if (informationalResourceArtifacts != null && isCreateArtifact) {
- Set<String> keys = informationalResourceArtifacts.keySet();
- for (String informationalResourceArtifactName : keys) {
- Map<String, Object> artifactInfoMap = (Map<String, Object>) informationalResourceArtifacts
- .get(informationalResourceArtifactName);
- if(serviceBusinessLogic.artifactsBusinessLogic!=null){
- ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic.createArtifactPlaceHolderInfo(
- resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user,
- ArtifactGroupTypeEnum.INFORMATIONAL);
- artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition);
- }
+ Map<String, ArtifactDefinition> artifactMap = service.getArtifacts();
+ if (artifactMap == null) {
+ artifactMap = new HashMap<>();
+ }
+ String resourceUniqueId = service.getUniqueId();
+ List<String> exludeResourceCategory = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getExcludeResourceCategory();
+ List<String> exludeResourceType = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getExcludeResourceType();
+ Map<String, Object> informationalResourceArtifacts = ConfigurationManager.getConfigurationManager()
+ .getConfiguration().getInformationalResourceArtifacts();
+ List<CategoryDefinition> categories = service.getCategories();
+ boolean isCreateArtifact = true;
+ if (exludeResourceCategory != null) {
+ String category = categories.get(0).getName();
+ isCreateArtifact = exludeResourceCategory.stream().noneMatch(e -> e.equalsIgnoreCase(category));
+ }
+
+ if (informationalResourceArtifacts != null && isCreateArtifact) {
+ Set<String> keys = informationalResourceArtifacts.keySet();
+ for (String informationalResourceArtifactName : keys) {
+ Map<String, Object> artifactInfoMap = (Map<String, Object>) informationalResourceArtifacts
+ .get(informationalResourceArtifactName);
+ if (serviceBusinessLogic.artifactsBusinessLogic != null) {
+ ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic.createArtifactPlaceHolderInfo(
+ resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user,
+ ArtifactGroupTypeEnum.INFORMATIONAL);
+ artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition);
}
}
- service.setArtifacts(artifactMap);
+ }
+ service.setArtifacts(artifactMap);
}
- public void rollback(boolean inTransaction, Service service, List<ArtifactDefinition> createdArtifacts, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
- if(!inTransaction) {
+ public void rollback(boolean inTransaction, Service service, List<ArtifactDefinition> createdArtifacts,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
+ if (!inTransaction) {
serviceBusinessLogic.janusGraphDao.rollback();
}
if (isNotEmpty(createdArtifacts) && isNotEmpty(nodeTypesNewCreatedArtifacts)) {
createdArtifacts.addAll(nodeTypesNewCreatedArtifacts);
- log.debug("Found {} newly created artifacts to deleted, the component name: {}",createdArtifacts.size(), service.getName());
+ log.debug("Found {} newly created artifacts to deleted, the component name: {}", createdArtifacts.size(), service.getName());
}
}
- public Map<String,Object> getNodeTypesFromTemplate(Map<String, Object> mappedToscaTemplate) {
+ public Map<String, Object> getNodeTypesFromTemplate(Map<String, Object> mappedToscaTemplate) {
return ImportUtils.findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES)
- .left().orValue(HashMap::new);
+ .left().orValue(HashMap::new);
}
private Resource nodeForceCertification(Resource resource, User user,
LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) {
return lifecycleBusinessLogic.forceResourceCertification(resource, user, lifecycleChangeInfo, inTransaction,
- needLock);
+ needLock);
}
private Resource nodeFullCertification(String uniqueId, User user,
LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) {
- Either<Resource, ResponseFormat> resourceResponse = lifecycleBusinessLogic.changeState(uniqueId, user, LifeCycleTransitionEnum.CERTIFY, lifecycleChangeInfo,
+ Either<Resource, ResponseFormat> resourceResponse = lifecycleBusinessLogic
+ .changeState(uniqueId, user, LifeCycleTransitionEnum.CERTIFY, lifecycleChangeInfo,
inTransaction, needLock);
- if(resourceResponse.isRight()){
+ if (resourceResponse.isRight()) {
throw new ByResponseFormatComponentException(resourceResponse.right().value());
}
return resourceResponse.left().value();
}
public Either<Boolean, ResponseFormat> validateNestedDerivedFromDuringUpdate(Resource currentResource,
- Resource updateInfoResource, boolean hasBeenCertified) {
+ Resource updateInfoResource, boolean hasBeenCertified) {
List<String> currentDerivedFrom = currentResource.getDerivedFrom();
List<String> updatedDerivedFrom = updateInfoResource.getDerivedFrom();
if (currentDerivedFrom == null || currentDerivedFrom.isEmpty() || updatedDerivedFrom == null
- || updatedDerivedFrom.isEmpty()) {
+ || updatedDerivedFrom.isEmpty()) {
log.trace("Update normative types");
return Either.left(true);
}
@@ -1612,7 +1655,7 @@ public class ServiceImportParseLogic {
validateDerivedFromExist(null, updateInfoResource, null);
} else {
Either<Boolean, ResponseFormat> validateDerivedFromExtending = validateDerivedFromExtending(null,
- currentResource, updateInfoResource, null);
+ currentResource, updateInfoResource, null);
if (validateDerivedFromExtending.isRight() || !validateDerivedFromExtending.left().value()) {
log.debug("Derived from cannot be updated if it doesnt inherits directly or extends inheritance");
@@ -1624,18 +1667,18 @@ public class ServiceImportParseLogic {
}
protected Either<Boolean, ResponseFormat> validateDerivedFromExtending(User user, Resource currentResource,
- Resource updateInfoResource, AuditingActionEnum actionEnum) {
+ Resource updateInfoResource, AuditingActionEnum actionEnum) {
String currentTemplateName = currentResource.getDerivedFrom().get(0);
String updatedTemplateName = updateInfoResource.getDerivedFrom().get(0);
Either<Boolean, StorageOperationStatus> dataModelResponse = toscaOperationFacade
- .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName);
+ .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName);
if (dataModelResponse.isRight()) {
StorageOperationStatus storageStatus = dataModelResponse.right().value();
BeEcompErrorManager.getInstance()
- .logBeDaoSystemError("Create/Update Resource - validateDerivingFromExtendingType");
+ .logBeDaoSystemError("Create/Update Resource - validateDerivingFromExtendingType");
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(storageStatus), currentResource);
+ componentsUtils.convertFromStorageResponse(storageStatus), currentResource);
log.trace("audit before sending response");
componentsUtils.auditResource(responseFormat, user, currentResource, actionEnum);
return Either.right(responseFormat);
@@ -1643,9 +1686,9 @@ public class ServiceImportParseLogic {
if (!dataModelResponse.left().value()) {
log.info("resource template with name {} does not inherit as original {}", updatedTemplateName,
- currentTemplateName);
+ currentTemplateName);
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(ActionStatus.PARENT_RESOURCE_DOES_NOT_EXTEND);
+ .getResponseFormat(ActionStatus.PARENT_RESOURCE_DOES_NOT_EXTEND);
componentsUtils.auditResource(responseFormat, user, currentResource, actionEnum);
return Either.right(responseFormat);
@@ -1655,40 +1698,40 @@ public class ServiceImportParseLogic {
}
public void validateResourceFieldsBeforeUpdate(Resource currentResource, Resource updateInfoResource,
- boolean inTransaction, boolean isNested) {
+ boolean inTransaction, boolean isNested) {
validateFields(currentResource, updateInfoResource, inTransaction, isNested);
}
private void validateFields(Resource currentResource, Resource updateInfoResource, boolean inTransaction, boolean isNested) {
- boolean hasBeenCertified = ValidationUtils.hasBeenCertified(currentResource.getVersion());
- log.debug("validate resource name before update");
- validateResourceName(currentResource, updateInfoResource, hasBeenCertified, isNested);
- log.debug("validate description before update");
- if(serviceBusinessLogic.componentDescriptionValidator!=null){
- serviceBusinessLogic.componentDescriptionValidator.validateAndCorrectField(null, updateInfoResource, null);
- }
- log.debug("validate icon before update");
- log.debug("validate tags before update");
- if(serviceBusinessLogic.componentTagsValidator!=null){
- serviceBusinessLogic.componentTagsValidator.validateAndCorrectField(null, updateInfoResource, null);
- }
- log.debug("validate vendor name before update");
- log.debug("validate resource vendor model number before update");
- log.debug("validate vendor release before update");
- log.debug("validate contact info before update");
- if(serviceBusinessLogic.componentContactIdValidator!=null){
- serviceBusinessLogic.componentContactIdValidator.validateAndCorrectField(null, updateInfoResource, null);
- }
- log.debug(VALIDATE_DERIVED_BEFORE_UPDATE);
- log.debug("validate category before update");
+ boolean hasBeenCertified = ValidationUtils.hasBeenCertified(currentResource.getVersion());
+ log.debug("validate resource name before update");
+ validateResourceName(currentResource, updateInfoResource, hasBeenCertified, isNested);
+ log.debug("validate description before update");
+ if (serviceBusinessLogic.componentDescriptionValidator != null) {
+ serviceBusinessLogic.componentDescriptionValidator.validateAndCorrectField(null, updateInfoResource, null);
+ }
+ log.debug("validate icon before update");
+ log.debug("validate tags before update");
+ if (serviceBusinessLogic.componentTagsValidator != null) {
+ serviceBusinessLogic.componentTagsValidator.validateAndCorrectField(null, updateInfoResource, null);
+ }
+ log.debug("validate vendor name before update");
+ log.debug("validate resource vendor model number before update");
+ log.debug("validate vendor release before update");
+ log.debug("validate contact info before update");
+ if (serviceBusinessLogic.componentContactIdValidator != null) {
+ serviceBusinessLogic.componentContactIdValidator.validateAndCorrectField(null, updateInfoResource, null);
+ }
+ log.debug(VALIDATE_DERIVED_BEFORE_UPDATE);
+ log.debug("validate category before update");
}
protected void validateResourceName(Resource currentResource, Resource updateInfoResource,
- boolean hasBeenCertified, boolean isNested) {
+ boolean hasBeenCertified, boolean isNested) {
String resourceNameUpdated = updateInfoResource.getName();
if (!isResourceNameEquals(currentResource, updateInfoResource)) {
if (isNested || !hasBeenCertified) {
@@ -1699,7 +1742,7 @@ public class ServiceImportParseLogic {
} else {
log.info("Resource name: {}, cannot be updated once the resource has been certified once.",
- resourceNameUpdated);
+ resourceNameUpdated);
throw new ComponentException(ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED);
}
}
@@ -1712,34 +1755,34 @@ public class ServiceImportParseLogic {
return true;
}
return currentResource.getResourceType().equals(ResourceTypeEnum.VF) &&
- resourceNameUpdated.equals(addCvfcSuffixToResourceName(resourceNameCurrent));
+ resourceNameUpdated.equals(addCvfcSuffixToResourceName(resourceNameCurrent));
}
public Resource prepareResourceForUpdate(Resource oldResource, Resource newResource, User user,
- boolean inTransaction, boolean needLock) {
+ boolean inTransaction, boolean needLock) {
if (!ComponentValidationUtils.canWorkOnResource(oldResource, user.getUserId())) {
// checkout
return lifecycleBusinessLogic.changeState(
- oldResource.getUniqueId(), user, LifeCycleTransitionEnum.CHECKOUT,
- new LifecycleChangeInfoWithAction("update by import"), inTransaction, needLock)
- .left()
- .on(response -> failOnChangeState(response, user, oldResource, newResource));
+ oldResource.getUniqueId(), user, LifeCycleTransitionEnum.CHECKOUT,
+ new LifecycleChangeInfoWithAction("update by import"), inTransaction, needLock)
+ .left()
+ .on(response -> failOnChangeState(response, user, oldResource, newResource));
}
return oldResource;
}
protected Resource failOnChangeState(ResponseFormat response, User user, Resource oldResource, Resource newResource) {
- if(response.getRequestError() != null){
- log.info("resource {} cannot be updated. reason={}", oldResource.getUniqueId(),
- response.getFormattedMessage());
+ if (response.getRequestError() != null) {
+ log.info("resource {} cannot be updated. reason={}", oldResource.getUniqueId(),
+ response.getFormattedMessage());
- componentsUtils.auditResource(response, user, newResource, AuditingActionEnum.IMPORT_RESOURCE,
- ResourceVersionInfo.newBuilder()
- .state(oldResource.getLifecycleState().name())
- .version(oldResource.getVersion())
- .build());
- }
+ componentsUtils.auditResource(response, user, newResource, AuditingActionEnum.IMPORT_RESOURCE,
+ ResourceVersionInfo.newBuilder()
+ .state(oldResource.getLifecycleState().name())
+ .version(oldResource.getVersion())
+ .build());
+ }
throw new ComponentException(response);
}
@@ -1753,10 +1796,10 @@ public class ServiceImportParseLogic {
public Resource createInputsOnResource(Resource resource, Map<String, InputDefinition> inputs) {
List<InputDefinition> resourceProperties = resource.getInputs();
- if (MapUtils.isNotEmpty(inputs)|| isNotEmpty(resourceProperties)) {
+ if (MapUtils.isNotEmpty(inputs) || isNotEmpty(resourceProperties)) {
Either<List<InputDefinition>, ResponseFormat> createInputs = inputsBusinessLogic.createInputsInGraph(inputs,
- resource);
+ resource);
if (createInputs.isRight()) {
throw new ComponentException(createInputs.right().value());
}
@@ -1764,10 +1807,10 @@ public class ServiceImportParseLogic {
return resource;
}
Either<Resource, StorageOperationStatus> updatedResource = toscaOperationFacade
- .getToscaElement(resource.getUniqueId());
+ .getToscaElement(resource.getUniqueId());
if (updatedResource.isRight()) {
throw new ComponentException(componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource));
+ componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource));
}
return updatedResource.left().value();
}
@@ -1788,32 +1831,33 @@ public class ServiceImportParseLogic {
fillGroupsFinalFields(groupsToCreate);
if (isNotEmpty(groupsFromResource)) {
serviceBusinessLogic.groupBusinessLogic.addGroups(resource,
- groupsToCreate, true)
- .left()
- .on(serviceBusinessLogic::throwComponentException);
+ groupsToCreate, true)
+ .left()
+ .on(serviceBusinessLogic::throwComponentException);
} else {
serviceBusinessLogic.groupBusinessLogic.createGroups(resource,
- groupsToCreate, true)
- .left()
- .on(serviceBusinessLogic::throwComponentException);
+ groupsToCreate, true)
+ .left()
+ .on(serviceBusinessLogic::throwComponentException);
}
}
if (isNotEmpty(groupsToDelete)) {
serviceBusinessLogic.groupBusinessLogic.deleteGroups(resource, groupsToDelete)
- .left()
- .on(serviceBusinessLogic::throwComponentException);
+ .left()
+ .on(serviceBusinessLogic::throwComponentException);
}
if (isNotEmpty(groupsToUpdate)) {
serviceBusinessLogic.groupBusinessLogic.updateGroups(resource, groupsToUpdate, true)
- .left()
- .on(serviceBusinessLogic::throwComponentException);
+ .left()
+ .on(serviceBusinessLogic::throwComponentException);
}
}
- protected void addGroupsToCreateOrUpdate(List<GroupDefinition> groupsFromResource, List<GroupDefinition> groupsAsList, List<GroupDefinition> groupsToUpdate, List<GroupDefinition> groupsToCreate) {
+ protected void addGroupsToCreateOrUpdate(List<GroupDefinition> groupsFromResource, List<GroupDefinition> groupsAsList,
+ List<GroupDefinition> groupsToUpdate, List<GroupDefinition> groupsToCreate) {
for (GroupDefinition group : groupsAsList) {
Optional<GroupDefinition> op = groupsFromResource.stream()
- .filter(p -> p.getInvariantName().equalsIgnoreCase(group.getInvariantName())).findAny();
+ .filter(p -> p.getInvariantName().equalsIgnoreCase(group.getInvariantName())).findAny();
if (op.isPresent()) {
GroupDefinition groupToUpdate = op.get();
groupToUpdate.setMembers(group.getMembers());
@@ -1826,10 +1870,11 @@ public class ServiceImportParseLogic {
}
}
- protected void addGroupsToDelete(List<GroupDefinition> groupsFromResource, List<GroupDefinition> groupsAsList, List<GroupDefinition> groupsToDelete) {
+ protected void addGroupsToDelete(List<GroupDefinition> groupsFromResource, List<GroupDefinition> groupsAsList,
+ List<GroupDefinition> groupsToDelete) {
for (GroupDefinition group : groupsFromResource) {
Optional<GroupDefinition> op = groupsAsList.stream()
- .filter(p -> p.getName().equalsIgnoreCase(group.getName())).findAny();
+ .filter(p -> p.getName().equalsIgnoreCase(group.getName())).findAny();
if (!op.isPresent() && (group.getArtifacts() == null || group.getArtifacts().isEmpty())) {
groupsToDelete.add(group);
}
@@ -1861,24 +1906,25 @@ public class ServiceImportParseLogic {
return result;
}
- public void updateGroupMembers(Map<String, GroupDefinition> groups, GroupDefinition updatedGroupDefinition, Service component, List<ComponentInstance> componentInstances, String groupName, Map<String, String> members) {
+ public void updateGroupMembers(Map<String, GroupDefinition> groups, GroupDefinition updatedGroupDefinition, Service component,
+ List<ComponentInstance> componentInstances, String groupName, Map<String, String> members) {
Set<String> compInstancesNames = members.keySet();
if (CollectionUtils.isEmpty(componentInstances)) {
String membersAstString = compInstancesNames.stream().collect(joining(","));
log.debug("The members: {}, in group: {}, cannot be found in component {}. There are no component instances.",
- membersAstString, groupName, component.getNormalizedName());
+ membersAstString, groupName, component.getNormalizedName());
throw new ComponentException(componentsUtils.getResponseFormat(
- ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
- component.getNormalizedName(), getComponentTypeForResponse(component)));
+ ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
+ component.getNormalizedName(), getComponentTypeForResponse(component)));
}
// Find all component instances with the member names
Map<String, String> memberNames = componentInstances.stream()
- .collect(toMap(ComponentInstance::getName, ComponentInstance::getUniqueId));
+ .collect(toMap(ComponentInstance::getName, ComponentInstance::getUniqueId));
memberNames.putAll(groups.keySet().stream().collect(toMap(g -> g, g -> "")));
Map<String, String> relevantInstances = memberNames.entrySet().stream()
- .filter(n -> compInstancesNames.contains(n.getKey()))
- .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
+ .filter(n -> compInstancesNames.contains(n.getKey()))
+ .collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
if (relevantInstances == null || relevantInstances.size() != compInstancesNames.size()) {
@@ -1889,10 +1935,10 @@ public class ServiceImportParseLogic {
compInstancesNames.removeAll(foundMembers);
String membersAstString = compInstancesNames.stream().collect(joining(","));
log.debug("The members: {}, in group: {}, cannot be found in component: {}", membersAstString,
- groupName, component.getNormalizedName());
+ groupName, component.getNormalizedName());
throw new ComponentException(componentsUtils.getResponseFormat(
- ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
- component.getNormalizedName(), getComponentTypeForResponse(component)));
+ ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName,
+ component.getNormalizedName(), getComponentTypeForResponse(component)));
}
updatedGroupDefinition.setMembers(relevantInstances);
}
@@ -1912,7 +1958,7 @@ public class ServiceImportParseLogic {
// 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);
+ .getResponseFormat(ActionStatus.GROUP_HAS_CYCLIC_DEPENDENCY, groupAName);
result = Either.right(responseFormat);
}
}
@@ -1925,7 +1971,7 @@ public class ServiceImportParseLogic {
}
protected void fillAllGroupMemebersRecursivly(String groupName, Map<String, GroupDefinition> allGroups,
- Set<String> allGroupMembers) {
+ Set<String> allGroupMembers) {
// Found Cyclic dependency
if (isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)) {
@@ -1937,12 +1983,12 @@ public class ServiceImportParseLogic {
// 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());
+ // 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) {
@@ -1950,49 +1996,51 @@ public class ServiceImportParseLogic {
}
}
- public ImmutablePair<Resource, ActionStatus> createResourceFromNodeType(String nodeTypeYaml, UploadResourceInfo resourceMetaData, User creator, boolean isInTransaction, boolean needLock,
+ public ImmutablePair<Resource, ActionStatus> createResourceFromNodeType(String nodeTypeYaml, UploadResourceInfo resourceMetaData, User creator,
+ boolean isInTransaction, boolean needLock,
Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ boolean forceCertificationAllowed, CsarInfo csarInfo,
String nodeName, boolean isNested) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction(CERTIFICATION_ON_IMPORT,
- LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR);
+ LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR);
Function<Resource, Boolean> validator = resource -> validateResourceCreationFromNodeType(
- resource, creator);
+ resource, creator);
return resourceImportManager.importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator,
- lifecycleChangeInfo, isInTransaction, true, needLock, nodeTypeArtifactsToHandle,
- nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested);
+ lifecycleChangeInfo, isInTransaction, true, needLock, nodeTypeArtifactsToHandle,
+ nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested);
}
public ImmutablePair<Resource, ActionStatus> createNodeTypeResourceFromYaml(
- String yamlName, Map.Entry<String, Object> nodeNameValue, User user, Map<String, Object> mapToConvert,
- Service resourceVf, boolean needLock,
- Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
- List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo,
- boolean isNested) {
+ String yamlName, Map.Entry<String, Object> nodeNameValue, User user, Map<String, Object> mapToConvert,
+ Service resourceVf, boolean needLock,
+ Map<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo,
+ boolean isNested) {
UploadResourceInfo resourceMetaData = fillResourceMetadata(yamlName, resourceVf, nodeNameValue.getKey(), user);
String singleVfcYaml = buildNodeTypeYaml(nodeNameValue, mapToConvert,
- resourceMetaData.getResourceType(), csarInfo);
+ resourceMetaData.getResourceType(), csarInfo);
user = serviceBusinessLogic.validateUser(user, "CheckIn Resource", resourceVf, AuditingActionEnum.CHECKIN_RESOURCE, true);
return createResourceFromNodeType(singleVfcYaml, resourceMetaData, user, true, needLock,
- nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo,
- nodeNameValue.getKey(), isNested);
+ nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo,
+ nodeNameValue.getKey(), isNested);
}
protected UploadResourceInfo fillResourceMetadata(String yamlName, Service resourceVf,
- String nodeName, User user) {
+ String nodeName, User user) {
UploadResourceInfo resourceMetaData = new UploadResourceInfo();
// validate nodetype name prefix
if (!nodeName.startsWith(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX)) {
log.debug("invalid nodeName:{} does not start with {}.", nodeName,
- Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
+ Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX);
throw new ComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
- yamlName, resourceMetaData.getName(), nodeName);
+ yamlName, resourceMetaData.getName(), nodeName);
}
String actualName = this.getNodeTypeActualName(nodeName);
@@ -2008,9 +2056,9 @@ public class ServiceImportParseLogic {
// validating type
if (!ResourceTypeEnum.containsName(resourceType.toUpperCase())) {
log.debug("invalid resourceType:{} the type is not one of the valide types:{}.", resourceType.toUpperCase(),
- ResourceTypeEnum.values());
+ ResourceTypeEnum.values());
throw new ComponentException(ActionStatus.INVALID_NODE_TEMPLATE,
- yamlName, resourceMetaData.getName(), nodeName);
+ yamlName, resourceMetaData.getName(), nodeName);
}
// Setting name
@@ -2050,12 +2098,12 @@ public class ServiceImportParseLogic {
Either<Resource, ResponseFormat> result = null;
try {
if (resource.getLifecycleState() != LifecycleStateEnum.CERTIFIED && forceCertificationAllowed
- && lifecycleBusinessLogic.isFirstCertification(resource.getVersion())) {
+ && lifecycleBusinessLogic.isFirstCertification(resource.getVersion())) {
nodeForceCertification(resource, user, lifecycleChangeInfo, inTransaction, needLock);
}
if (resource.getLifecycleState() == LifecycleStateEnum.CERTIFIED) {
Either<ArtifactDefinition, Operation> eitherPopulated = serviceBusinessLogic.populateToscaArtifacts(
- resource, user, false, inTransaction, needLock);
+ resource, user, false, inTransaction, needLock);
return resource;
}
return nodeFullCertification(resource.getUniqueId(), user, lifecycleChangeInfo, inTransaction, needLock);
@@ -2075,13 +2123,13 @@ public class ServiceImportParseLogic {
}
public Resource buildValidComplexVfc(CsarInfo csarInfo, String nodeName,
- Map<String, NodeTypeInfo> nodesInfo) {
+ Map<String, NodeTypeInfo> nodesInfo) {
Resource complexVfc = buildComplexVfcMetadata(csarInfo, nodeName, nodesInfo);
log.debug("************* Going to validate complex VFC from yaml {}", complexVfc.getName());
csarInfo.addNodeToQueue(nodeName);
return validateResourceBeforeCreate(complexVfc, csarInfo.getModifier(),
- AuditingActionEnum.IMPORT_RESOURCE, true, csarInfo);
+ AuditingActionEnum.IMPORT_RESOURCE, true, csarInfo);
}
public Resource updateGroupsOnResource(Resource resource, Map<String, GroupDefinition> groups) {
@@ -2091,61 +2139,62 @@ public class ServiceImportParseLogic {
updateOrCreateGroups(resource, groups);
}
Either<Resource, StorageOperationStatus> updatedResource = toscaOperationFacade
- .getToscaElement(resource.getUniqueId());
+ .getToscaElement(resource.getUniqueId());
if (updatedResource.isRight()) {
throw new ComponentException(componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource));
+ componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource));
}
return updatedResource.left().value();
}
protected void setInformationalArtifactsPlaceHolder(Resource resource, User user) {
- Map<String, ArtifactDefinition> artifactMap = resource.getArtifacts();
- if (artifactMap == null) {
- artifactMap = new HashMap<>();
- }
- String resourceUniqueId = resource.getUniqueId();
- List<String> exludeResourceCategory = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getExcludeResourceCategory();
- List<String> exludeResourceType = ConfigurationManager.getConfigurationManager().getConfiguration()
- .getExcludeResourceType();
- Map<String, Object> informationalResourceArtifacts = ConfigurationManager.getConfigurationManager()
- .getConfiguration().getInformationalResourceArtifacts();
- List<CategoryDefinition> categories = resource.getCategories();
- boolean isCreateArtifact = true;
- if (exludeResourceCategory != null) {
- String category = categories.get(0).getName();
- isCreateArtifact = exludeResourceCategory.stream().noneMatch(e->e.equalsIgnoreCase(category));
- }
- if (isCreateArtifact && exludeResourceType != null) {
- String resourceType = resource.getResourceType().name();
- isCreateArtifact = exludeResourceType.stream().noneMatch(e->e.equalsIgnoreCase(resourceType));
- }
- if (informationalResourceArtifacts != null && isCreateArtifact) {
- Set<String> keys = informationalResourceArtifacts.keySet();
- for (String informationalResourceArtifactName : keys) {
- Map<String, Object> artifactInfoMap = (Map<String, Object>) informationalResourceArtifacts
- .get(informationalResourceArtifactName);
- if(serviceBusinessLogic.artifactsBusinessLogic!=null){
- ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic.createArtifactPlaceHolderInfo(
- resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user,
- ArtifactGroupTypeEnum.INFORMATIONAL);
- artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition);
- }
+ Map<String, ArtifactDefinition> artifactMap = resource.getArtifacts();
+ if (artifactMap == null) {
+ artifactMap = new HashMap<>();
+ }
+ String resourceUniqueId = resource.getUniqueId();
+ List<String> exludeResourceCategory = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getExcludeResourceCategory();
+ List<String> exludeResourceType = ConfigurationManager.getConfigurationManager().getConfiguration()
+ .getExcludeResourceType();
+ Map<String, Object> informationalResourceArtifacts = ConfigurationManager.getConfigurationManager()
+ .getConfiguration().getInformationalResourceArtifacts();
+ List<CategoryDefinition> categories = resource.getCategories();
+ boolean isCreateArtifact = true;
+ if (exludeResourceCategory != null) {
+ String category = categories.get(0).getName();
+ isCreateArtifact = exludeResourceCategory.stream().noneMatch(e -> e.equalsIgnoreCase(category));
+ }
+ if (isCreateArtifact && exludeResourceType != null) {
+ String resourceType = resource.getResourceType().name();
+ isCreateArtifact = exludeResourceType.stream().noneMatch(e -> e.equalsIgnoreCase(resourceType));
+ }
+ if (informationalResourceArtifacts != null && isCreateArtifact) {
+ Set<String> keys = informationalResourceArtifacts.keySet();
+ for (String informationalResourceArtifactName : keys) {
+ Map<String, Object> artifactInfoMap = (Map<String, Object>) informationalResourceArtifacts
+ .get(informationalResourceArtifactName);
+ if (serviceBusinessLogic.artifactsBusinessLogic != null) {
+ ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic.createArtifactPlaceHolderInfo(
+ resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user,
+ ArtifactGroupTypeEnum.INFORMATIONAL);
+ artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition);
}
}
- resource.setArtifacts(artifactMap);
+ }
+ resource.setArtifacts(artifactMap);
}
- public void rollback(boolean inTransaction, Resource resource, List<ArtifactDefinition> createdArtifacts, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
- if(!inTransaction) {
+ public void rollback(boolean inTransaction, Resource resource, List<ArtifactDefinition> createdArtifacts,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts) {
+ if (!inTransaction) {
serviceBusinessLogic.janusGraphDao.rollback();
}
if (isNotEmpty(createdArtifacts) && isNotEmpty(nodeTypesNewCreatedArtifacts)) {
createdArtifacts.addAll(nodeTypesNewCreatedArtifacts);
- log.debug("Found {} newly created artifacts to deleted, the component name: {}",createdArtifacts.size(), resource.getName());
+ log.debug("Found {} newly created artifacts to deleted, the component name: {}", createdArtifacts.size(), resource.getName());
}
}
@@ -2159,10 +2208,10 @@ public class ServiceImportParseLogic {
List<InputDefinition> inputs = service.getInputs();
if (MapUtils.isNotEmpty(groups)) {
groups.values()
- .stream()
- .filter(g -> isNotEmpty(g.getProperties()))
- .flatMap(g -> g.getProperties().stream())
- .forEach(p -> handleGetInputs(p, inputs));
+ .stream()
+ .filter(g -> isNotEmpty(g.getProperties()))
+ .flatMap(g -> g.getProperties().stream())
+ .forEach(p -> handleGetInputs(p, inputs));
}
}
@@ -2170,10 +2219,10 @@ public class ServiceImportParseLogic {
List<InputDefinition> inputs = resource.getInputs();
if (MapUtils.isNotEmpty(groups)) {
groups.values()
- .stream()
- .filter(g -> isNotEmpty(g.getProperties()))
- .flatMap(g -> g.getProperties().stream())
- .forEach(p -> handleGetInputs(p, inputs));
+ .stream()
+ .filter(g -> isNotEmpty(g.getProperties()))
+ .flatMap(g -> g.getProperties().stream())
+ .forEach(p -> handleGetInputs(p, inputs));
}
}
@@ -2182,9 +2231,9 @@ public class ServiceImportParseLogic {
if (inputs == null || inputs.isEmpty()) {
log.debug("Failed to add property {} to group. Inputs list is empty ", property);
serviceBusinessLogic.rollbackWithException(ActionStatus.INPUTS_NOT_FOUND, property.getGetInputValues()
- .stream()
- .map(GetInputValueDataDefinition::getInputName)
- .collect(toList()).toString());
+ .stream()
+ .map(GetInputValueDataDefinition::getInputName)
+ .collect(toList()).toString());
}
ListIterator<GetInputValueDataDefinition> getInputValuesIter = property.getGetInputValues().listIterator();
while (getInputValuesIter.hasNext()) {
@@ -2203,8 +2252,8 @@ public class ServiceImportParseLogic {
public InputDefinition findInputByName(List<InputDefinition> inputs, GetInputValueDataDefinition getInput) {
Optional<InputDefinition> inputOpt = inputs.stream()
- .filter(p -> p.getName().equals(getInput.getInputName()))
- .findFirst();
+ .filter(p -> p.getName().equals(getInput.getInputName()))
+ .findFirst();
if (!inputOpt.isPresent()) {
log.debug("#findInputByName - Failed to find the input {} ", getInput.getInputName());
serviceBusinessLogic.rollbackWithException(ActionStatus.INPUTS_NOT_FOUND, getInput.getInputName());
@@ -2212,15 +2261,16 @@ public class ServiceImportParseLogic {
return inputOpt.get();
}
- public void associateComponentInstancePropertiesToComponent(String yamlName, Resource resource, Map<String, List<ComponentInstanceProperty>> instProperties) {
+ public void associateComponentInstancePropertiesToComponent(String yamlName, Resource resource,
+ Map<String, List<ComponentInstanceProperty>> instProperties) {
try {
Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade
- .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId());
+ .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId());
if (addPropToInst.isRight()) {
log.debug("failed to associate properties of resource {} status is {}", resource.getUniqueId(),
- addPropToInst.right().value());
+ addPropToInst.right().value());
throw new ComponentException(componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
+ componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
}
} catch (Exception e) {
log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage());
@@ -2228,26 +2278,28 @@ public class ServiceImportParseLogic {
}
}
- public void associateComponentInstanceInputsToComponent(String yamlName, Resource resource, Map<String, List<ComponentInstanceInput>> instInputs) {
+ public void associateComponentInstanceInputsToComponent(String yamlName, Resource resource,
+ Map<String, List<ComponentInstanceInput>> instInputs) {
if (MapUtils.isNotEmpty(instInputs)) {
Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addInputToInst = toscaOperationFacade
- .associateComponentInstanceInputsToComponent(instInputs, resource.getUniqueId());
+ .associateComponentInstanceInputsToComponent(instInputs, resource.getUniqueId());
if (addInputToInst.isRight()) {
log.debug("failed to associate inputs value of resource {} status is {}", resource.getUniqueId(),
- addInputToInst.right().value());
+ addInputToInst.right().value());
throw new ComponentException(componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName));
+ componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName));
}
}
}
- public void associateDeploymentArtifactsToInstances(User user, String yamlName, Resource resource, Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts) {
+ public void associateDeploymentArtifactsToInstances(User user, String yamlName, Resource resource,
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts) {
StorageOperationStatus addArtToInst = toscaOperationFacade
- .associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource, user);
+ .associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource, user);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
@@ -2259,55 +2311,58 @@ public class ServiceImportParseLogic {
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
- public void associateOrAddCalculatedCapReq(String yamlName, Resource resource, Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities, Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements) {
+ public void associateOrAddCalculatedCapReq(String yamlName, Resource resource,
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities,
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateOrAddCalculatedCapReq(instCapabilities, instRequirements,
- resource);
+ resource);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate cap and req of resource {} status is {}", resource.getUniqueId(),
- addArtToInst);
+ addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
- public void associateInstAttributeToComponentToInstances(String yamlName, Resource resource, Map<String, List<AttributeDefinition>> instAttributes) {
+ public void associateInstAttributeToComponentToInstances(String yamlName, Resource resource,
+ Map<String, List<AttributeDefinition>> instAttributes) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateInstAttributeToComponentToInstances(instAttributes,
- resource);
+ resource);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate attributes of resource {} status is {}", resource.getUniqueId(),
- addArtToInst);
+ addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
public Resource getResourceAfterCreateRelations(Resource resource) {
ComponentParametersView parametersView = getComponentFilterAfterCreateRelations();
Either<Resource, StorageOperationStatus> eitherGetResource = toscaOperationFacade
- .getToscaElement(resource.getUniqueId(), parametersView);
+ .getToscaElement(resource.getUniqueId(), parametersView);
if (eitherGetResource.isRight()) {
- throwComponentExceptionByResource(eitherGetResource.right().value(),resource);
+ throwComponentExceptionByResource(eitherGetResource.right().value(), resource);
}
return eitherGetResource.left().value();
}
public Resource throwComponentExceptionByResource(StorageOperationStatus status, Resource resource) {
ResponseFormat responseFormat = componentsUtils.getResponseFormatByResource(
- componentsUtils.convertFromStorageResponse(status), resource);
+ componentsUtils.convertFromStorageResponse(status), resource);
throw new ComponentException(responseFormat);
}
public void setCapabilityNamesTypes(Map<String, List<CapabilityDefinition>> originCapabilities,
- Map<String, List<UploadCapInfo>> uploadedCapabilities) {
+ Map<String, List<UploadCapInfo>> uploadedCapabilities) {
for (Map.Entry<String, List<UploadCapInfo>> currEntry : uploadedCapabilities.entrySet()) {
if (originCapabilities.containsKey(currEntry.getKey())) {
currEntry.getValue().stream().forEach(cap -> cap.setType(currEntry.getKey()));
@@ -2326,43 +2381,45 @@ public class ServiceImportParseLogic {
}
public Map<String, List<CapabilityDefinition>> getValidComponentInstanceCapabilities(
- String resourceId, Map<String, List<CapabilityDefinition>> defaultCapabilities,
- Map<String, List<UploadCapInfo>> uploadedCapabilities) {
+ String resourceId, Map<String, List<CapabilityDefinition>> defaultCapabilities,
+ Map<String, List<UploadCapInfo>> uploadedCapabilities) {
Map<String, List<CapabilityDefinition>> validCapabilitiesMap = new HashMap<>();
- uploadedCapabilities.forEach((k,v)->addValidComponentInstanceCapabilities(k,v,resourceId,defaultCapabilities,validCapabilitiesMap));
+ uploadedCapabilities.forEach((k, v) -> addValidComponentInstanceCapabilities(k, v, resourceId, defaultCapabilities, validCapabilitiesMap));
return validCapabilitiesMap;
}
public void associateComponentInstanceInputsToComponent(String yamlName, Service service, Map<String, List<ComponentInstanceInput>> instInputs) {
if (MapUtils.isNotEmpty(instInputs)) {
Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addInputToInst = toscaOperationFacade
- .associateComponentInstanceInputsToComponent(instInputs, service.getUniqueId());
+ .associateComponentInstanceInputsToComponent(instInputs, service.getUniqueId());
if (addInputToInst.isRight()) {
log.debug("failed to associate inputs value of resource {} status is {}", service.getUniqueId(),
- addInputToInst.right().value());
+ addInputToInst.right().value());
throw new ComponentException(componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName));
+ componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName));
}
}
}
- public void associateComponentInstancePropertiesToComponent(String yamlName, Service service, Map<String, List<ComponentInstanceProperty>> instProperties) {
+ public void associateComponentInstancePropertiesToComponent(String yamlName, Service service,
+ Map<String, List<ComponentInstanceProperty>> instProperties) {
Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addPropToInst = toscaOperationFacade
- .associateComponentInstancePropertiesToComponent(instProperties, service.getUniqueId());
+ .associateComponentInstancePropertiesToComponent(instProperties, service.getUniqueId());
if (addPropToInst.isRight()) {
throw new ComponentException(componentsUtils.getResponseFormat(
- componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
+ componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName));
}
}
- public void associateDeploymentArtifactsToInstances(User user, String yamlName, Service resource, Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts) {
+ public void associateDeploymentArtifactsToInstances(User user, String yamlName, Service resource,
+ Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts) {
StorageOperationStatus addArtToInst = toscaOperationFacade
- .associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource, user);
+ .associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource, user);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
@@ -2373,76 +2430,80 @@ public class ServiceImportParseLogic {
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate artifact of resource {} status is {}", resource.getUniqueId(), addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
- public void associateOrAddCalculatedCapReq(String yamlName, Service resource, Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities, Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements) {
+ public void associateOrAddCalculatedCapReq(String yamlName, Service resource,
+ Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities,
+ Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateOrAddCalculatedCapReq(instCapabilities, instRequirements,
- resource);
+ resource);
log.debug("enter associateOrAddCalculatedCapReq,get instCapabilities:{},get instRequirements:{}",
- instCapabilities, instRequirements);
+ instCapabilities, instRequirements);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate cap and req of resource {} status is {}", resource.getUniqueId(),
- addArtToInst);
+ addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
- public void associateInstAttributeToComponentToInstances(String yamlName, Service resource, Map<String, List<AttributeDefinition>> instAttributes) {
+ public void associateInstAttributeToComponentToInstances(String yamlName, Service resource,
+ Map<String, List<AttributeDefinition>> instAttributes) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateInstAttributeToComponentToInstances(instAttributes,
- resource);
+ resource);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate attributes of resource {} status is {}", resource.getUniqueId(),
- addArtToInst);
+ addArtToInst);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName));
}
}
public void associateRequirementsToService(String yamlName, Service resource, Map<String, ListRequirementDataDefinition> requirements) {
StorageOperationStatus addReqToService;
addReqToService = toscaOperationFacade.associateRequirementsToService(requirements,
- resource.getUniqueId());
+ resource.getUniqueId());
if (addReqToService != StorageOperationStatus.OK && addReqToService != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate attributes of resource {} status is {}", resource.getUniqueId(),
- addReqToService);
+ addReqToService);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addReqToService), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addReqToService), yamlName));
}
}
- public void associateCapabilitiesToService(String yamlName, Service resource, Map<String,ListCapabilityDataDefinition> capabilities) {
+ public void associateCapabilitiesToService(String yamlName, Service resource, Map<String, ListCapabilityDataDefinition> capabilities) {
StorageOperationStatus addCapToService;
addCapToService = toscaOperationFacade.associateCapabilitiesToService(capabilities,
- resource.getUniqueId());
+ resource.getUniqueId());
if (addCapToService != StorageOperationStatus.OK && addCapToService != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate attributes of resource {} status is {}", resource.getUniqueId(),
- addCapToService);
+ addCapToService);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(addCapToService), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(addCapToService), yamlName));
}
}
public void associateResourceInstances(String yamlName, Service service, List<RequirementCapabilityRelDef> relations) {
- Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> relationsEither = toscaOperationFacade.associateResourceInstances(service, service.getUniqueId(), relations);
+ Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> relationsEither = toscaOperationFacade
+ .associateResourceInstances(service, service.getUniqueId(), relations);
if (relationsEither.isRight() && relationsEither.right().value() != StorageOperationStatus.NOT_FOUND) {
StorageOperationStatus status = relationsEither.right().value();
log.debug("failed to associate instances of service {} status is {}", service.getUniqueId(),
- status);
+ status);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName));
}
}
public void addCapabilities(Map<String, List<CapabilityDefinition>> originCapabilities, String type, List<CapabilityDefinition> capabilities) {
List<CapabilityDefinition> list = capabilities.stream().map(CapabilityDefinition::new)
- .collect(toList());
+ .collect(toList());
originCapabilities.put(type, list);
}
@@ -2450,7 +2511,7 @@ public class ServiceImportParseLogic {
for (UploadCapInfo capability : capabilities) {
if (isNotEmpty(capability.getProperties())) {
newPropertiesMap.put(capability.getName(), capability.getProperties().stream()
- .collect(toMap(UploadInfo::getName, p -> p)));
+ .collect(toMap(UploadInfo::getName, p -> p)));
}
}
}
@@ -2479,17 +2540,19 @@ public class ServiceImportParseLogic {
public void associateResourceInstances(String yamlName, Resource resource, List<RequirementCapabilityRelDef> relations) {
- Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> relationsEither = toscaOperationFacade.associateResourceInstances(resource, resource.getUniqueId(), relations);
+ Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> relationsEither = toscaOperationFacade
+ .associateResourceInstances(resource, resource.getUniqueId(), relations);
if (relationsEither.isRight() && relationsEither.right().value() != StorageOperationStatus.NOT_FOUND) {
StorageOperationStatus status = relationsEither.right().value();
log.debug("failed to associate instances of resource {} status is {}", resource.getUniqueId(),
- status);
+ status);
throw new ComponentException(componentsUtils
- .getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName));
+ .getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName));
}
}
- public void addRelationsToRI(String yamlName, Resource resource, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap, List<ComponentInstance> componentInstancesList, List<RequirementCapabilityRelDef> relations) {
+ public void addRelationsToRI(String yamlName, Resource resource, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
+ List<ComponentInstance> componentInstancesList, List<RequirementCapabilityRelDef> relations) {
for (Map.Entry<String, UploadComponentInstanceInfo> entry : uploadResInstancesMap.entrySet()) {
UploadComponentInstanceInfo uploadComponentInstanceInfo = entry.getValue();
ComponentInstance currentCompInstance = null;
@@ -2502,12 +2565,12 @@ public class ServiceImportParseLogic {
}
if (currentCompInstance == null) {
log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, uploadComponentInstanceInfo.getName(),
- resource.getUniqueId());
+ resource.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE,
- resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE,
+ resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
ResponseFormat responseFormat = componentsUtils
- .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
throw new ComponentException(responseFormat);
}
@@ -2519,7 +2582,7 @@ public class ServiceImportParseLogic {
}
protected ResponseFormat addRelationToRI(String yamlName, Resource resource,
- UploadComponentInstanceInfo nodesInfoValue, List<RequirementCapabilityRelDef> relations) {
+ UploadComponentInstanceInfo nodesInfoValue, List<RequirementCapabilityRelDef> relations) {
List<ComponentInstance> componentInstancesList = resource.getComponentInstances();
ComponentInstance currentCompInstance = null;
@@ -2532,12 +2595,12 @@ public class ServiceImportParseLogic {
}
if (currentCompInstance == null) {
log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, nodesInfoValue.getName(),
- resource.getUniqueId());
+ resource.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- COMPONENT_INSTANCE_WITH_NAME + nodesInfoValue.getName() + IN_RESOURCE,
- resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ COMPONENT_INSTANCE_WITH_NAME + nodesInfoValue.getName() + IN_RESOURCE,
+ resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE,
- yamlName);
+ yamlName);
}
String resourceInstanceId = currentCompInstance.getUniqueId();
Map<String, List<UploadReqInfo>> regMap = nodesInfoValue.getRequirements();
@@ -2554,15 +2617,15 @@ public class ServiceImportParseLogic {
regCapRelDef.setFromNode(resourceInstanceId);
log.debug("try to find available requirement {} ", regName);
Either<RequirementDefinition, ResponseFormat> eitherReqStatus = findAviableRequiremen(regName,
- yamlName, nodesInfoValue, currentCompInstance,
- uploadRegInfo.getCapabilityName());
+ yamlName, nodesInfoValue, currentCompInstance,
+ uploadRegInfo.getCapabilityName());
if (eitherReqStatus.isRight()) {
return eitherReqStatus.right().value();
}
RequirementDefinition validReq = eitherReqStatus.left().value();
List<CapabilityRequirementRelationship> reqAndRelationshipPairList = regCapRelDef
- .getRelationships();
+ .getRelationships();
if (reqAndRelationshipPairList == null) {
reqAndRelationshipPairList = new ArrayList<>();
}
@@ -2584,27 +2647,27 @@ public class ServiceImportParseLogic {
if (currentCapCompInstance == null) {
log.debug("The component instance with name {} not found on resource {} ",
- uploadRegInfo.getNode(), resource.getUniqueId());
+ uploadRegInfo.getNode(), resource.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE,
- resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE,
+ resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
return componentsUtils
- .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
regCapRelDef.setToNode(currentCapCompInstance.getUniqueId());
log.debug("try to find aviable Capability req name is {} ", validReq.getName());
CapabilityDefinition aviableCapForRel = findAvailableCapabilityByTypeOrName(validReq,
- currentCapCompInstance, uploadRegInfo);
+ currentCapCompInstance, uploadRegInfo);
reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
reqAndRelationshipPair.setCapabilityUid(aviableCapForRel.getUniqueId());
reqAndRelationshipPair.setCapabilityOwnerId(aviableCapForRel.getOwnerId());
if (aviableCapForRel == null) {
BeEcompErrorManager.getInstance().logInternalDataError(
- "aviable capability was not found. req name is " + validReq.getName()
- + " component instance is " + currentCapCompInstance.getUniqueId(),
- resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
+ "aviable capability was not found. req name is " + validReq.getName()
+ + " component instance is " + currentCapCompInstance.getUniqueId(),
+ resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR);
return componentsUtils
- .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
+ .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();
capReqRel.setRelation(reqAndRelationshipPair);
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 7e0fd60377..a3232f61ce 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
@@ -17,7 +17,12 @@
package org.openecomp.sdc.be.components.impl;
import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
@@ -33,14 +38,13 @@ 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.Before;
-import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
-import org.mockito.InjectMocks;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.ElementOperationMock;
@@ -58,7 +62,31 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.NodeTypeInfo;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+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.UploadPropInfo;
+import org.openecomp.sdc.be.model.UploadReqInfo;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
@@ -71,42 +99,8 @@ import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-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 static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.when;
-
class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSetup {
- ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
- ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
- ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
- ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
- IElementOperation elementDao = Mockito.mock(IElementOperation.class);
- IInterfaceLifecycleOperation interfaceTypeOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
- InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class);
- LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
-
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 GENERIC_ROOT_NAME = "tosca.nodes.Root";
@@ -116,18 +110,23 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
private static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
private static final String RESOURCE_SUBCATEGORY = "Router";
- @InjectMocks
- private ServiceImportParseLogic serviceImportParseLogic;
- ResponseFormatManager responseManager = null;
- User user = null;
+ private final ComponentsUtils componentsUtils = new ComponentsUtils(Mockito.mock(AuditingManager.class));
+ private final ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
+ private final ServiceBusinessLogic serviceBusinessLogic = Mockito.mock(ServiceBusinessLogic.class);
+ private final ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
+ private final IElementOperation elementDao = Mockito.mock(IElementOperation.class);
+ private final IInterfaceLifecycleOperation interfaceTypeOperation = Mockito.mock(IInterfaceLifecycleOperation.class);
+ private final InputsBusinessLogic inputsBusinessLogic = Mockito.mock(InputsBusinessLogic.class);
+ private final LifecycleBusinessLogic lifecycleBusinessLogic = Mockito.mock(LifecycleBusinessLogic.class);
+
+ private ResponseFormatManager responseManager = null;
+ private User user = null;
+ private ServiceImportParseLogic testSubject;
private ServiceImportParseLogic createTestSubject() {
return new ServiceImportParseLogic();
}
- ServiceImportParseLogic bl;
-
-
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
@@ -143,83 +142,30 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
user.setRole(Role.ADMIN.name());
responseManager = ResponseFormatManager.getInstance();
- bl = new ServiceImportParseLogic();
- bl.setComponentsUtils(componentsUtils);
- bl.setToscaOperationFacade(toscaOperationFacade);
- serviceBusinessLogic.setElementDao(elementDao);
- bl.setServiceBusinessLogic(serviceBusinessLogic);
- bl.setCapabilityTypeOperation(capabilityTypeOperation);
- bl.setInterfaceTypeOperation(interfaceTypeOperation);
- bl.setInputsBusinessLogic(inputsBusinessLogic);
- bl.setLifecycleBusinessLogic(lifecycleBusinessLogic);
- }
-
- @Test
- public void testGetServiceBusinessLogic() {
- ServiceImportParseLogic testSubject;
- ServiceBusinessLogic result;
-
- testSubject = createTestSubject();
- result = testSubject.getServiceBusinessLogic();
- assertNull(result);
- }
-
- @Test
- public void testSetServiceBusinessLogic() {
- ServiceImportParseLogic testSubject;
- ServiceBusinessLogic serviceBusinessLogic = null;
-
testSubject = createTestSubject();
+ testSubject.setComponentsUtils(componentsUtils);
+ testSubject.setToscaOperationFacade(toscaOperationFacade);
+ serviceBusinessLogic.setElementDao(elementDao);
testSubject.setServiceBusinessLogic(serviceBusinessLogic);
- assertNotNull(testSubject);
+ testSubject.setCapabilityTypeOperation(capabilityTypeOperation);
+ testSubject.setInterfaceTypeOperation(interfaceTypeOperation);
+ testSubject.setInputsBusinessLogic(inputsBusinessLogic);
+ testSubject.setLifecycleBusinessLogic(lifecycleBusinessLogic);
}
@Test
- public void testGetCapabilityTypeOperation() {
- ServiceImportParseLogic testSubject;
- ICapabilityTypeOperation result;
-
- testSubject = createTestSubject();
- result = testSubject.getCapabilityTypeOperation();
- assertNull(result);
- }
-
- @Test
- public void testSetCapabilityTypeOperation() {
- ServiceImportParseLogic testSubject;
- ICapabilityTypeOperation iCapabilityTypeOperation = null;
-
+ void testFindNodeTypesArtifactsToHandle() {
testSubject = createTestSubject();
- testSubject.setCapabilityTypeOperation(iCapabilityTypeOperation);
- assertNotNull(testSubject);
- }
-
- private CsarInfo createCsarInfo() {
- Map<String, byte[]> csar = new HashMap<>();
- User user = new User();
- CsarInfo csarInfo = new CsarInfo(user, "csar_UUID", csar, "vfResourceName", "mainTemplateName",
- "mainTemplateContent", true);
- csarInfo.setVfResourceName("vfResourceName");
- csarInfo.setCsar(csar);
- csarInfo.setCsarUUID("csarUUID");
- csarInfo.setModifier(user);
- csarInfo.setUpdate(true);
- return csarInfo;
- }
-
- @Test
- public void testFindNodeTypesArtifactsToHandle() {
- ServiceImportParseLogic testSubject = createTestSubject();
Map<String, NodeTypeInfo> nodeTypesInfo = new HashedMap();
final Service service = createServiceObject(false);
Assertions.assertNotNull(
- bl.findNodeTypesArtifactsToHandle(
- nodeTypesInfo, getCsarInfo(), service));
+ this.testSubject.findNodeTypesArtifactsToHandle(
+ nodeTypesInfo, getCsarInfo(), service));
}
@Test
- public void testBuildNodeTypeYaml() {
+ void testBuildNodeTypeYaml() {
Map.Entry<String, Object> nodeNameValue = new Entry<String, Object>() {
@Override
public String getKey() {
@@ -239,14 +185,14 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
Map<String, Object> mapToConvert = new HashMap<>();
String nodeResourceType = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX;
+ final CsarInfo csarInfo = getCsarInfo();
Assertions.assertThrows(ComponentException.class, () ->
- bl.buildNodeTypeYaml(
- nodeNameValue, mapToConvert, nodeResourceType, getCsarInfo()));
+ testSubject.buildNodeTypeYaml(nodeNameValue, mapToConvert, nodeResourceType, csarInfo));
}
@Test
- public void testFindAddNodeTypeArtifactsToHandle() {
+ void testFindAddNodeTypeArtifactsToHandle() {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = new HashMap<>();
Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
@@ -258,16 +204,17 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
Resource resource = new Resource();
Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(resource);
when(toscaOperationFacade.getLatestByToscaResourceName(anyString()))
- .thenReturn(getCompLatestResult);
+ .thenReturn(getCompLatestResult);
+ final CsarInfo csarInfo = getCsarInfo();
Assertions.assertThrows(ComponentException.class, () ->
- bl.findAddNodeTypeArtifactsToHandle(getCsarInfo(), nodeTypesArtifactsToHandle, service,
- extractedVfcsArtifacts, namespace, p1));
+ testSubject.findAddNodeTypeArtifactsToHandle(csarInfo, nodeTypesArtifactsToHandle, service,
+ extractedVfcsArtifacts, namespace, p1));
}
@Test
- public void testFindAddNodeTypeArtifactsToHandleNotNull() {
+ void testFindAddNodeTypeArtifactsToHandleNotNull() {
Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = new HashMap<>();
Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
@@ -285,12 +232,12 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
when(toscaOperationFacade.getLatestByToscaResourceName(anyString()))
.thenReturn(getCompLatestResult);
Assertions.assertNotNull(extractedVfcsArtifacts);
- bl.findAddNodeTypeArtifactsToHandle(getCsarInfo(), nodeTypesArtifactsToHandle, service,
- extractedVfcsArtifacts, namespace, p1);
+ testSubject.findAddNodeTypeArtifactsToHandle(getCsarInfo(), nodeTypesArtifactsToHandle, service,
+ extractedVfcsArtifacts, namespace, p1);
}
@Test
- public void testHandleAndAddExtractedVfcsArtifacts() {
+ void testHandleAndAddExtractedVfcsArtifacts() {
List<ArtifactDefinition> vfcArtifacts = new ArrayList<>();
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
artifactDefinition.setArtifactName("artifactDefinitionName");
@@ -301,29 +248,29 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
artifactsToAdd.add(artifactDefinitionToAdd);
Assertions.assertNotNull(vfcArtifacts);
- bl.handleAndAddExtractedVfcsArtifacts(vfcArtifacts, artifactsToAdd);
+ testSubject.handleAndAddExtractedVfcsArtifacts(vfcArtifacts, artifactsToAdd);
}
@Test
- public void testFindNodeTypeArtifactsToHandle() {
+ void testFindNodeTypeArtifactsToHandle() {
Resource curNodeType = createParseResourceObject(true);
List<ArtifactDefinition> extractedArtifacts = new ArrayList<>();
Assertions.assertNull(
- bl.findNodeTypeArtifactsToHandle(curNodeType, extractedArtifacts));
+ testSubject.findNodeTypeArtifactsToHandle(curNodeType, extractedArtifacts));
}
@Test
- public void testCollectExistingArtifacts() {
+ void testCollectExistingArtifacts() {
Resource curNodeType = createParseResourceObject(true);
Assertions.assertNotNull(
- bl.collectExistingArtifacts(curNodeType));
+ testSubject.collectExistingArtifacts(curNodeType));
}
@Test
- public void testPutFoundArtifacts() {
+ void testPutFoundArtifacts() {
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
List<ArtifactDefinition> artifactsToUpload = new ArrayList<>();
artifactsToUpload.add(artifactDefinition);
@@ -332,11 +279,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
List<ArtifactDefinition> artifactsToDelete = new ArrayList<>();
artifactsToDelete.add(artifactDefinition);
Assertions.assertNotNull(
- bl.putFoundArtifacts(artifactsToUpload, artifactsToUpdate, artifactsToDelete));
+ testSubject.putFoundArtifacts(artifactsToUpload, artifactsToUpdate, artifactsToDelete));
}
@Test
- public void testProcessExistingNodeTypeArtifacts() {
+ void testProcessExistingNodeTypeArtifacts() {
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
List<ArtifactDefinition> extractedArtifacts = new ArrayList<>();
extractedArtifacts.add(artifactDefinition);
@@ -349,13 +296,13 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
Map<String, ArtifactDefinition> existingArtifacts = new HashMap<>();
existingArtifacts.put("test", artifactDefinition);
Assertions.assertThrows(ComponentException.class, () ->
- bl.processExistingNodeTypeArtifacts(extractedArtifacts, artifactsToUpload, artifactsToUpdate,
- artifactsToDelete, existingArtifacts));
+ testSubject.processExistingNodeTypeArtifacts(extractedArtifacts, artifactsToUpload, artifactsToUpdate,
+ artifactsToDelete, existingArtifacts));
}
@Test
- public void testProcessNodeTypeArtifact() {
+ void testProcessNodeTypeArtifact() {
List<ArtifactDefinition> artifactsToUpload = new ArrayList<>();
List<ArtifactDefinition> artifactsToUpdate = new ArrayList<>();
Map<String, ArtifactDefinition> existingArtifacts = new HashMap<>();
@@ -369,11 +316,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
currNewArtifact.setArtifactType("ArtifactType");
currNewArtifact.setPayload("Payload".getBytes());
Assertions.assertNotNull(existingArtifact);
- bl.processNodeTypeArtifact(artifactsToUpload, artifactsToUpdate, existingArtifacts, currNewArtifact);
+ testSubject.processNodeTypeArtifact(artifactsToUpload, artifactsToUpdate, existingArtifacts, currNewArtifact);
}
@Test
- public void testUpdateFoundArtifact() {
+ void testUpdateFoundArtifact() {
List<ArtifactDefinition> artifactsToUpdate = new ArrayList<>();
ArtifactDefinition currNewArtifact = new ArtifactDefinition();
currNewArtifact.setArtifactChecksum("090909");
@@ -382,53 +329,51 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
foundArtifact.setArtifactChecksum("08767");
Assertions.assertNotNull(currNewArtifact);
- bl.updateFoundArtifact(artifactsToUpdate, currNewArtifact, foundArtifact);
+ testSubject.updateFoundArtifact(artifactsToUpdate, currNewArtifact, foundArtifact);
}
@Test
- public void testIsArtifactDeletionRequired() {
+ void testIsArtifactDeletionRequired() {
String artifactId = "artifactId";
byte[] artifactFileBytes = new byte[100];
boolean isFromCsar = true;
- Assertions.assertNotNull(
- bl.isArtifactDeletionRequired(artifactId, artifactFileBytes, isFromCsar));
+ Assertions.assertFalse(testSubject.isArtifactDeletionRequired(artifactId, artifactFileBytes, isFromCsar));
}
@Test
- public void testFillGroupsFinalFields() {
+ void testFillGroupsFinalFields() {
List<GroupDefinition> groupsAsList = new ArrayList<>();
GroupDefinition groupDefinition = new GroupDefinition();
groupDefinition.setName("groupDefinitionName");
groupsAsList.add(groupDefinition);
Assertions.assertNotNull(groupsAsList);
- bl.fillGroupsFinalFields(groupsAsList);
+ testSubject.fillGroupsFinalFields(groupsAsList);
}
@Test
- public void testGetComponentTypeForResponse() {
+ void testGetComponentTypeForResponse() {
Resource resource = createParseResourceObject(true);
Assertions.assertNotNull(
- bl.getComponentTypeForResponse(resource));
+ testSubject.getComponentTypeForResponse(resource));
}
@Test
- public void testGetComponentTypeForResponseByService() {
+ void testGetComponentTypeForResponseByService() {
Service service = createServiceObject(true);
Assertions.assertNotNull(
- bl.getComponentTypeForResponse(service));
+ testSubject.getComponentTypeForResponse(service));
}
@Test
- public void testIsfillGroupMemebersRecursivlyStopCondition() {
+ void testIsfillGroupMemebersRecursivlyStopCondition() {
String groupName = "groupName";
Map<String, GroupDefinition> allGroups = new HashMap<>();
Set<String> allGroupMembers = new HashSet<>();
- Assertions.assertNotNull(
- bl.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers));
+ Assertions.assertTrue(testSubject.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers));
}
@Test
- public void testIsfillGroupMemebersRecursivlyStopCondition2() {
+ void testIsfillGroupMemebersRecursivlyStopCondition2() {
String groupName = "groupName";
Map<String, GroupDefinition> allGroups = new HashMap<>();
GroupDefinition groupDefinition = new GroupDefinition();
@@ -437,12 +382,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
groupDefinition.setMembers(members);
allGroups.put(groupName, groupDefinition);
Set<String> allGroupMembers = new HashSet<>();
- Assertions.assertNotNull(
- bl.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers));
+ Assertions.assertTrue(testSubject.isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers));
}
@Test
- public void testBuildValidComplexVfc() {
+ void testBuildValidComplexVfc() {
Resource resource = createParseResourceObject(true);
String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
@@ -451,38 +395,40 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
derivedFrom.add("derivedFrom");
nodeTypeInfo.setDerivedFrom(derivedFrom);
nodesInfo.put(nodeName, nodeTypeInfo);
+ final CsarInfo csarInfo = getCsarInfo();
Assertions.assertThrows(ComponentException.class, () ->
- bl.buildValidComplexVfc(resource, getCsarInfo(), nodeName, nodesInfo));
+ testSubject.buildValidComplexVfc(resource, csarInfo, nodeName, nodesInfo));
}
@Test
- public void testValidateResourceBeforeCreate() {
+ void testValidateResourceBeforeCreate() {
Resource resource = createParseResourceObject(true);
- bl.getServiceBusinessLogic().setElementDao(elementDao);
+ testSubject.getServiceBusinessLogic().setElementDao(elementDao);
+ final CsarInfo csarInfo = getCsarInfo();
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateResourceBeforeCreate(resource, user, AuditingActionEnum.IMPORT_RESOURCE, false, getCsarInfo()));
+ testSubject.validateResourceBeforeCreate(resource, user, AuditingActionEnum.IMPORT_RESOURCE, false, csarInfo));
}
@Test
- public void testValidateResourceType() {
+ void testValidateResourceType() {
Resource resource = createParseResourceObject(true);
Assertions.assertNotNull(
- bl.validateResourceType(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateResourceType(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateResourceTypeIsEmpty() {
+ void testValidateResourceTypeIsEmpty() {
Resource resource = new Resource();
resource.setResourceType(null);
Assertions.assertNotNull(
- bl.validateResourceType(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateResourceType(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateLifecycleTypesCreate() {
+ void testValidateLifecycleTypesCreate() {
Resource resource = createParseResourceObject(true);
Map<String, InterfaceDefinition> mapInterfaces = new HashMap<>();
InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
@@ -493,11 +439,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
when(interfaceTypeOperation.getInterface(anyString()))
.thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Assertions.assertNotNull(
- bl.validateLifecycleTypesCreate(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateLifecycleTypesCreate(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateCapabilityTypesCreate() {
+ void testValidateCapabilityTypesCreate() {
Resource resource = createParseResourceObject(true);
Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
String uniqueId = "18982938994";
@@ -507,15 +453,15 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
capabilities.put(uniqueId, capabilityDefinitionList);
resource.setCapabilities(capabilities);
when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
- thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Assertions.assertNotNull(
- bl.validateCapabilityTypesCreate(user, bl.getCapabilityTypeOperation(), resource,
- AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCapabilityTypesCreate(user, testSubject.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateCapabilityTypesCreateWhenHaveCapability() {
+ void testValidateCapabilityTypesCreateWhenHaveCapability() {
Resource resource = createParseResourceObject(true);
Map<String, List<CapabilityDefinition>> capabilities = new HashMap<>();
String uniqueId = "18982938994";
@@ -526,29 +472,29 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
resource.setCapabilities(capabilities);
CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition();
when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
- thenReturn(Either.left(capabilityTypeDefinition));
+ thenReturn(Either.left(capabilityTypeDefinition));
Assertions.assertNotNull(
- bl.validateCapabilityTypesCreate(user, bl.getCapabilityTypeOperation(), resource,
- AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCapabilityTypesCreate(user, testSubject.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateCapabilityTypeExists() {
+ void testValidateCapabilityTypeExists() {
Resource resource = createParseResourceObject(true);
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
Assertions.assertNotNull(
- bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
- AuditingActionEnum.IMPORT_RESOURCE,
- eitherResult, typeEntry, false));
+ testSubject.validateCapabilityTypeExists(user, testSubject.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE,
+ eitherResult, typeEntry, false));
}
}
@Test
- public void testValidateCapabilityTypeExistsWhenPropertiesIsNull() {
+ void testValidateCapabilityTypeExistsWhenPropertiesIsNull() {
Resource resource = createParseResourceObject(true);
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition();
@@ -567,18 +513,18 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
resource.setCapabilities(capabilities);
when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
- thenReturn(Either.left(capabilityTypeDefinition));
+ thenReturn(Either.left(capabilityTypeDefinition));
for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
Assertions.assertNotNull(
- bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
- AuditingActionEnum.IMPORT_RESOURCE,
- eitherResult, typeEntry, false));
+ testSubject.validateCapabilityTypeExists(user, testSubject.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE,
+ eitherResult, typeEntry, false));
}
}
@Test
- public void testValidateCapabilityTypeExistsWhenPropertiesNotNull() {
+ void testValidateCapabilityTypeExistsWhenPropertiesNotNull() {
Resource resource = createParseResourceObject(true);
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
CapabilityTypeDefinition capabilityTypeDefinition = new CapabilityTypeDefinition();
@@ -606,158 +552,135 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
resource.setCapabilities(capabilities);
when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
- thenReturn(Either.left(capabilityTypeDefinition));
+ thenReturn(Either.left(capabilityTypeDefinition));
for (Map.Entry<String, List<CapabilityDefinition>> typeEntry : resource.getCapabilities().entrySet()) {
Assertions.assertNotNull(
- bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
- AuditingActionEnum.IMPORT_RESOURCE,
- eitherResult, typeEntry, false));
+ testSubject.validateCapabilityTypeExists(user, testSubject.getCapabilityTypeOperation(), resource,
+ AuditingActionEnum.IMPORT_RESOURCE,
+ eitherResult, typeEntry, false));
}
}
@Test
- public void testValidateCapabilityTypeExists2() {
+ void testValidateCapabilityTypeExists2() {
Resource resource = createParseResourceObject(true);
Either<Boolean, ResponseFormat> eitherResult = Either.left(true);
when(capabilityTypeOperation.getCapabilityType(anyString(), anyBoolean())).
- thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
for (String type : resource.getRequirements().keySet()) {
Assertions.assertNotNull(
- bl.validateCapabilityTypeExists(user, bl.getCapabilityTypeOperation(), resource,
- resource.getRequirements().get(type), AuditingActionEnum.IMPORT_RESOURCE, eitherResult, type,
- false));
+ testSubject.validateCapabilityTypeExists(user, testSubject.getCapabilityTypeOperation(), resource,
+ resource.getRequirements().get(type), AuditingActionEnum.IMPORT_RESOURCE, eitherResult, type,
+ false));
}
}
@Test
- public void testValidateResourceFieldsBeforeCreate() {
+ void testValidateResourceFieldsBeforeCreate() {
Resource resource = createParseResourceObject(true);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateResourceFieldsBeforeCreate(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
- }
-
- @Test
- public void testValidateDerivedFromExist() {
- Resource resource = createParseResourceObject(true);
- when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
- .thenReturn(Either.left(true));
- Assertions.assertNotNull(resource);
-
- bl.validateDerivedFromExist(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ testSubject.validateResourceFieldsBeforeCreate(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateDerivedFromExistFailure1() {
+ void testValidateDerivedFromExist() {
Resource resource = createParseResourceObject(true);
-
- when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
- .thenReturn(Either.left(true));
+ when(toscaOperationFacade.validateToscaResourceNameExists(anyString())).thenReturn(Either.left(true));
Assertions.assertNotNull(resource);
- bl.validateDerivedFromExist(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ testSubject.validateDerivedFromExist(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
- public void testValidateDerivedFromExistFailure2() {
- Resource resource = createParseResourceObject(true);
-
- when(toscaOperationFacade.validateToscaResourceNameExists(anyString()))
- .thenReturn(Either.left(true));
- Assertions.assertNotNull(resource);
-
- bl.validateDerivedFromExist(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
- }
-
- @Test
- public void testValidateLicenseType() {
+ void testValidateLicenseType() {
Resource resource = createParseResourceObject(true);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateLicenseType(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateLicenseType(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateCost() {
+ void testValidateCost() {
Resource resource = createParseResourceObject(true);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCost(resource));
+ testSubject.validateCost(resource));
}
@Test
- public void testValidateResourceVendorModelNumber() {
+ void testValidateResourceVendorModelNumber() {
Resource resource = createParseResourceObject(true);
Assertions.assertNotNull(resource);
- bl.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ testSubject.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
- public void testValidateResourceVendorModelNumberWrongLen() {
+ void testValidateResourceVendorModelNumberWrongLen() {
Resource resource = createParseResourceObject(true);
resource.setResourceVendorModelNumber("000000000011122221111222333444443222556677788778889999998776554332340");
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateResourceVendorModelNumberWrongValue() {
+ void testValidateResourceVendorModelNumberWrongValue() {
Resource resource = createParseResourceObject(true);
resource.setResourceVendorModelNumber("");
Assertions.assertNotNull(resource);
- bl.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ testSubject.validateResourceVendorModelNumber(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
- public void testValidateVendorReleaseName() {
+ void testValidateVendorReleaseName() {
Resource resource = createParseResourceObject(true);
resource.setVendorRelease("0.1");
Assertions.assertNotNull(resource);
- bl.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ testSubject.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
- public void testValidateVendorReleaseNameFailure() {
+ void testValidateVendorReleaseNameFailure() {
Resource resource = createParseResourceObject(true);
resource.setVendorRelease("");
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateVendorReleaseNameWrongLen() {
+ void testValidateVendorReleaseNameWrongLen() {
Resource resource = createParseResourceObject(true);
resource.setVendorRelease("000000000011122221111222333444443222556677788778889999998776554332340");
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateVendorReleaseName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateCategory() {
+ void testValidateCategory() {
Resource resource = createParseResourceObject(true);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateEmptyCategory() {
+ void testValidateEmptyCategory() {
Resource resource = createParseResourceObject(true);
resource.setCategories(null);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateCategorySizeBiggerThan1() {
+ void testValidateCategorySizeBiggerThan1() {
Resource resource = createParseResourceObject(true);
List<CategoryDefinition> categories = new ArrayList<>();
CategoryDefinition categoryDefinition1 = new CategoryDefinition();
@@ -767,24 +690,24 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
resource.setCategories(categories);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateEmptySubCategory() {
+ void testValidateEmptySubCategory() {
Resource resource = createParseResourceObject(true);
List<CategoryDefinition> categories = resource.getCategories();
CategoryDefinition categoryDefinition = categories.get(0);
categoryDefinition.setSubcategories(null);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateEmptySubCategorySizeBiggerThan1() {
+ void testValidateEmptySubCategorySizeBiggerThan1() {
Resource resource = createParseResourceObject(true);
List<CategoryDefinition> categories = resource.getCategories();
CategoryDefinition categoryDefinition = categories.get(0);
@@ -795,23 +718,23 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
subcategories.add(subCategoryDefinition2);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateEmptyCategoryName() {
+ void testValidateEmptyCategoryName() {
Resource resource = createParseResourceObject(true);
List<CategoryDefinition> categories = resource.getCategories();
CategoryDefinition categoryDefinition = categories.get(0);
categoryDefinition.setName(null);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateEmptySubCategoryName() {
+ void testValidateEmptySubCategoryName() {
Resource resource = createParseResourceObject(true);
List<CategoryDefinition> categories = resource.getCategories();
CategoryDefinition categoryDefinition = categories.get(0);
@@ -820,106 +743,106 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
subCategoryDefinition1.setName(null);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testValidateCategoryListed() {
+ void testValidateCategoryListed() {
Resource resource = createParseResourceObject(true);
CategoryDefinition category = resource.getCategories().get(0);
SubCategoryDefinition subcategory = category.getSubcategories().get(0);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCategoryListed(category, subcategory, user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
+ testSubject.validateCategoryListed(category, subcategory, user, resource, AuditingActionEnum.IMPORT_RESOURCE, true));
}
@Test
- public void testFailOnInvalidCategory() {
+ void testFailOnInvalidCategory() {
Resource resource = createParseResourceObject(true);
Assertions.assertThrows(ComponentException.class, () ->
- bl.failOnInvalidCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.failOnInvalidCategory(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateVendorName() {
+ void testValidateVendorName() {
Resource resource = createParseResourceObject(true);
Assertions.assertNotNull(resource);
- bl.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ testSubject.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
- public void testValidateVendorNameEmpty() {
+ void testValidateVendorNameEmpty() {
Resource resource = createParseResourceObject(true);
resource.setVendorName(null);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateVendorNameWrongLen() {
+ void testValidateVendorNameWrongLen() {
Resource resource = createParseResourceObject(true);
resource.setVendorName("000000000011122221111222333444443222556677788778889999998776554332340");
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateVendorName(user, resource, AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateVendorName2() {
+ void testValidateVendorName2() {
Resource resource = createParseResourceObject(true);
CategoryDefinition category = resource.getCategories().get(0);
SubCategoryDefinition subcategory = category.getSubcategories().get(0);
String vendorName = "vendorName";
Assertions.assertNotNull(resource);
- bl.validateVendorName(vendorName, user, resource, AuditingActionEnum.IMPORT_RESOURCE);
+ testSubject.validateVendorName(vendorName, user, resource, AuditingActionEnum.IMPORT_RESOURCE);
}
@Test
- public void testFillResourceMetadata2() {
+ void testFillResourceMetadata2() {
String yamlName = "yamlName";
Resource resourceVf = createParseResourceObject(true);
String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "test";
resourceVf.setSystemName("systemName");
Assertions.assertThrows(ComponentException.class, () ->
- bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
+ testSubject.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
}
@Test
- public void testFillResourceMetadataWrongStart() {
+ void testFillResourceMetadataWrongStart() {
String yamlName = "yamlName";
Resource resourceVf = createParseResourceObject(true);
String nodeName = "WrongStart" + "test";
Assertions.assertThrows(ComponentException.class, () ->
- bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
+ testSubject.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
}
@Test
- public void testFillResourceMetadataResourceTypeIsAbs() {
+ void testFillResourceMetadataResourceTypeIsAbs() {
String yamlName = "yamlName";
Resource resourceVf = createParseResourceObject(true);
String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + Constants.ABSTRACT;
Assertions.assertNotNull(
- bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
+ testSubject.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
}
@Test
- public void testGetNodeTypeActualName() {
+ void testGetNodeTypeActualName() {
String fullName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "test";
Assertions.assertNotNull(
- bl.getNodeTypeActualName(fullName));
+ testSubject.getNodeTypeActualName(fullName));
}
@Test
- public void testAddInput() {
+ void testAddInput() {
Map<String, InputDefinition> currPropertiesMap = new HashMap<>();
InputDefinition prop = new InputDefinition();
Assertions.assertNotNull(currPropertiesMap);
- bl.addInput(currPropertiesMap, prop);
+ testSubject.addInput(currPropertiesMap, prop);
}
@Test
- public void testFindAviableRequirement() {
+ void testFindAviableRequirement() {
String uniqueId = "101929382910";
String regName = uniqueId;
String yamlName = uniqueId;
@@ -939,11 +862,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
String capName = "capName";
Assertions.assertNotNull(
- bl.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName));
+ testSubject.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName));
}
@Test
- public void testFindAviableRequirementSameCapName() {
+ void testFindAviableRequirementSameCapName() {
String uniqueId = "101929382910";
String regName = uniqueId;
String yamlName = uniqueId;
@@ -962,22 +885,21 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
String capName = uniqueId;
Assertions.assertNotNull(
- bl.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName));
+ testSubject.findAviableRequiremen(regName, yamlName, uploadComponentInstanceInfo, currentCompInstance, capName));
}
@Test
- public void testFindAvailableCapabilityByTypeOrName() {
+ void testFindAvailableCapabilityByTypeOrName() {
RequirementDefinition validReq = new RequirementDefinition();
ComponentInstance currentCapCompInstance = new ComponentInstance();
UploadReqInfo uploadReqInfo = new UploadReqInfo();
Assertions.assertThrows(ComponentException.class, () ->
- bl.findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadReqInfo));
+ testSubject.findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadReqInfo));
}
-
@Test
- public void testFindAvailableCapability() {
+ void testFindAvailableCapability() {
String uniqueId = "23422345677";
RequirementDefinition validReq = new RequirementDefinition();
validReq.setCapability(uniqueId);
@@ -992,11 +914,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
instance.setCapabilities(capabilityMap);
Assertions.assertNotNull(
- bl.findAvailableCapability(validReq, instance));
+ testSubject.findAvailableCapability(validReq, instance));
}
@Test
- public void testfindAvailableCapability2() {
+ void testfindAvailableCapability2() {
String uniqueId = "23422345677";
RequirementDefinition validReq = new RequirementDefinition();
validReq.setCapability(uniqueId);
@@ -1014,18 +936,18 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
uploadReqInfo.setCapabilityName(uniqueId);
Assertions.assertNotNull(
- bl.findAvailableCapability(validReq, instance, uploadReqInfo));
+ testSubject.findAvailableCapability(validReq, instance, uploadReqInfo));
}
@Test
- public void testGetComponentWithInstancesFilter() {
+ void testGetComponentWithInstancesFilter() {
Assertions.assertNotNull(
- bl.getComponentWithInstancesFilter());
+ testSubject.getComponentWithInstancesFilter());
}
@Test
- public void testCreateParseResourceObject() {
+ void testCreateParseResourceObject() {
String key = "0923928394";
List<UploadCapInfo> capabilities = new ArrayList<>();
UploadCapInfo uploadCapInfo = new UploadCapInfo();
@@ -1048,16 +970,16 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
capabilitiesMap.put(key, capabilityDefinitionList);
when(toscaOperationFacade.getToscaFullElement(anyString()))
- .thenReturn(Either.left(resource));
+ .thenReturn(Either.left(resource));
Assertions.assertNotNull(resource);
- bl.addValidComponentInstanceCapabilities(key, capabilities, resourceId, defaultCapabilities,
- validCapabilitiesMap);
+ testSubject.addValidComponentInstanceCapabilities(key, capabilities, resourceId, defaultCapabilities,
+ validCapabilitiesMap);
}
@Test
- public void testGetCapabilityFailure() {
+ void testGetCapabilityFailure() {
String resourceId = "resourceId";
String key = "0923928394";
Map<String, List<CapabilityDefinition>> defaultCapabilities = new HashMap<>();
@@ -1068,14 +990,13 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
defaultCapabilities.put(key, capabilityDefinitionList);
String capabilityType = key;
when(toscaOperationFacade.getToscaFullElement(anyString()))
- .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Assertions.assertThrows(ComponentException.class, () ->
- bl.getCapability(resourceId, defaultCapabilities, capabilityType));
+ testSubject.getCapability(resourceId, defaultCapabilities, capabilityType));
}
-
@Test
- public void testValidateCapabilityProperties() {
+ void testValidateCapabilityProperties() {
List<UploadCapInfo> capabilities = new ArrayList<>();
UploadCapInfo uploadCapInfo = new UploadCapInfo();
List<UploadPropInfo> properties = new ArrayList<>();
@@ -1089,11 +1010,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
defaultCapability.setName("test");
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateCapabilityProperties(capabilities, resourceId, defaultCapability));
+ testSubject.validateCapabilityProperties(capabilities, resourceId, defaultCapability));
}
@Test
- public void testValidateUniquenessUpdateUploadedComponentInstanceCapability() {
+ void testValidateUniquenessUpdateUploadedComponentInstanceCapability() {
String key = "02124568";
List<UploadCapInfo> capabilities = new ArrayList<>();
UploadCapInfo uploadCapInfo = new UploadCapInfo();
@@ -1113,29 +1034,29 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
Assertions.assertNotNull(defaultCapability);
- bl.validateUniquenessUpdateUploadedComponentInstanceCapability(defaultCapability, uploadCapInfo);
+ testSubject.validateUniquenessUpdateUploadedComponentInstanceCapability(defaultCapability, uploadCapInfo);
}
@Test
- public void testSetDeploymentArtifactsPlaceHolderByResource() {
+ void testSetDeploymentArtifactsPlaceHolderByResource() {
Resource resource = createParseResourceObject(true);
Assertions.assertNotNull(resource);
- bl.setDeploymentArtifactsPlaceHolder(resource, user);
+ testSubject.setDeploymentArtifactsPlaceHolder(resource, user);
}
@Test
- public void testSetDeploymentArtifactsPlaceHolderByService() {
+ void testSetDeploymentArtifactsPlaceHolderByService() {
Service Service = createServiceObject(true);
Assertions.assertNotNull(Service);
- bl.setDeploymentArtifactsPlaceHolder(Service, user);
+ testSubject.setDeploymentArtifactsPlaceHolder(Service, user);
}
@Test
- public void testProcessDeploymentResourceArtifacts() {
+ void testProcessDeploymentResourceArtifacts() {
Resource resource = createParseResourceObject(true);
resource.setResourceType(ResourceTypeEnum.VF);
Map<String, ArtifactDefinition> artifactMap = new HashMap<>();
@@ -1148,21 +1069,21 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
v = artifactDetails;
Assertions.assertNotNull(resource);
- bl.processDeploymentResourceArtifacts(user, resource, artifactMap, k, v);
+ testSubject.processDeploymentResourceArtifacts(user, resource, artifactMap, k, v);
}
@Test
- public void testMergeOldResourceMetadataWithNew() {
+ void testMergeOldResourceMetadataWithNew() {
Resource oldResource = createParseResourceObject(true);
Resource newResource = new Resource();
Assertions.assertNotNull(oldResource);
- bl.mergeOldResourceMetadataWithNew(oldResource, newResource);
+ testSubject.mergeOldResourceMetadataWithNew(oldResource, newResource);
}
@Test
- public void testBuildComplexVfcMetadata() {
+ void testBuildComplexVfcMetadata() {
Resource resource = createParseResourceObject(true);
String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
@@ -1172,31 +1093,29 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
nodeTypeInfo.setDerivedFrom(derivedFrom);
nodesInfo.put(nodeName, nodeTypeInfo);
-
Assertions.assertNotNull(
- bl.buildComplexVfcMetadata(getCsarInfo(), nodeName, nodesInfo));
+ testSubject.buildComplexVfcMetadata(getCsarInfo(), nodeName, nodesInfo));
}
@Test
- public void testValidateResourceCreationFromNodeType() {
+ void testValidateResourceCreationFromNodeType() {
Resource resource = createParseResourceObject(true);
resource.setDerivedFrom(null);
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateResourceCreationFromNodeType(resource, user));
+ testSubject.validateResourceCreationFromNodeType(resource, user));
}
@Test
- public void testCreateInputsOnResource() {
+ void testCreateInputsOnResource() {
Resource resource = createParseResourceObject(true);
Map<String, InputDefinition> inputs = new HashMap<>();
-
Assertions.assertNotNull(
- bl.createInputsOnResource(resource, inputs));
+ testSubject.createInputsOnResource(resource, inputs));
}
@Test
- public void testCreateInputsOnResourceWhenIsNotEmpty() {
+ void testCreateInputsOnResourceWhenIsNotEmpty() {
String key = "12345667";
Resource resource = createParseResourceObject(true);
List<InputDefinition> inputDefinitionList = new ArrayList<>();
@@ -1206,15 +1125,15 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
Map<String, InputDefinition> inputs = new HashMap<>();
inputs.put(key, inputDefinition);
when(inputsBusinessLogic.createInputsInGraph(anyMap(),
- any(Component.class))).thenReturn(Either.left(inputDefinitionList));
+ any(Component.class))).thenReturn(Either.left(inputDefinitionList));
when(toscaOperationFacade
- .getToscaElement(anyString())).thenReturn(Either.left(resource));
+ .getToscaElement(anyString())).thenReturn(Either.left(resource));
Assertions.assertNotNull(
- bl.createInputsOnResource(resource, inputs));
+ testSubject.createInputsOnResource(resource, inputs));
}
@Test
- public void testCreateInputsOnService() {
+ void testCreateInputsOnService() {
Service service = createServiceObject(true);
List<InputDefinition> resourceProperties = new ArrayList<>();
InputDefinition inputDefinition = new InputDefinition();
@@ -1228,29 +1147,29 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
Service newService = new Service();
when(inputsBusinessLogic.createInputsInGraph(any(Map.class), any(Component.class)))
- .thenReturn(Either.left(inputDefinitionList));
+ .thenReturn(Either.left(inputDefinitionList));
when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(newService));
- Service inputsOnService = bl.createInputsOnService(service, inputs);
+ Service inputsOnService = testSubject.createInputsOnService(service, inputs);
assertNotNull(inputsOnService);
}
@Test
- public void testCreateServiceTransaction() {
+ void testCreateServiceTransaction() {
Service service = createServiceObject(true);
List<ComponentInstance> list = new ArrayList<>();
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setName("name");
service.setComponentInstances(list);
when(toscaOperationFacade.validateComponentNameExists(
- anyString(), any(ResourceTypeEnum.class), any(ComponentTypeEnum.class))).thenReturn(Either.left(false));
+ anyString(), any(ResourceTypeEnum.class), any(ComponentTypeEnum.class))).thenReturn(Either.left(false));
when(toscaOperationFacade.createToscaComponent(any(Service.class))).thenReturn(Either.left(service));
- Assertions.assertThrows(NullPointerException.class, () -> bl.createServiceTransaction(service, user, true));
+ Assertions.assertThrows(NullPointerException.class, () -> testSubject.createServiceTransaction(service, user, true));
}
@Test
- public void testCreateArtifactsPlaceHolderData() {
+ void testCreateArtifactsPlaceHolderData() {
Service service = createServiceObject(true);
CategoryDefinition category = new CategoryDefinition();
category.setName("");
@@ -1259,22 +1178,22 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
service.setCategories(categories);
Assertions.assertNotNull(service);
- bl.createArtifactsPlaceHolderData(service, user);
+ testSubject.createArtifactsPlaceHolderData(service, user);
}
@Test
- public void testSetInformationalArtifactsPlaceHolder() {
+ void testSetInformationalArtifactsPlaceHolder() {
Service service = createServiceObject(true);
Assertions.assertNotNull(service);
- bl.setInformationalArtifactsPlaceHolder(service, user);
+ testSubject.setInformationalArtifactsPlaceHolder(service, user);
}
@Test
- public void testValidateNestedDerivedFromDuringUpdate() {
+ void testValidateNestedDerivedFromDuringUpdate() {
Resource currentResource = createParseResourceObject(true);
Resource updateInfoResource = createParseResourceObject(true);
String key = "2323456";
@@ -1287,103 +1206,101 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
updateInfoResource.setDerivedFrom(updatedDerivedFromList);
when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
- .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-
+ .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
Assertions.assertNotNull(
- bl.validateNestedDerivedFromDuringUpdate(currentResource, updateInfoResource, true));
+ testSubject.validateNestedDerivedFromDuringUpdate(currentResource, updateInfoResource, true));
}
@Test
- public void testValidateDerivedFromExtending() {
+ void testValidateDerivedFromExtending() {
Resource currentResource = createParseResourceObject(true);
Resource updateInfoResource = createParseResourceObject(true);
when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
- .thenReturn(Either.left(false));
+ .thenReturn(Either.left(false));
Assertions.assertNotNull(
- bl.validateDerivedFromExtending(user, currentResource, updateInfoResource,
- AuditingActionEnum.IMPORT_RESOURCE));
+ testSubject.validateDerivedFromExtending(user, currentResource, updateInfoResource,
+ AuditingActionEnum.IMPORT_RESOURCE));
}
@Test
- public void testValidateResourceFieldsBeforeUpdate() {
+ void testValidateResourceFieldsBeforeUpdate() {
Resource currentResource = createParseResourceObject(true);
Resource updateInfoResource = createParseResourceObject(true);
Assertions.assertNotNull(currentResource);
- bl.validateResourceFieldsBeforeUpdate(currentResource, updateInfoResource, true, true);
+ testSubject.validateResourceFieldsBeforeUpdate(currentResource, updateInfoResource, true, true);
}
@Test
- public void testValidateResourceName() {
+ void testValidateResourceName() {
Resource currentResource = createParseResourceObject(true);
Resource updateInfoResource = createParseResourceObject(true);
currentResource.setName("test1");
updateInfoResource.setName("test2");
-
Assertions.assertThrows(ComponentException.class, () ->
- bl.validateResourceName(currentResource, updateInfoResource, true, false));
+ testSubject.validateResourceName(currentResource, updateInfoResource, true, false));
}
@Test
- public void testIsResourceNameEquals() {
+ void testIsResourceNameEquals() {
Resource currentResource = createParseResourceObject(true);
Resource updateInfoResource = createParseResourceObject(true);
- boolean resourceNameEquals = bl.isResourceNameEquals(currentResource, updateInfoResource);
+ boolean resourceNameEquals = testSubject.isResourceNameEquals(currentResource, updateInfoResource);
assertTrue(resourceNameEquals);
}
@Test
- public void testPrepareResourceForUpdate() {
+ void testPrepareResourceForUpdate() {
Resource oldResource = createParseResourceObject(true);
Resource newResource = createParseResourceObject(true);
when(lifecycleBusinessLogic.changeState(anyString(), any(User.class), any(LifeCycleTransitionEnum.class),
- any(LifecycleChangeInfoWithAction.class), anyBoolean(), anyBoolean())).thenReturn(Either.left(oldResource));
+ any(LifecycleChangeInfoWithAction.class), anyBoolean(), anyBoolean())).thenReturn(Either.left(oldResource));
Assertions.assertNotNull(
- bl.prepareResourceForUpdate(oldResource, newResource, user, true, true));
+ testSubject.prepareResourceForUpdate(oldResource, newResource, user, true, true));
}
@Test
- public void testFailOnChangeState() {
+ void testFailOnChangeState() {
ResponseFormat response = new ResponseFormat();
Resource oldResource = createParseResourceObject(true);
oldResource.setUniqueId("123");
Resource newResource = createParseResourceObject(true);
Assertions.assertThrows(ComponentException.class, () ->
- bl.failOnChangeState(response, user, oldResource, newResource));
+ testSubject.failOnChangeState(response, user, oldResource, newResource));
}
@Test
- public void testHandleResourceGenericType() {
+ void testHandleResourceGenericType() {
Resource resource = createParseResourceObject(true);
- Resource resource1 = bl.handleResourceGenericType(resource);
+ Resource resource1 = testSubject.handleResourceGenericType(resource);
assertNotEquals(resource, resource1);
}
@Test
- public void testUpdateOrCreateGroups() {
+ void testUpdateOrCreateGroups() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = new HashMap<>();
Assertions.assertNotNull(resource);
- bl.updateOrCreateGroups(resource, groups);
+ testSubject.updateOrCreateGroups(resource, groups);
}
@Test
- public void testAddGroupsToCreateOrUpdate() {
+ void testAddGroupsToCreateOrUpdate() {
List<GroupDefinition> groupsFromResource = new ArrayList<>();
GroupDefinition groupDefinition = new GroupDefinition();
groupDefinition.setInvariantName("groupDefinitionName");
@@ -1395,11 +1312,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
List<GroupDefinition> groupsToCreate = new ArrayList<>();
Assertions.assertNotNull(groupDefinition);
- bl.addGroupsToCreateOrUpdate(groupsFromResource, groupsAsList, groupsToUpdate, groupsToCreate);
+ testSubject.addGroupsToCreateOrUpdate(groupsFromResource, groupsAsList, groupsToUpdate, groupsToCreate);
}
@Test
- public void testAddGroupsToDelete() {
+ void testAddGroupsToDelete() {
List<GroupDefinition> groupsFromResource = new ArrayList<>();
GroupDefinition groupDefinition = new GroupDefinition();
groupDefinition.setName("groupDefinitionName");
@@ -1411,11 +1328,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
List<GroupDefinition> groupsToDelete = new ArrayList<>();
Assertions.assertNotNull(groupsFromResource);
- bl.addGroupsToDelete(groupsFromResource, groupsAsList, groupsToDelete);
+ testSubject.addGroupsToDelete(groupsFromResource, groupsAsList, groupsToDelete);
}
@Test
- public void testUpdateGroupsMembersUsingResource() {
+ void testUpdateGroupsMembersUsingResource() {
Service component = createServiceObject(true);
Map<String, GroupDefinition> groups = new HashMap<>();
GroupDefinition groupDefinition = getGroupDefinition();
@@ -1423,11 +1340,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
groups.put("groupsMap", groupDefinition);
Assertions.assertNotNull(
- bl.updateGroupsMembersUsingResource(groups, component));
+ testSubject.updateGroupsMembersUsingResource(groups, component));
}
@Test
- public void testupdateGroupMembers() {
+ void testupdateGroupMembers() {
Service component = createServiceObject(true);
Map<String, GroupDefinition> groups = new HashMap<>();
GroupDefinition updatedGroupDefinition = new GroupDefinition();
@@ -1436,11 +1353,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
Map<String, String> members = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members));
+ testSubject.updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members));
}
@Test
- public void testupdateGroupMembersNotNull() {
+ void testupdateGroupMembersNotNull() {
Service component = createServiceObject(true);
Map<String, GroupDefinition> groups = getGroups();
GroupDefinition updatedGroupDefinition = new GroupDefinition();
@@ -1455,34 +1372,33 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
members.put("componentInstanceName", "members");
Assertions.assertThrows(ComponentException.class, () ->
- bl.updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members));
+ testSubject.updateGroupMembers(groups, updatedGroupDefinition, component, componentInstances, groupName, members));
}
@Test
- public void testValidateCyclicGroupsDependencies() {
+ 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(
- bl.validateCyclicGroupsDependencies(groups));
+ testSubject.validateCyclicGroupsDependencies(groups));
}
@Test
- public void testFillAllGroupMemebersRecursivly() {
+ void testFillAllGroupMemebersRecursivly() {
Map<String, GroupDefinition> allGroups = new HashMap<>();
Set<String> allGroupMembers = new HashSet<>();
String groupName = "groupName";
Assertions.assertNotNull(groupName);
- bl.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers);
+ testSubject.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers);
}
@Test
- public void testFillAllGroupMemebersRecursivlyAllGroups() {
+ void testFillAllGroupMemebersRecursivlyAllGroups() {
String groupName = "groupName";
Map<String, GroupDefinition> allGroups = new HashMap<>();
GroupDefinition groupDefinition = new GroupDefinition();
@@ -1495,65 +1411,63 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
allGroupMembers.add("allGroupMembers");
Assertions.assertNotNull(allGroups);
- bl.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers);
+ testSubject.fillAllGroupMemebersRecursivly(groupName, allGroups, allGroupMembers);
}
@Test
- public void testFillResourceMetadataForServiceFailure() {
+ void testFillResourceMetadataForServiceFailure() {
String yamlName = "yamlName";
Service resourceVf = createServiceObject(true);
String nodeName = "nodeName";
Assertions.assertThrows(ComponentException.class, () ->
- bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
+ testSubject.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
}
@Test
- public void testFillResourceMetadataForServiceWrongType() {
+ void testFillResourceMetadataForServiceWrongType() {
String yamlName = "yamlName";
Service resourceVf = createServiceObject(true);
String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "nodeName";
Assertions.assertThrows(ComponentException.class, () ->
- bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
+ testSubject.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
}
@Test
- public void testFillResourceMetadataForServiceSuccess() {
+ void testFillResourceMetadataForServiceSuccess() {
String yamlName = "yamlName";
Service resourceVf = createServiceObject(true);
String nodeName = Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "VFC";
-
Assertions.assertNotNull(
- bl.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
+ testSubject.fillResourceMetadata(yamlName, resourceVf, nodeName, user));
}
@Test
- public void testpropagateStateToCertified() {
+ void testpropagateStateToCertified() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
resource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
-
Assertions.assertNotNull(
- bl.propagateStateToCertified(user, resource, lifecycleChangeInfo, true, true, true));
+ testSubject.propagateStateToCertified(user, resource, lifecycleChangeInfo, true, true, true));
}
@Test
- public void testpropagateStateToCertifiedIsTrue() {
+ void testpropagateStateToCertifiedIsTrue() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
resource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
Assertions.assertNotNull(
- bl.propagateStateToCertified(user, resource, lifecycleChangeInfo, true, true, true));
+ testSubject.propagateStateToCertified(user, resource, lifecycleChangeInfo, true, true, true));
}
@Test
- public void testBuildValidComplexVfc2() {
+ void testBuildValidComplexVfc2() {
String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
Map<String, NodeTypeInfo> nodesInfo = new HashMap<>();
NodeTypeInfo nodeTypeInfo = new NodeTypeInfo();
@@ -1562,22 +1476,22 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
nodeTypeInfo.setDerivedFrom(derivedFrom);
nodesInfo.put(nodeName, nodeTypeInfo);
+ final CsarInfo csarInfo = getCsarInfo();
Assertions.assertThrows(ComponentException.class, () ->
- bl.buildValidComplexVfc(getCsarInfo(), nodeName, nodesInfo));
+ testSubject.buildValidComplexVfc(csarInfo, nodeName, nodesInfo));
}
@Test
- public void testUpdateGroupsOnResourceEmptyGroups() {
+ void testUpdateGroupsOnResourceEmptyGroups() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = new HashMap<>();
-
Assertions.assertNotNull(
- bl.updateGroupsOnResource(resource, groups));
+ testSubject.updateGroupsOnResource(resource, groups));
}
@Test
- public void testSetInformationalArtifactsPlaceHolder2() {
+ void testSetInformationalArtifactsPlaceHolder2() {
Resource resource = createParseResourceObject(true);
List<CategoryDefinition> categoryDefinitions = new ArrayList<>();
CategoryDefinition categoryDefinition = new CategoryDefinition();
@@ -1586,11 +1500,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
resource.setCategories(categoryDefinitions);
Assertions.assertNotNull(resource);
- bl.setInformationalArtifactsPlaceHolder(resource, user);
+ testSubject.setInformationalArtifactsPlaceHolder(resource, user);
}
@Test
- public void testRollback() {
+ void testRollback() {
Resource resource = createParseResourceObject(true);
List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
@@ -1599,11 +1513,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
nodeTypesNewCreatedArtifacts.add(artifactDefinition);
Assertions.assertNotNull(resource);
- bl.rollback(true, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
+ testSubject.rollback(true, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
}
@Test
- public void testRollback_NotNull() {
+ void testRollback_NotNull() {
Resource resource = createParseResourceObject(true);
List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
ArtifactDefinition artifactDefinition = new ArtifactDefinition();
@@ -1615,38 +1529,38 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
nodeTypesNewCreatedArtifacts.add(artifactDefinition2);
Assertions.assertNotNull(resource);
- bl.rollback(true, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
+ testSubject.rollback(true, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
}
@Test
- public void testCreateArtifactsPlaceHolderData2() {
+ void testCreateArtifactsPlaceHolderData2() {
Resource resource = createParseResourceObject(true);
Assertions.assertNotNull(resource);
- bl.createArtifactsPlaceHolderData(resource, user);
+ testSubject.createArtifactsPlaceHolderData(resource, user);
}
@Test
- public void testHandleGroupsProperties() {
+ void testHandleGroupsProperties() {
Service service = createServiceObject(true);
Map<String, GroupDefinition> groups = getGroups();
Assertions.assertNotNull(service);
- bl.handleGroupsProperties(service, groups);
+ testSubject.handleGroupsProperties(service, groups);
}
@Test
- public void testHandleGroupsProperties2() {
+ void testHandleGroupsProperties2() {
Resource resource = createParseResourceObject(true);
Map<String, GroupDefinition> groups = getGroups();
Assertions.assertNotNull(resource);
- bl.handleGroupsProperties(resource, groups);
+ testSubject.handleGroupsProperties(resource, groups);
}
@Test
- public void testHandleGetInputs() {
+ void testHandleGetInputs() {
PropertyDataDefinition property = new PropertyDataDefinition();
List<GetInputValueDataDefinition> getInputValues = new ArrayList<>();
GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
@@ -1665,11 +1579,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
inputs.add(inputDefinition);
Assertions.assertNotNull(inputs);
- bl.handleGetInputs(property, inputs);
+ testSubject.handleGetInputs(property, inputs);
}
@Test
- public void testHandleGetInputs_null() {
+ void testHandleGetInputs_null() {
PropertyDataDefinition property = new PropertyDataDefinition();
List<GetInputValueDataDefinition> getInputValues = new ArrayList<>();
GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
@@ -1679,11 +1593,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
property.setGetInputValues(getInputValues);
List<InputDefinition> inputs = new ArrayList<>();
Assertions.assertThrows(NoSuchElementException.class, () ->
- bl.handleGetInputs(property, inputs));
+ testSubject.handleGetInputs(property, inputs));
}
@Test
- public void testFindInputByName() {
+ void testFindInputByName() {
GetInputValueDataDefinition getInput = new GetInputValueDataDefinition();
getInput.setInputId("inputId");
getInput.setInputName("inputName");
@@ -1694,20 +1608,20 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
inputs.add(inputDefinition);
Assertions.assertNotNull(
- bl.findInputByName(inputs, getInput));
+ testSubject.findInputByName(inputs, getInput));
}
@Test
- public void testAssociateComponentInstancePropertiesToComponent() {
+ void testAssociateComponentInstancePropertiesToComponent() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties));
+ testSubject.associateComponentInstancePropertiesToComponent(yamlName, resource, instProperties));
}
@Test
- public void testAssociateComponentInstanceInputsToComponent() {
+ void testAssociateComponentInstanceInputsToComponent() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1717,79 +1631,79 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
componentInstanceInputList.add(componentInstanceInput);
Assertions.assertNotNull(resource);
- bl.associateComponentInstanceInputsToComponent(yamlName, resource, instInputs);
+ testSubject.associateComponentInstanceInputsToComponent(yamlName, resource, instInputs);
}
@Test
- public void testAssociateDeploymentArtifactsToInstances() {
+ void testAssociateDeploymentArtifactsToInstances() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts));
+ testSubject.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts));
}
@Test
- public void testAssociateArtifactsToInstances() {
+ void testAssociateArtifactsToInstances() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts));
+ testSubject.associateDeploymentArtifactsToInstances(user, yamlName, resource, instDeploymentArtifacts));
}
@Test
- public void testAssociateArtifactsToInstances2() {
+ void testAssociateArtifactsToInstances2() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateArtifactsToInstances(yamlName, resource, instDeploymentArtifacts));
+ testSubject.associateArtifactsToInstances(yamlName, resource, instDeploymentArtifacts));
}
@Test
- public void testAssociateOrAddCalculatedCapReq() {
+ void testAssociateOrAddCalculatedCapReq() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities = new HashMap<>();
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements));
+ testSubject.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements));
}
@Test
- public void testAssociateInstAttributeToComponentToInstances() {
+ void testAssociateInstAttributeToComponentToInstances() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes));
+ testSubject.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes));
}
@Test
- public void testThrowComponentExceptionByResource() {
+ void testThrowComponentExceptionByResource() {
StorageOperationStatus status = StorageOperationStatus.OK;
Resource resource = createParseResourceObject(true);
Assertions.assertThrows(ComponentException.class, () ->
- bl.throwComponentExceptionByResource(status, resource));
+ testSubject.throwComponentExceptionByResource(status, resource));
}
@Test
- public void testGetResourceAfterCreateRelations() {
+ void testGetResourceAfterCreateRelations() {
Resource resource = createParseResourceObject(true);
Resource newResource = new Resource();
when(toscaOperationFacade.getToscaElement(anyString(), any(ComponentParametersView.class)))
- .thenReturn(Either.left(newResource));
- Resource resourceAfterCreateRelations = bl.getResourceAfterCreateRelations(resource);
+ .thenReturn(Either.left(newResource));
+ Resource resourceAfterCreateRelations = testSubject.getResourceAfterCreateRelations(resource);
assertNotNull(resourceAfterCreateRelations);
}
@Test
- public void testSetCapabilityNamesTypes() {
+ void testSetCapabilityNamesTypes() {
Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>();
List<CapabilityDefinition> capabilityDefinitionList = new ArrayList<>();
CapabilityDefinition capabilityDefinition = new CapabilityDefinition();
@@ -1804,22 +1718,22 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
uploadedCapabilities.put("Capability", uploadCapInfoList);
Assertions.assertNotNull(originCapabilities);
- bl.setCapabilityNamesTypes(originCapabilities, uploadedCapabilities);
+ testSubject.setCapabilityNamesTypes(originCapabilities, uploadedCapabilities);
}
@Test
- public void testAssociateComponentInstanceInputsToComponent2() {
+ void testAssociateComponentInstanceInputsToComponent2() {
String yamlName = "yamlName";
Service service = createServiceObject(true);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
Assertions.assertNotNull(service);
- bl.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
+ testSubject.associateComponentInstanceInputsToComponent(yamlName, service, instInputs);
}
@Test
- public void testAssociateComponentInstanceInputsNotNullToComponent2() {
+ void testAssociateComponentInstanceInputsNotNullToComponent2() {
String yamlName = "yamlName";
Service service = createServiceObject(true);
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
@@ -1829,105 +1743,105 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
componentInstanceInputs.add(componentInstanceInput);
instInputs.put("instInputs", componentInstanceInputs);
when(toscaOperationFacade.associateComponentInstanceInputsToComponent(any(Map.class),
- anyString())).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ anyString())).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateComponentInstanceInputsToComponent(yamlName, service, instInputs));
+ testSubject.associateComponentInstanceInputsToComponent(yamlName, service, instInputs));
}
@Test
- public void testAssociateComponentInstancePropertiesToComponent2() {
+ void testAssociateComponentInstancePropertiesToComponent2() {
String yamlName = "yamlName";
Service service = createServiceObject(true);
Map<String, List<ComponentInstanceProperty>> instInputs = new HashMap<>();
Map<String, List<ComponentInstanceProperty>> instInputMap = new HashMap<>();
when(toscaOperationFacade.associateComponentInstancePropertiesToComponent(any(), anyString()))
- .thenReturn(Either.left(instInputMap));
+ .thenReturn(Either.left(instInputMap));
Assertions.assertNotNull(service);
- bl.associateComponentInstancePropertiesToComponent(yamlName, service, instInputs);
+ testSubject.associateComponentInstancePropertiesToComponent(yamlName, service, instInputs);
}
@Test
- public void testAssociateDeploymentArtifactsToInstances2() {
+ void testAssociateDeploymentArtifactsToInstances2() {
String yamlName = "yamlName";
Service service = createServiceObject(true);
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateDeploymentArtifactsToInstances(user, yamlName, service, instDeploymentArtifacts));
+ testSubject.associateDeploymentArtifactsToInstances(user, yamlName, service, instDeploymentArtifacts));
}
@Test
- public void testAssociateArtifactsToInstances3() {
+ void testAssociateArtifactsToInstances3() {
String yamlName = "yamlName";
Service service = createServiceObject(true);
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateArtifactsToInstances(yamlName, service, instArtifacts));
+ testSubject.associateArtifactsToInstances(yamlName, service, instArtifacts));
}
@Test
- public void testAssociateOrAddCalculatedCapReq2() {
+ void testAssociateOrAddCalculatedCapReq2() {
String yamlName = "yamlName";
Service resource = createServiceObject(true);
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities = new HashMap<>();
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements));
+ testSubject.associateOrAddCalculatedCapReq(yamlName, resource, instCapabilities, instRequirements));
}
@Test
- public void testAssociateInstAttributeToComponentToInstances2() {
+ void testAssociateInstAttributeToComponentToInstances2() {
String yamlName = "yamlName";
Service resource = createServiceObject(true);
Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes));
+ testSubject.associateInstAttributeToComponentToInstances(yamlName, resource, instAttributes));
}
@Test
- public void testAssociateRequirementsToService() {
+ void testAssociateRequirementsToService() {
String yamlName = "yamlName";
Service resource = createServiceObject(true);
Map<String, ListRequirementDataDefinition> requirements = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateRequirementsToService(yamlName, resource, requirements));
+ testSubject.associateRequirementsToService(yamlName, resource, requirements));
}
@Test
- public void testAssociateCapabilitiesToService() {
+ void testAssociateCapabilitiesToService() {
String yamlName = "yamlName";
Service resource = createServiceObject(true);
Map<String, ListCapabilityDataDefinition> capabilities = new HashMap<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateCapabilitiesToService(yamlName, resource, capabilities));
+ testSubject.associateCapabilitiesToService(yamlName, resource, capabilities));
}
@Test
- public void testAssociateResourceInstances() {
+ void testAssociateResourceInstances() {
String yamlName = "yamlName";
Service resource = createServiceObject(true);
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
when(toscaOperationFacade.associateResourceInstances(any(Component.class),
- anyString(), any(ArrayList.class))).thenReturn(Either.left(relations));
+ anyString(), any(ArrayList.class))).thenReturn(Either.left(relations));
Assertions.assertNotNull(resource);
- bl.associateResourceInstances(yamlName, resource, relations);
+ testSubject.associateResourceInstances(yamlName, resource, relations);
}
@Test
- public void testAddCapabilities() {
+ void testAddCapabilities() {
Map<String, List<CapabilityDefinition>> originCapabilities = new HashMap<>();
String type = "type";
List<CapabilityDefinition> capabilities = new ArrayList<>();
Assertions.assertNotNull(type);
- bl.addCapabilities(originCapabilities, type, capabilities);
+ testSubject.addCapabilities(originCapabilities, type, capabilities);
}
@Test
- public void testAddCapabilitiesProperties() {
+ void testAddCapabilitiesProperties() {
Map<String, Map<String, UploadPropInfo>> newPropertiesMap = new HashMap<>();
List<UploadCapInfo> capabilities = new ArrayList<>();
UploadCapInfo capability = new UploadCapInfo();
@@ -1940,42 +1854,42 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
capabilities.add(capability);
Assertions.assertNotNull(capabilities);
- bl.addCapabilitiesProperties(newPropertiesMap, capabilities);
+ testSubject.addCapabilitiesProperties(newPropertiesMap, capabilities);
}
@Test
- public void testGetServiceWithGroups() {
+ void testGetServiceWithGroups() {
String resourceId = "resourceId";
Service service = createServiceObject(true);
when(toscaOperationFacade.getToscaElement(anyString(), any(ComponentParametersView.class)))
- .thenReturn(Either.left(service));
+ .thenReturn(Either.left(service));
Assertions.assertNotNull(
- bl.getServiceWithGroups(resourceId));
+ testSubject.getServiceWithGroups(resourceId));
}
@Test
- public void testGetResourceWithGroups() {
+ void testGetResourceWithGroups() {
String resourceId = "resourceId";
Resource resource = createParseResourceObject(false);
when(toscaOperationFacade.getToscaElement(anyString(), any(ComponentParametersView.class)))
- .thenReturn(Either.left(resource));
+ .thenReturn(Either.left(resource));
Assertions.assertNotNull(
- bl.getResourceWithGroups(resourceId));
+ testSubject.getResourceWithGroups(resourceId));
}
@Test
- public void testAssociateResourceInstances2() {
+ void testAssociateResourceInstances2() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
when(toscaOperationFacade.associateResourceInstances(any(Resource.class),
- anyString(), any(ArrayList.class))).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+ anyString(), any(ArrayList.class))).thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
Assertions.assertThrows(ComponentException.class, () ->
- bl.associateResourceInstances(yamlName, resource, relations));
+ testSubject.associateResourceInstances(yamlName, resource, relations));
}
@Test
- public void testAddRelationsToRI() {
+ void testAddRelationsToRI() {
String yamlName = "group.yml";
Resource resource = createResourceObject(false);
@@ -2004,11 +1918,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
responseFormat.setStatus(200);
Assertions.assertNotNull(resource);
- bl.addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList, relations);
+ testSubject.addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList, relations);
}
@Test
- public void testAddRelationsToRI_null() {
+ void testAddRelationsToRI_null() {
String yamlName = "group.yml";
Resource resource = createParseResourceObject(true);
Map<String, UploadComponentInstanceInfo> uploadResInstancesMap = new HashMap<>();
@@ -2018,12 +1932,12 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Assertions.assertThrows(ComponentException.class, () ->
- bl.addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList,
- relations));
+ testSubject.addRelationsToRI(yamlName, resource, uploadResInstancesMap, componentInstancesList,
+ relations));
}
@Test
- public void testAddRelationToRI() {
+ void testAddRelationToRI() {
String yamlName = "yamlName";
Resource resource = createParseResourceObject(true);
resource.setComponentInstances(creatComponentInstances());
@@ -2031,11 +1945,11 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Assertions.assertNotNull(
- bl.addRelationToRI(yamlName, resource, nodesInfoValue, relations));
+ testSubject.addRelationToRI(yamlName, resource, nodesInfoValue, relations));
}
@Test
- public void testAddRelationToRI_null() {
+ void testAddRelationToRI_null() {
String yamlName = "yamlName.yml";
Resource resource = createParseResourceObject(false);
List<ComponentInstance> componentInstancesList = new ArrayList<>();
@@ -2043,22 +1957,23 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
UploadComponentInstanceInfo nodesInfoValue = getuploadComponentInstanceInfo();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Assertions.assertNotNull(
- bl.addRelationToRI(yamlName, resource, nodesInfoValue, relations));
+ testSubject.addRelationToRI(yamlName, resource, nodesInfoValue, relations));
}
@Test
- public void testFindVfcResource() {
+ void testFindVfcResource() {
Service service = createServiceObject(true);
String currVfcToscaName = "currVfcToscaName";
String previousVfcToscaName = "previousVfcToscaName";
UploadComponentInstanceInfo nodesInfoValue = new UploadComponentInstanceInfo();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
+ final CsarInfo csarInfo = getCsarInfo();
Assertions.assertThrows(ComponentException.class, () ->
- bl.findVfcResource(getCsarInfo(), service, currVfcToscaName, previousVfcToscaName,
- StorageOperationStatus.OK));
+ testSubject.findVfcResource(csarInfo, service, currVfcToscaName, previousVfcToscaName,
+ StorageOperationStatus.OK));
}
- protected GroupDefinition getGroupDefinition() {
+ private GroupDefinition getGroupDefinition() {
GroupDefinition groupDefinition = new GroupDefinition();
Map<String, String> members = new HashMap<>();
members.put("members", "members");
@@ -2106,7 +2021,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
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);
@@ -2126,17 +2041,15 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
} catch (IOException e) {
e.printStackTrace();
}
- CsarInfo csarInfo = new CsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent,
- false);
- return csarInfo;
+ return new CsarInfo(user, csarUuid, csar, vfReousrceName, mainTemplateName, mainTemplateContent, false);
}
- public static String loadFileNameToJsonString(String fileName) throws IOException {
+ private 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 {
+ private 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);
@@ -2174,7 +2087,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
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);
}
@@ -2183,4 +2096,5 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
assertThat(expectedResponse.getStatus()).isEqualTo(actualResponse.getStatus());
assertThat(expectedResponse.getFormattedMessage()).isEqualTo(actualResponse.getFormattedMessage());
}
-} \ No newline at end of file
+
+}