aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java58
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java3
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java27
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java4
10 files changed, 80 insertions, 54 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
index be3a408bfa..2ce03f3d1c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
@@ -65,7 +65,7 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
private static final String FAILED = " failed";
private final YamlTemplateParsingHandler yamlHandler;
private CsarOperation csarOperation;
- private ModelOperation modelOperation;
+ private final ModelOperation modelOperation;
@Autowired
public CsarBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, IGroupInstanceOperation groupInstanceOperation,
@@ -164,6 +164,10 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
toscaYamlCsarStatus.getValue(), true, modelOperation);
}
+ public ParsedToscaYamlInfo getParsedToscaYamlInfo(final ServiceCsarInfo csarInfo, final Service service){
+ return getParsedToscaYamlInfo(csarInfo.getMainTemplateContent(), csarInfo.getMainTemplateName(), csarInfo.extractTypesInfo(), csarInfo, null, service);
+ }
+
public ParsedToscaYamlInfo getParsedToscaYamlInfo(String topologyTemplateYaml, String yamlName, Map<String, NodeTypeInfo> nodeTypesInfo,
CsarInfo csarInfo, String nodeName, Component component) {
return yamlHandler
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 7e7348d89e..6e385b200a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -1346,7 +1346,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Function<Resource, Boolean> validator = resource -> validateResourceCreationFromNodeType(resource, creator);
return resourceImportManager
.importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock,
- nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested);
+ nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested, null);
}
/**
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 8976753638..99dea8f04d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -66,6 +66,7 @@ import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
@@ -84,10 +85,11 @@ import org.openecomp.sdc.be.model.DefaultUploadResourceInfo;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.NodeTypesMetadataList;
-import org.openecomp.sdc.be.model.NullNodeTypeMetadata;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RequirementDefinition;
import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadInterfaceInfo;
import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.category.CategoryDefinition;
@@ -154,13 +156,14 @@ public class ResourceImportManager {
}
public ImmutablePair<Resource, ActionStatus> importNormativeResource(final String resourceYml, final UploadResourceInfo resourceMetaData,
+ final Map<String, UploadComponentInstanceInfo> instancesFromCsar,
final User creator, final boolean createNewVersion, final boolean needLock,
final boolean isInTransaction) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
lifecycleChangeInfo.setUserRemarks("certification on import");
Function<Resource, Boolean> validator = resource -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, createNewVersion,
- needLock, null, null, false, null, null, false);
+ needLock, null, null, false, null, null, false, instancesFromCsar);
}
public void importAllNormativeResource(final String resourcesYaml, final NodeTypesMetadataList nodeTypesMetadataList, final User user,
@@ -176,11 +179,11 @@ public class ResourceImportManager {
return;
}
final Map<String, Object> nodeTypesMap = (Map<String, Object>) nodeTypesYamlMap.get(ToscaTagNamesEnum.NODE_TYPES.getElementName());
- importAllNormativeResource(nodeTypesMap, nodeTypesMetadataList, user, "", createNewVersion,needLock);
+ importAllNormativeResource(nodeTypesMap, nodeTypesMetadataList, null, user, "", createNewVersion,needLock);
}
public void importAllNormativeResource(final Map<String, Object> nodeTypesMap, final NodeTypesMetadataList nodeTypesMetadataList,
- final User user, String model, final boolean createNewVersion, final boolean needLock) {
+ Map<String, UploadComponentInstanceInfo> instancesFromCsar, final User user, String model, final boolean createNewVersion, final boolean needLock) {
try {
nodeTypesMetadataList.getNodeMetadataList().forEach(nodeTypeMetadata -> {
final String nodeTypeToscaName = nodeTypeMetadata.getToscaName();
@@ -199,7 +202,7 @@ public class ResourceImportManager {
uploadResourceInfo.setModel(model);
uploadResourceInfo.setContactId(user.getUserId());
}
- importNormativeResource(nodeTypeYaml, uploadResourceInfo, user, createNewVersion, needLock, true);
+ importNormativeResource(nodeTypeYaml, uploadResourceInfo, instancesFromCsar, user, createNewVersion, needLock, true);
}
});
janusGraphDao.commit();
@@ -209,6 +212,15 @@ public class ResourceImportManager {
}
}
+ public ImmutablePair<Resource, ActionStatus> importNormativeResourceFromCsar(String resourceYml, UploadResourceInfo resourceMetaData,
+ User creator, boolean createNewVersion, boolean needLock) {
+ LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
+ lifecycleChangeInfo.setUserRemarks("certification on import");
+ Function<Resource, Boolean> validator = resource -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
+ return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock,
+ null, null, false, null, null, false, null);
+ }
+
public ImmutablePair<Resource, ActionStatus> importCertifiedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator,
Function<Resource, Boolean> validationFunction,
LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean isInTransaction,
@@ -216,7 +228,7 @@ public class ResourceImportManager {
Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
boolean forceCertificationAllowed, CsarInfo csarInfo, String nodeName,
- boolean isNested) {
+ boolean isNested, Map<String, UploadComponentInstanceInfo> instancesFromCsar) {
Resource resource = new Resource();
ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> response = Either.left(responsePair);
@@ -225,7 +237,7 @@ public class ResourceImportManager {
boolean shouldBeCertified = nodeTypeArtifactsToHandle == null || nodeTypeArtifactsToHandle.isEmpty();
setConstantMetaData(resource, shouldBeCertified);
setResourceMetaData(resource, resourceYml, resourceMetaData);
- populateResourceFromYaml(resourceYml, resource);
+ populateResourceFromYaml(resourceYml, resource, instancesFromCsar);
validationFunction.apply(resource);
resource.getComponentMetadataDefinition().getMetadataDataDefinition().setNormative(resourceMetaData.isNormative());
checkResourceExists(createNewVersion, csarInfo, resource);
@@ -341,7 +353,7 @@ public class ResourceImportManager {
ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
try {
setMetaDataFromJson(resourceMetaData, resource);
- populateResourceFromYaml(resourceYml, resource);
+ populateResourceFromYaml(resourceYml, resource, null);
// currently import VF isn't supported. In future will be supported import VF only with CSAR file!!
if (ResourceTypeEnum.VF == resource.getResourceType()) {
log.debug("Now import VF isn't supported. It will be supported in future with CSAR file only");
@@ -356,7 +368,7 @@ public class ResourceImportManager {
return responsePair;
}
- private void populateResourceFromYaml(final String resourceYml, Resource resource) {
+ private void populateResourceFromYaml(final String resourceYml, Resource resource, Map<String, UploadComponentInstanceInfo> instancesFromCsar) {
@SuppressWarnings("unchecked") Object ymlObj = new Yaml().load(resourceYml);
if (ymlObj instanceof Map) {
final Either<Resource, StorageOperationStatus> existingResource = getExistingResource(resource);
@@ -383,7 +395,7 @@ public class ResourceImportManager {
setProperties(toscaJson, resource, existingResource);
setAttributes(toscaJson, resource);
setRequirements(toscaJson, resource, parentResource);
- setInterfaceLifecycle(toscaJson, resource, existingResource);
+ setInterfaceLifecycle(toscaJson, resource, existingResource, instancesFromCsar);
} else {
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
@@ -441,20 +453,29 @@ public class ResourceImportManager {
return null;
}
- private void setInterfaceLifecycle(Map<String, Object> toscaJson, Resource resource, Either<Resource, StorageOperationStatus> existingResource) {
+ private void setInterfaceLifecycle(Map<String, Object> toscaJson, Resource resource, Either<Resource, StorageOperationStatus> existingResource,
+ Map<String, UploadComponentInstanceInfo> instancesFromCsar) {
final Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils
.findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.INTERFACES);
final Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>();
final Map<String, Object> map;
+ List<UploadInterfaceInfo> interfaceInfoList = null;
+ if (MapUtils.isNotEmpty(instancesFromCsar)) {
+ interfaceInfoList = instancesFromCsar.values().stream().filter(i -> MapUtils.isNotEmpty(i.getInterfaces()))
+ .flatMap(i -> i.getInterfaces().values().stream()).collect(Collectors.toList());
+ }
if (toscaInterfaces.isLeft()) {
map = toscaInterfaces.left().value();
for (final Entry<String, Object> interfaceNameValue : map.entrySet()) {
- final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue(),
- resource.getModel());
+ final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface =
+ createModuleInterface(interfaceNameValue.getValue(), resource.getModel());
if (eitherInterface.isRight()) {
log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(), resource.getName());
} else {
final InterfaceDefinition interfaceDefinition = eitherInterface.left().value();
+ if (CollectionUtils.isNotEmpty(interfaceInfoList)) {
+ updateInterfaceDefinition(interfaceDefinition, interfaceInfoList);
+ }
moduleInterfaces.put(interfaceDefinition.getType(), interfaceDefinition);
}
}
@@ -480,6 +501,17 @@ public class ResourceImportManager {
}
}
+ private void updateInterfaceDefinition(InterfaceDefinition interfaceDefinition, List<UploadInterfaceInfo> interfaceInfoList) {
+ Map<String, OperationDataDefinition> operations = new HashMap<>();
+ interfaceInfoList.stream().filter(i -> interfaceDefinition.getType().endsWith(i.getKey())).forEach(i -> {
+ i.getOperations().values().forEach(o -> {
+ o.setImplementation(null);
+ });
+ operations.putAll(i.getOperations());
+ });
+ interfaceDefinition.setOperations(operations);
+ }
+
private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(final Object interfaceJson, final String model) {
try {
if (interfaceJson instanceof String) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 641e294e42..1ba74a1594 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -46,7 +46,6 @@ import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
@@ -389,7 +388,8 @@ public class ServiceImportBusinessLogic {
final List<NodeTypeDefinition> nodeTypesToCreate = getNodeTypesToCreate(serviceModel, csarInfo);
if (CollectionUtils.isNotEmpty(nodeTypesToCreate)) {
- createNodeTypes(nodeTypesToCreate, serviceModel, csarInfo.getModifier());
+ ParsedToscaYamlInfo parsedToscaYamlInfo = csarBusinessLogic.getParsedToscaYamlInfo(csarInfo, service);
+ createNodeTypes(nodeTypesToCreate, parsedToscaYamlInfo.getInstances(), serviceModel, csarInfo.getModifier());
}
final Map<String, Object> groupTypesToCreate = getGroupTypesToCreate(serviceModel, csarInfo);
@@ -539,7 +539,7 @@ public class ServiceImportBusinessLogic {
&& result.left().value().getProperties().size() != dataType.get("properties").size();
}
- private void createNodeTypes(List<NodeTypeDefinition> nodeTypesToCreate, String model, User user) {
+ private void createNodeTypes(List<NodeTypeDefinition> nodeTypesToCreate, Map<String, UploadComponentInstanceInfo> instancesFromCsar, String model, User user) {
NodeTypesMetadataList nodeTypesMetadataList = new NodeTypesMetadataList();
List<NodeTypeMetadata> nodeTypeMetadataList = new ArrayList<>();
final Map<String, Object> allTypesToCreate = new HashMap<>();
@@ -548,7 +548,7 @@ public class ServiceImportBusinessLogic {
nodeTypeMetadataList.add(nodeType.getNodeTypeMetadata());
});
nodeTypesMetadataList.setNodeMetadataList(nodeTypeMetadataList);
- resourceImportManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, model, true, false);
+ resourceImportManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, instancesFromCsar, user, model, true, false);
}
private List<NodeTypeDefinition> getNodeTypesToCreate(final String model, final ServiceCsarInfo csarInfo) {
@@ -874,23 +874,20 @@ public class ServiceImportBusinessLogic {
private boolean isInputFromComponentInstanceProperty(final String inputName, final List<ComponentInstance> componentInstances) {
- AtomicBoolean isInputFromCIProp = new AtomicBoolean(false);
if (CollectionUtils.isNotEmpty(componentInstances)) {
- outer:
for (ComponentInstance instance : componentInstances) {
for (PropertyDefinition instanceProperty : instance.getProperties()) {
if (CollectionUtils.isNotEmpty(instanceProperty.getGetInputValues())) {
for (GetInputValueDataDefinition getInputValueDataDefinition : instanceProperty.getGetInputValues()) {
if (inputName.equals(getInputValueDataDefinition.getInputName())) {
- isInputFromCIProp.set(true);
- break outer;
+ return true;
}
}
}
}
}
}
- return isInputFromCIProp.get();
+ return false;
}
private void associateInputToComponentInstanceProperty(final String userId, final InputDefinition input,
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 3c82df4a50..5bde56de80 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
@@ -1774,7 +1774,7 @@ public class ServiceImportParseLogic {
Function<Resource, Boolean> validator = resource -> validateResourceCreationFromNodeType(resource, creator);
return resourceImportManager
.importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock,
- nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested);
+ nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested, null);
}
public ImmutablePair<Resource, ActionStatus> createNodeTypeResourceFromYaml(String yamlName, Map.Entry<String, Object> nodeNameValue, User user,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
index ade8637715..58756642c1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
@@ -659,13 +659,13 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
if (CsarValidationUtils.isCsarPayloadName(resourceInfoObject.getPayloadName())) {
log.debug("import resource from csar");
importedResourceStatus = importResourceFromUICsar(resourceInfoObject, user, resourceUniqueId);
- } else if (!authority.isUserTypeResource()) {
- log.debug("import normative type resource");
- createOrUpdateResponse =
- resourceImportManager.importNormativeResource(yamlAsString, resourceInfoObject, user, createNewVersion, true, false);
- } else {
+ } else if (authority.isUserTypeResource()) {
log.debug("import user resource (not normative type)");
createOrUpdateResponse = resourceImportManager.importUserDefinedResource(yamlAsString, resourceInfoObject, user, false);
+ } else {
+ log.debug("import normative type resource");
+ createOrUpdateResponse =
+ resourceImportManager.importNormativeResource(yamlAsString, resourceInfoObject, null, user, createNewVersion, true, false);
}
if (createOrUpdateResponse != null) {
importedResourceStatus = createOrUpdateResponse;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java
index c1eccdbef0..00500888cb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java
@@ -197,8 +197,7 @@ public class ResourceUploadServlet extends AbstractValidationsServlet {
}
try {
- resourceImportManager
- .importAllNormativeResource(nodeTypesYamlString, nodeTypeMetadata, user, createNewVersion, false);
+ resourceImportManager.importAllNormativeResource(nodeTypesYamlString, nodeTypeMetadata, user, createNewVersion, false);
return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.CREATED), null);
} catch (final BusinessException e) {
throw e;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
index 7822bd8134..0d6922e3f2 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
@@ -33,9 +33,7 @@ import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyMap;
import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.contains;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
@@ -53,7 +51,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -172,7 +169,7 @@ class ResourceImportManagerTest {
String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-blockStorage.yml");
ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
Resource resource = createResource.left;
testSetConstantMetaData(resource);
@@ -198,7 +195,7 @@ class ResourceImportManagerTest {
final String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-blockStorage.yml");
ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
assertNotNull(createResource);
Resource resource = createResource.left;
assertNotNull(resource);
@@ -300,7 +297,7 @@ class ResourceImportManagerTest {
String jsonContent = "this is an invalid yml!";
ComponentException errorInfoFromTest = null;
try {
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
} catch (ComponentException e) {
errorInfoFromTest = e;
}
@@ -323,7 +320,7 @@ class ResourceImportManagerTest {
String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-webServer.yml");
ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
Resource resource = createResource.left;
testSetCapabilities(resource);
@@ -343,7 +340,7 @@ class ResourceImportManagerTest {
String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-port.yml");
ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
testSetRequirements(createResource.left);
}
@@ -367,7 +364,7 @@ class ResourceImportManagerTest {
when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(interfaceTypes));
final ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
assertSetInterfaceImplementation(createResource.left);
}
@@ -390,7 +387,7 @@ class ResourceImportManagerTest {
when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(interfaceTypes));
ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
assertNotNull(createResource);
Resource resource = createResource.getLeft();
assertNotNull(resource);
@@ -427,7 +424,7 @@ class ResourceImportManagerTest {
when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(interfaceTypes));
ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
assertNull(createResource.left.getInterfaces());
}
@@ -450,7 +447,7 @@ class ResourceImportManagerTest {
when(interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes(any())).thenReturn(Either.left(interfaceTypes));
ImmutablePair<Resource, ActionStatus> createResource =
- importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
assertNull(createResource.left.getInterfaces());
}
@@ -471,7 +468,7 @@ class ResourceImportManagerTest {
String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-blockStorage.yml");
var actualException = assertThrows(ByActionStatusComponentException.class,
- () -> importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false));
+ () -> importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false));
assertEquals(ActionStatus.COMPONENT_WITH_VENDOR_RELEASE_ALREADY_EXISTS, actualException.getActionStatus());
}
@@ -495,7 +492,7 @@ class ResourceImportManagerTest {
.createOrUpdateResourceByImport(any(Resource.class), any(User.class), eq(true), eq(true), eq(false), eq(null), eq(null), eq(false)))
.thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK)).thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.OK));
- importManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, user, "", false, false);
+ importManager.importAllNormativeResource(allTypesToCreate, nodeTypesMetadataList, null, user, "", false, false);
verify(janusGraphDao).commit();
}
@@ -610,7 +607,7 @@ class ResourceImportManagerTest {
interfaces.put(interfaceDefinition.getType(), interfaceDefinition);
resource.setInterfaces(interfaces);
- return importManager.importNormativeResource(jsonContent, resourceMD, user, true, true, false);
+ return importManager.importNormativeResource(jsonContent, resourceMD, null, user, true, true, false);
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
index e74160e69c..fc709ceaea 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogicTest.java
@@ -213,8 +213,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
when(serviceImportParseLogic.findNodeTypesArtifactsToHandle(any(Map.class), any(CsarInfo.class), any(Service.class)))
.thenReturn(Either.left(new HashMap<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>>()));
doReturn(getParsedToscaYamlInfo()).when(csarBusinessLogic).getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), any(), any(Service.class));
-// when(csarBusinessLogic.getParsedToscaYamlInfo(anyString(), anyString(), any(), any(CsarInfo.class), any(), any(Service.class)))
-// .thenReturn(getParsedToscaYamlInfo());
+ doReturn(getParsedToscaYamlInfo()).when(csarBusinessLogic).getParsedToscaYamlInfo(any(ServiceCsarInfo.class), any(Service.class));
when(serviceBusinessLogic.lockComponentByName(newService.getSystemName(), oldService, CREATE_RESOURCE)).thenReturn(Either.left(true));
when(toscaOperationFacade.getLatestResourceByToscaResourceName(anyString())).thenReturn(Either.left(createOldResource()));
when(serviceImportParseLogic.createServiceTransaction(oldService, csarInfo.getModifier(), false, AuditingActionEnum.CREATE_RESOURCE)).thenReturn(newService);
@@ -320,7 +319,7 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
assertNotNull(capabilityTypesMap.get("tosca.testcapabilitytypes.Name"));
ArgumentCaptor<Map<String, Object>> nodeTypes = ArgumentCaptor.forClass(Map.class);
- verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(),
+ verify(resourceImportManager).importAllNormativeResource(nodeTypes.capture(), any(), any(), any(), any(),
anyBoolean(), anyBoolean());
Map<String, Object> nodeTypesMap = nodeTypes.getValue();
Map<String, Object> newUpdatedNodeType = (Map<String, Object>) nodeTypesMap.get(updatedNodeType);
@@ -676,8 +675,6 @@ class ServiceImportBusinessLogicTest extends ServiceImportBussinessLogicBaseTest
artifactDefinition.setArtifactName("artifactDefinition");
deploymentArtifacts.put("deploymentArtifacts", artifactDefinition);
preparedService.setDeploymentArtifacts(deploymentArtifacts);
- String nodeName = "org.openecomp.resource.derivedFrom.zxjTestImportServiceAb.test";
- Map<String, EnumMap<ArtifactsBusinessLogic.ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
when(toscaOperationFacade.getToscaElement(anyString())).thenReturn(Either.left(createServiceObject(true)));
when(csarArtifactsAndGroupsBusinessLogic.updateResourceArtifactsFromCsar(any(CsarInfo.class), any(Service.class),
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
index 7a7b07f260..19a877cb9c 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ResourceUploadServletTest.java
@@ -206,7 +206,7 @@ class ResourceUploadServletTest extends JerseyTest {
when(servletUtils.getUserAdmin()).thenReturn(userBusinessLogic);
when(userBusinessLogic.getUser(anyString())).thenReturn(user);
when(resourceBusinessLogic.validatePropertiesDefaultValues(any())).thenReturn(true);
- when(resourceImportManager.importNormativeResource(anyString(), any(), any(), anyBoolean(), anyBoolean(), anyBoolean()))
+ when(resourceImportManager.importNormativeResource(anyString(), any(), any(), any(), anyBoolean(), anyBoolean(), anyBoolean()))
.thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.CREATED));
when(modelBusinessLogic.findModel(modelName)).thenReturn(Optional.of(new Model(modelName)));
final var response = target().path(multipartPath).request(MediaType.APPLICATION_JSON)
@@ -223,7 +223,7 @@ class ResourceUploadServletTest extends JerseyTest {
when(servletUtils.getUserAdmin()).thenReturn(userBusinessLogic);
when(userBusinessLogic.getUser(anyString())).thenReturn(user);
when(resourceBusinessLogic.validatePropertiesDefaultValues(any())).thenReturn(true);
- when(resourceImportManager.importNormativeResource(anyString(), any(), any(), anyBoolean(), anyBoolean(), anyBoolean()))
+ when(resourceImportManager.importNormativeResource(anyString(), any(), any(), any(), anyBoolean(), anyBoolean(), anyBoolean()))
.thenReturn(new ImmutablePair<>(new Resource(), ActionStatus.CREATED));
final var response = target().path(multipartPath).request(MediaType.APPLICATION_JSON)
.header(Constants.USER_ID_HEADER, USER_ID)