summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-10-19 09:18:55 +0100
committerJvD_Ericsson <jeff.van.dam@est.tech>2023-10-26 13:13:15 +0100
commit5d7ca5c1e86d7633a1954ae89334df18d264f82b (patch)
tree67637eb436ceac8c98d27ad9a4b154e0c65e8470
parent6b58f89d940d56bfda38b5f86ef5a86ee29f80cf (diff)
Improve test coverage
- Added some tests to - ToscaExportHandlerTest.java - ToscaExportHandlerTest.java - Removed unused code Issue-ID: SDC-4654 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: Iee23e3a148005e960eb9c986b7b0605e4f7c8337
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFactory.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionDownloadEventFactory.java5
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionNotificationEventFactory.java7
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventMigrationFactory.java46
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponse.java1
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ActivationRequestInformation.java26
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactTypeBusinessLogic.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java86
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ExternalRefsBusinessLogic.java1
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckInformer.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java39
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java47
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAnnotation.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaFilter.java32
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplate.java53
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInput.java18
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/types/ServiceConsumptionData.java36
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/user/Role.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/user/UserAdminAction.java24
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/config/HttpClientFactory.java1
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java1481
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java74
29 files changed, 829 insertions, 1273 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFactory.java
index d4e1c37c58..da2fc0a5d5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFactory.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/category/AuditCategoryEventFactory.java
@@ -43,12 +43,6 @@ public class AuditCategoryEventFactory extends AuditBaseEventFactory {
this(action, commonFields, buildUserName(modifier), categoryName, subCategoryName, groupingName, resourceType);
}
- public AuditCategoryEventFactory(AuditingActionEnum action, CommonAuditData commonFields, String modifier, String categoryName,
- String subCategoryName, String groupingName, String resourceType, String timestamp) {
- this(action, commonFields, modifier, categoryName, subCategoryName, groupingName, resourceType);
- event.setTimestamp1(timestamp);
- }
-
@Override
public String getLogPattern() {
return LOG_STR;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionDownloadEventFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionDownloadEventFactory.java
index b18ac6aaac..a8427107da 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionDownloadEventFactory.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionDownloadEventFactory.java
@@ -36,11 +36,6 @@ public class AuditDistributionDownloadEventFactory extends AuditBaseEventFactory
this.event = new DistributionDownloadEvent(getAction().getName(), commonFields, distributionData);
}
- public AuditDistributionDownloadEventFactory(CommonAuditData commonFields, DistributionData distributionData, String timestamp) {
- this(commonFields, distributionData);
- this.event.setTimestamp1(timestamp);
- }
-
@Override
public String getLogPattern() {
return LOG_STR;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionNotificationEventFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionNotificationEventFactory.java
index 05664b926e..36cb5d622c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionNotificationEventFactory.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/distribution/AuditDistributionNotificationEventFactory.java
@@ -42,13 +42,6 @@ public class AuditDistributionNotificationEventFactory extends AuditBaseEventFac
this(commonAuditData, resourceCommonInfo, resourceVersionInfo, did, AuditBaseEventFactory.buildUserName(modifier), topicName, opEnvFields);
}
- public AuditDistributionNotificationEventFactory(CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
- ResourceVersionInfo resourceVersionInfo, String did, String modifier, String topicName,
- OperationalEnvAuditData opEnvFields, String timestamp) {
- this(commonAuditData, resourceCommonInfo, resourceVersionInfo, did, modifier, topicName, opEnvFields);
- this.event.setTimestamp1(timestamp);
- }
-
private AuditDistributionNotificationEventFactory(CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
ResourceVersionInfo resourceVersionInfo, String did, String modifier, String topicName,
OperationalEnvAuditData opEnvFields) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventMigrationFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventMigrationFactory.java
deleted file mode 100644
index 579971d909..0000000000
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/resourceadmin/AuditResourceAdminEventMigrationFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.be.auditing.impl.resourceadmin;
-
-import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
-import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
-import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
-import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
-
-public class AuditResourceAdminEventMigrationFactory extends AuditResourceAdminEventFactory {
-
- public AuditResourceAdminEventMigrationFactory(AuditingActionEnum action, CommonAuditData commonFields, ResourceCommonInfo resourceCommonInfo,
- ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String invariantUuid,
- String modifier, String artifactData, String comment, String did, String toscaNodeType,
- String timestamp) {
- super(action, commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, modifier, artifactData, comment, did, toscaNodeType,
- timestamp);
- }
-
- @Override
- public String getLogPattern() {
- return "";
- }
-
- @Override
- public String[] getLogMessageParams() {
- return new String[0];
- }
-}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponse.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponse.java
index bebc286592..b397d26f75 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponse.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/CambriaErrorResponse.java
@@ -25,7 +25,6 @@ import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus;
public class CambriaErrorResponse {
- public static final int HTTP_OK = 200;
public static final int HTTP_INTERNAL_SERVER_ERROR = 500;
CambriaOperationStatus operationStatus;
Integer httpCode;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ActivationRequestInformation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ActivationRequestInformation.java
index 87ef16f163..26ded1f344 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ActivationRequestInformation.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ActivationRequestInformation.java
@@ -19,11 +19,13 @@
*/
package org.openecomp.sdc.be.components.impl;
+import lombok.Data;
import org.openecomp.sdc.be.model.Service;
/**
* Created by chaya on 10/22/2017.
*/
+@Data
public class ActivationRequestInformation {
private Service serviceToActivate;
@@ -35,28 +37,4 @@ public class ActivationRequestInformation {
this.workloadContext = workloadContext;
this.tenant = tenant;
}
-
- public String getTenant() {
- return tenant;
- }
-
- public void setTenant(String tenant) {
- this.tenant = tenant;
- }
-
- public Service getServiceToActivate() {
- return serviceToActivate;
- }
-
- public void setServiceToActivate(Service serviceToActivate) {
- this.serviceToActivate = serviceToActivate;
- }
-
- public String getWorkloadContext() {
- return workloadContext;
- }
-
- public void setWorkloadContext(String workloadContext) {
- this.workloadContext = workloadContext;
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactTypeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactTypeBusinessLogic.java
index 126571741f..39f6041c5d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactTypeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactTypeBusinessLogic.java
@@ -39,8 +39,6 @@ import org.springframework.beans.factory.annotation.Autowired;
@org.springframework.stereotype.Component("artifactTypeBusinessLogic")
public class ArtifactTypeBusinessLogic extends BaseBusinessLogic {
- private static final Logger log = Logger.getLogger(ArtifactTypeBusinessLogic.class.getName());
-
private final ArtifactTypeOperation artifactTypeOperation;
@Autowired
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 06b4a34062..71d55d362b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -3744,7 +3744,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
errorWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status)));
}
if (errorWrapper.isEmpty()) {
- NodeTypeEnum parentType = convertParentType(componentType);
final List<ArtifactDefinition> existingDeploymentArtifacts = getDeploymentArtifacts(toscaComponentEither.left().value(), null);
for (ArtifactDefinition artifactDefinition : existingDeploymentArtifacts) {
if (artifactInfo.getArtifactName().equalsIgnoreCase(artifactDefinition.getArtifactName())) {
@@ -4032,7 +4031,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
String componentId = component.getUniqueId();
String artifactId = artifactDefinition.getUniqueId();
Either<ArtifactDefinition, Operation> result;
- Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
//artifact validation
artifactDefinition = validateArtifact(componentId, componentType, operation, artifactId, artifactDefinition, auditingAction, user, component,
shouldLock, inTransaction);
@@ -4224,7 +4222,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic {
}
private Component checkoutParentComponent(ComponentTypeEnum componentType, String parentId, String userId) {
- Component component = null;
User modifier = userBusinessLogic.getUser(userId, false);
LifecycleChangeInfoWithAction changeInfo = new LifecycleChangeInfoWithAction("External API checkout",
LifecycleChanceActionEnum.UPDATE_FROM_EXTERNAL_API);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 0b60a3671d..b878adf639 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -634,20 +634,6 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
return Either.left(deleteMarkedElements.left().value());
}
- public Either<List<ArtifactDefinition>, StorageOperationStatus> getComponentArtifactsForDelete(String parentId, NodeTypeEnum parentType) {
- List<ArtifactDefinition> artifacts = new ArrayList<>();
- Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifactsResponse = artifactToscaOperation.getArtifacts(parentId);
- if (artifactsResponse.isRight()) {
- if (artifactsResponse.right().value() != StorageOperationStatus.NOT_FOUND) {
- log.debug("failed to retrieve artifacts for {} {}", parentType, parentId);
- return Either.right(artifactsResponse.right().value());
- }
- } else {
- artifacts.addAll(artifactsResponse.left().value().values());
- }
- return Either.left(artifacts);
- }
-
/**
* @param componentId
* @param user
@@ -1019,10 +1005,6 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
return Either.left(component);
}
- public CatalogOperation getCatalogOperations() {
- return catalogOperations;
- }
-
@Autowired
public void setCatalogOperations(CatalogOperation catalogOperations) {
this.catalogOperations = catalogOperations;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index ddbc5dc041..7cb9858484 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -1888,43 +1888,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<ComponentInstanceProperty, ResponseFormat> createOrUpdateAttributeValue(ComponentTypeEnum componentTypeEnum, String componentId,
- String resourceInstanceId,
- ComponentInstanceProperty attribute, String userId) {
- Either<ComponentInstanceProperty, ResponseFormat> result = null;
- Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- validateUserExists(userId);
- if (errorWrapper.isEmpty()) {
- validateComponentTypeEnum(componentTypeEnum, "CreateOrUpdateAttributeValue", errorWrapper);
- }
- if (errorWrapper.isEmpty()) {
- validateCanWorkOnComponent(componentId, componentTypeEnum, userId, errorWrapper);
- }
- if (errorWrapper.isEmpty()) {
- validateComponentLock(componentId, componentTypeEnum, errorWrapper);
- }
- try {
- if (errorWrapper.isEmpty()) {
- final boolean isCreate = Objects.isNull(attribute.getValueUniqueUid());
- if (isCreate) {
- result = createAttributeValue(attribute, resourceInstanceId);
- } else {
- result = updateAttributeValue(attribute, resourceInstanceId);
- }
- } else {
- result = Either.right(errorWrapper.getInnerElement());
- }
- return result;
- } finally {
- if (result == null || result.isRight()) {
- janusGraphDao.rollback();
- } else {
- janusGraphDao.commit();
- }
- // unlock resource
- graphLockOperation.unlockComponent(componentId, componentTypeEnum.getNodeType());
- }
- }
public Either<List<ComponentInstanceProperty>, ResponseFormat> createOrUpdatePropertiesValues(ComponentTypeEnum componentTypeEnum,
String componentId, String resourceInstanceId,
@@ -2110,19 +2073,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
}
- private void setJsonObjectForSubProperty(final JSONObject jObject, final List<String> path, String value) {
- if (path.size() == 1) {
- Object valueAsObject = new Yaml().loadAs(value, Object.class);
- jObject.put(path.get(0), valueAsObject);
- } else {
- if (!jObject.has(path.get(0))) {
- jObject.put(path.get(0), new JSONObject());
- }
- final JSONObject jsonObject = jObject.getJSONObject(path.get(0));
- setJsonObjectForSubProperty(jsonObject, path.subList(1, path.size()), value);
- }
- }
-
public Either<List<ComponentInstanceAttribute>, ResponseFormat> createOrUpdateAttributeValues(final ComponentTypeEnum componentTypeEnum,
final String componentId,
final String resourceInstanceId,
@@ -2519,42 +2469,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
return Either.left(newValue);
}
- private <T extends PropertyDefinition> void validateToscaGetFunction(T property, Component parentComponent) {
- final ToscaGetFunctionDataDefinition toscaGetFunction = (ToscaGetFunctionDataDefinition) property.getToscaFunction();
- validateGetToscaFunctionAttributes(toscaGetFunction);
- validateGetPropertySource(toscaGetFunction.getFunctionType(), toscaGetFunction.getPropertySource());
- if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_INPUT) {
- validateGetFunction(property, parentComponent.getInputs(), parentComponent.getModel());
- return;
- }
- if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_PROPERTY) {
- if (toscaGetFunction.getPropertySource() == PropertySource.SELF) {
- validateGetFunction(property, parentComponent.getProperties(), parentComponent.getModel());
- } else if (toscaGetFunction.getPropertySource() == PropertySource.INSTANCE) {
- final ComponentInstance componentInstance =
- parentComponent.getComponentInstanceById(toscaGetFunction.getSourceUniqueId())
- .orElseThrow(ToscaGetFunctionExceptionSupplier.instanceNotFound(toscaGetFunction.getSourceName()));
- validateGetFunction(property, componentInstance.getProperties(), parentComponent.getModel());
- }
-
- return;
- }
- if (toscaGetFunction.getFunctionType() == ToscaGetFunctionType.GET_ATTRIBUTE) {
- if (toscaGetFunction.getPropertySource() == PropertySource.SELF) {
- validateGetFunction(property, parentComponent.getAttributes(), parentComponent.getModel());
- } else if (toscaGetFunction.getPropertySource() == PropertySource.INSTANCE) {
- final ComponentInstance componentInstance =
- parentComponent.getComponentInstanceById(toscaGetFunction.getSourceUniqueId())
- .orElseThrow(ToscaGetFunctionExceptionSupplier.instanceNotFound(toscaGetFunction.getSourceName()));
- validateGetFunction(property, componentInstance.getAttributes(), parentComponent.getModel());
- }
-
- return;
- }
-
- throw ToscaGetFunctionExceptionSupplier.functionNotSupported(toscaGetFunction.getFunctionType()).get();
- }
-
private <T extends PropertyDefinition> void validateGetFunction(final T property,
final List<? extends ToscaPropertyData> parentProperties,
final String model) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java
index 93fb171539..f895a20c0c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ConsumerBusinessLogic.java
@@ -248,10 +248,6 @@ public class ConsumerBusinessLogic extends BaseBusinessLogic {
return Either.left(consumer);
}
- public Either<ConsumerDefinition, ResponseFormat> getConsumer(String consumerId) {
- return getConsumer(consumerId, null);
- }
-
public Either<ConsumerDefinition, ResponseFormat> deleteConsumer(String consumerId, User user) {
ConsumerDefinition tmpConsumer = new ConsumerDefinition();
tmpConsumer.setConsumerName(consumerId);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
index 363b8d64df..4156e3da35 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
@@ -265,9 +265,6 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
return elementOperation.getAllResourceCategories();
}
- public Either<List<CategoryDefinition>, ActionStatus> getAllServiceCategories() {
- return elementOperation.getAllServiceCategories();
- }
public Either<CategoryDefinition, ResponseFormat> createCategory(CategoryDefinition category, String componentTypeParamName, String userId) {
AuditingActionEnum auditingAction = AuditingActionEnum.ADD_CATEGORY;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ExternalRefsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ExternalRefsBusinessLogic.java
index acd19e4bee..f1d4825b08 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ExternalRefsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ExternalRefsBusinessLogic.java
@@ -42,7 +42,6 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
@org.springframework.stereotype.Component
public class ExternalRefsBusinessLogic {
- private static final Logger log = Logger.getLogger(ExternalRefsBusinessLogic.class);
private final ExternalReferencesOperation externalReferencesOperation;
private final ToscaOperationFacade toscaOperationFacade;
private final AccessValidations accessValidations;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckInformer.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckInformer.java
deleted file mode 100644
index ccc7feb4da..0000000000
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/HealthCheckInformer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.be.components.impl;
-
-import org.openecomp.sdc.common.api.HealthCheckInfo;
-
-public interface HealthCheckInformer {
-
- HealthCheckInfo getHealthCheckInfo();
-}
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 58756642c1..fe779779d0 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
@@ -331,10 +331,6 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
return servletUtils;
}
- public Gson getGson() {
- return getServletUtils().getGson();
- }
-
@Override
public ComponentsUtils getComponentsUtils() {
return getServletUtils().getComponentsUtils();
@@ -837,30 +833,6 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
}
}
- void validateComponentInstanceBusinessLogic(HttpServletRequest request, String containerComponentType,
- Wrapper<ComponentInstanceBusinessLogic> blWrapper, Wrapper<ResponseFormat> errorWrapper) {
- ServletContext context = request.getSession().getServletContext();
- ComponentInstanceBusinessLogic componentInstanceLogic = getComponentInstanceBL(context);
- if (componentInstanceLogic == null) {
- log.debug("Unsupported component type {}", containerComponentType);
- errorWrapper.setInnerElement(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR, containerComponentType));
- } else {
- blWrapper.setInnerElement(componentInstanceLogic);
- }
- }
-
- <T> Response buildResponseFromElement(Wrapper<ResponseFormat> errorWrapper, Wrapper<T> attributeWrapper) throws IOException {
- Response response;
- if (errorWrapper.isEmpty()) {
- ObjectMapper mapper = new ObjectMapper();
- String result = mapper.writeValueAsString(attributeWrapper.getInnerElement());
- response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), result);
- } else {
- response = buildErrorResponse(errorWrapper.getInnerElement());
- }
- return response;
- }
-
protected void validateXECOMPInstanceIDHeader(String instanceIdHeader, Wrapper<ResponseFormat> responseWrapper) {
ResponseFormat responseFormat;
if (StringUtils.isEmpty(instanceIdHeader)) {
@@ -890,17 +862,6 @@ public abstract class AbstractValidationsServlet extends BeGenericServlet {
}
}
- public <T> Either<List<T>, ResponseFormat> parseListOfObjects(String json, Type type) {
- try {
- List<T> listOfObjects = gson.fromJson(json, type);
- return Either.left(listOfObjects);
- } catch (Exception e) {
- log.debug("Failed to parse json to {} object", type.getClass().getName(), e);
- ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
- return Either.right(responseFormat);
- }
- }
-
protected void validateNotEmptyBody(String data) {
if (StringUtils.isEmpty(data)) {
throw new ByActionStatusComponentException(ActionStatus.MISSING_BODY);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java
index bc1893b770..707f89800e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/RepresentationUtils.java
@@ -195,10 +195,6 @@ public class RepresentationUtils {
.writeValueAsString(elementToRepresent);
}
- public static class ResourceRep {
-
- }
-
@JsonFilter(REMOVE_IS_EMPTY_FROM_COLLECTIONS_FILTER)
private static class IsEmptyFilterMixIn {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
index 143fb7b34b..847947badd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
@@ -97,16 +97,6 @@ public class AttributeConverter {
return toscaAttribute;
}
- private ToscaSchemaDefinition convert(final EntrySchema entrySchema) {
- if (entrySchema == null) {
- return null;
- }
- final ToscaSchemaDefinition toscaSchemaDefinition = new ToscaSchemaDefinition();
- toscaSchemaDefinition.setType(entrySchema.getType());
- toscaSchemaDefinition.setDescription(entrySchema.getDescription());
- return toscaSchemaDefinition;
- }
-
private Object convertToToscaObject(final AttributeDefinition attributeDefinition,
String value,
final boolean preserveEmptyValue) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 163b67a44f..09c93ed408 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -277,44 +277,6 @@ public class ToscaExportHandler {
return Either.left(toscaRepresentation);
}
- public Either<ToscaRepresentation, ToscaError> exportComponentInterface(final Component component, final boolean isAssociatedComponent,
- final boolean isSkipImports) {
- final List<Map<String, Map<String, String>>> imports = new ArrayList<>(getDefaultToscaImports(component.getModel(), isSkipImports));
- if (CollectionUtils.isEmpty(imports)) {
- log.debug(FAILED_TO_GET_DEFAULT_IMPORTS_CONFIGURATION);
- return Either.right(ToscaError.GENERAL_ERROR);
- }
- List<Triple<String, String, Component>> dependencies = new ArrayList<>();
- if (component.getDerivedFromGenericType() != null && !component.getDerivedFromGenericType()
- .startsWith("org.openecomp.resource.abstract.nodes.")) {
- final Either<Component, StorageOperationStatus> baseType = toscaOperationFacade
- .getByToscaResourceNameAndVersion(component.getDerivedFromGenericType(), component.getDerivedFromGenericVersion(),
- component.getModel());
- if (baseType.isLeft() && baseType.left().value() != null) {
- addDependencies(imports, dependencies, baseType.left().value(), isSkipImports);
- } else {
- log.debug("Failed to fetch derived from type {}", component.getDerivedFromGenericType());
- }
- }
-
- String toscaVersion = null;
- if (component instanceof Resource) {
- toscaVersion = ((Resource) component).getToscaVersion();
- }
- ToscaTemplate toscaTemplate = new ToscaTemplate(toscaVersion != null ? toscaVersion : TOSCA_VERSION);
- toscaTemplate.setImports(imports);
- final Map<String, ToscaNodeType> nodeTypes = new HashMap<>();
- final Either<ToscaTemplate, ToscaError> toscaTemplateRes = convertInterfaceNodeType(new HashMap<>(), component, toscaTemplate, nodeTypes,
- isAssociatedComponent);
- if (toscaTemplateRes.isRight()) {
- return Either.right(toscaTemplateRes.right().value());
- }
- toscaTemplate = toscaTemplateRes.left().value();
- toscaTemplate.setDependencies(dependencies);
- ToscaRepresentation toscaRepresentation = this.createToscaRepresentation(toscaTemplate);
- return Either.left(toscaRepresentation);
- }
-
private ToscaRepresentation createToscaRepresentation(ToscaTemplate toscaTemplate) {
CustomRepresenter representer = new CustomRepresenter();
DumperOptions options = new DumperOptions();
@@ -342,15 +304,6 @@ public class ToscaExportHandler {
return Either.left(fillImports.left().value().left);
}
- public Either<ToscaTemplate, ToscaError> getDependencies(Component component, boolean isSkipImports) {
- ToscaTemplate toscaTemplate = new ToscaTemplate(null);
- Either<ImmutablePair<ToscaTemplate, Map<String, Component>>, ToscaError> fillImports = fillImports(component, toscaTemplate, isSkipImports);
- if (fillImports.isRight()) {
- return Either.right(fillImports.right().value());
- }
- return Either.left(fillImports.left().value().left);
- }
-
public Either<ToscaTemplate, ToscaError> convertToToscaTemplate(final Component component, final boolean isSkipImports) {
final List<Map<String, Map<String, String>>> defaultToscaImportConfig = getDefaultToscaImports(component.getModel(), isSkipImports);
if (CollectionUtils.isEmpty(defaultToscaImportConfig)) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAnnotation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAnnotation.java
index 5aee23ddbb..9a3253d6d8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAnnotation.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAnnotation.java
@@ -21,41 +21,15 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.HashMap;
import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+@Getter
+@Setter
public class ToscaAnnotation {
private String type;
private Map<String, Object> properties;
private String description;
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public void addProperty(String name, Object property) {
- if (properties == null) {
- properties = new HashMap<>();
- }
- properties.put(name, property);
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaFilter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaFilter.java
deleted file mode 100644
index 3ff29e8df9..0000000000
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaFilter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.sdc.be.tosca.model;
-
-import lombok.Data;
-
-@Data
-public class ToscaFilter {
-
- private String name;
- private String constraint;
- private Object value; //ToscaFunction or String or float, etc I guess
-}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplate.java
index c7763e6dc8..6e05cc08a5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplate.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaGroupTemplate.java
@@ -21,7 +21,11 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+@Data
+@AllArgsConstructor
public class ToscaGroupTemplate {
private String type;
@@ -30,58 +34,9 @@ public class ToscaGroupTemplate {
private Map<String, Object> properties;
private Map<String, ToscaTemplateCapability> capabilities;
- public ToscaGroupTemplate(String type, List<String> members, IToscaMetadata metadata, Map<String, Object> properties,
- Map<String, ToscaTemplateCapability> capabilities) {
- this.type = type;
- this.members = members;
- this.metadata = metadata;
- this.properties = properties;
- this.capabilities = capabilities;
- }
-
public ToscaGroupTemplate(String type, IToscaMetadata metadata, Map<String, Object> properties) {
this.type = type;
this.metadata = metadata;
this.properties = properties;
}
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public List<String> getMembers() {
- return members;
- }
-
- public void setMembers(List<String> members) {
- this.members = members;
- }
-
- public IToscaMetadata getMetadata() {
- return metadata;
- }
-
- public void setMetadata(IToscaMetadata metadata) {
- this.metadata = metadata;
- }
-
- public Map<String, Object> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, Object> properties) {
- this.properties = properties;
- }
-
- public Map<String, ToscaTemplateCapability> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, ToscaTemplateCapability> capabilities) {
- this.capabilities = capabilities;
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInput.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInput.java
index a06f67c005..694430fa74 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInput.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaInput.java
@@ -17,32 +17,28 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.tosca.model;
import java.util.HashMap;
import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+@Getter
+@Setter
public class ToscaInput extends ToscaProperty {
private Map<String, ToscaAnnotation> annotations;
- //copy constructor
public ToscaInput(ToscaProperty toscaProperty) {
super(toscaProperty);
}
- public Map<String, ToscaAnnotation> getAnnotations() {
- return annotations;
- }
-
- public void setAnnotations(Map<String, ToscaAnnotation> annotations) {
- this.annotations = annotations;
- }
-
- public void addAnnotation(String name, ToscaAnnotation annotaion) {
+ public void addAnnotation(String name, ToscaAnnotation annotation) {
if (annotations == null) {
annotations = new HashMap<>();
}
- annotations.put(name, annotaion);
+ annotations.put(name, annotation);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
index eb34732db9..fe0af5f1a1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
@@ -51,10 +51,4 @@ public class ToscaNodeTemplate {
this.directives = CollectionUtils.isEmpty(directives) ? null : directives;
}
- public void addInterface(String interfaceName, Object interfaceDataDefinition) {
- if (MapUtils.isEmpty(this.interfaces)) {
- this.interfaces = new HashMap<>();
- }
- this.interfaces.put(interfaceName, interfaceDataDefinition);
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/types/ServiceConsumptionData.java b/catalog-be/src/main/java/org/openecomp/sdc/be/types/ServiceConsumptionData.java
index 51b36538e5..f7022e3929 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/types/ServiceConsumptionData.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/types/ServiceConsumptionData.java
@@ -15,6 +15,11 @@
*/
package org.openecomp.sdc.be.types;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
public class ServiceConsumptionData {
private String inputId;
@@ -22,35 +27,4 @@ public class ServiceConsumptionData {
private String value;
private String type;
- public String getInputId() {
- return inputId;
- }
-
- public void setInputId(String inputId) {
- this.inputId = inputId;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/Role.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/Role.java
index 4274532e93..7308a6caa5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/Role.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/user/Role.java
@@ -26,12 +26,4 @@ package org.openecomp.sdc.be.user;
public enum Role {
ADMIN, TESTER, DESIGNER, PRODUCT_MANAGER, PRODUCT_STRATEGIST;
- public static Role getByNameIgnoreCase(String name) {
- for (Role inst : Role.values()) {
- if (inst.name().equalsIgnoreCase(name)) {
- return inst;
- }
- }
- return null;
- }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserAdminAction.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserAdminAction.java
deleted file mode 100644
index 4aa852cf7e..0000000000
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserAdminAction.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.sdc.be.user;
-
-public enum UserAdminAction {
- ADD_USER, UPDATE_USER, DELET_USER
-}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/config/HttpClientFactory.java b/catalog-be/src/main/java/org/openecomp/sdc/config/HttpClientFactory.java
index 176f05a25c..cadab4e8fd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/config/HttpClientFactory.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/config/HttpClientFactory.java
@@ -45,7 +45,6 @@ public class HttpClientFactory {
private static final int DEFAULT_MAX_CONNECTION_PER_ROUTE = 5;
private static final int VALIDATE_CONNECTION_AFTER_INACTIVITY_MS = 10000;
private static final int CONNECT_TIMEOUT_MS = 15000;
- private static final Logger log = Logger.getLogger(HttpClientFactory.class);
private static final UserTokenHandler userTokenHandler = context -> null;
private HttpClientConnectionManager createConnectionManager() {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
index b749ef68fd..2fc1e82827 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
@@ -20,8 +20,6 @@
package org.openecomp.sdc.be.tosca;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -90,7 +88,6 @@ import org.openecomp.sdc.be.tosca.ComponentCache.CacheEntry;
import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
-import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
@@ -99,809 +96,797 @@ import org.openecomp.sdc.exception.ResponseFormat;
class CsarUtilsTest extends BaseConfDependent {
- @InjectMocks
- private CsarUtils testSubject;
-
+ private final List<String> nodesFromPackage = Arrays.asList("tosca.nodes.Root", "tosca.nodes.Container.Application");
+ private final byte[] contentData;
@InjectMocks
- private CommonCsarGenerator commonCsarGenerator;
-
- @Mock
- private ArtifactCassandraDao artifactCassandraDao;
-
- @Mock
- private ComponentsUtils componentsUtils;
-
- @Mock
- private ToscaExportHandler toscaExportUtils;
+ private CsarUtils testSubject;
+ @InjectMocks
+ private CommonCsarGenerator commonCsarGenerator;
+ @Mock
+ private ArtifactCassandraDao artifactCassandraDao;
+ @Mock
+ private ComponentsUtils componentsUtils;
+ @Mock
+ private ToscaExportHandler toscaExportUtils;
+ @Mock
+ private SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao;
+ @Mock
+ private ToscaOperationFacade toscaOperationFacade;
+ @Mock
+ private ArtifactsBusinessLogic artifactsBusinessLogic;
- @Mock
- private SdcSchemaFilesCassandraDao sdcSchemaFilesCassandraDao;
+ public CsarUtilsTest() throws IOException {
+ contentData = getFileResource("yamlValidation/resource-serviceTemplate.yml");
+ }
- @Mock
- private ToscaOperationFacade toscaOperationFacade;
+ @BeforeAll
+ public static void setupBeforeClass() {
+ componentName = "catalog-be";
+ confPath = "src/test/resources/config";
+ setUp();
+ }
- @Mock
- private ArtifactsBusinessLogic artifactsBusinessLogic;
+ private static void initConfigurationManager() {
+ final String confPath = new File(Objects
+ .requireNonNull(
+ CsarUtilsTest.class.getClassLoader().getResource("config/catalog-be/configuration.yaml"))
+ .getFile()).getParent();
+ final ConfigurationSource confSource =
+ new FSConfigurationSource(ExternalConfiguration.getChangeListener(), confPath);
+ new ConfigurationManager(confSource);
+ }
- private final List<String> nodesFromPackage = Arrays.asList("tosca.nodes.Root", "tosca.nodes.Container.Application");
+ @BeforeEach
+ public void setUpMock() {
+ ExternalConfiguration.setAppName("catalog-be");
+ MockitoAnnotations.openMocks(this);
+ initConfigurationManager();
+ }
- private final byte[] contentData;
+ @Test
+ void testCreateCsar() throws IOException {
+ Component component = new Resource();
+ Map<String, ArtifactDefinition> artifactDefinitionHashMap = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifactDefinitionHashMap.put("assettoscatemplate", artifact);
- public CsarUtilsTest() throws IOException {
- contentData = getFileResource("yamlValidation/resource-serviceTemplate.yml");
- }
-
- @BeforeAll
- public static void setupBeforeClass() {
- componentName = "catalog-be";
- confPath = "src/test/resources/config";
- setUp();
- }
-
- @BeforeEach
- public void setUpMock() {
- ExternalConfiguration.setAppName("catalog-be");
- MockitoAnnotations.openMocks(this);
- initConfigurationManager();
- }
-
- private static void initConfigurationManager() {
- final String confPath = new File(Objects
- .requireNonNull(
- CsarUtilsTest.class.getClassLoader().getResource("config/catalog-be/configuration.yaml"))
- .getFile()).getParent();
- final ConfigurationSource confSource =
- new FSConfigurationSource(ExternalConfiguration.getChangeListener(), confPath);
- new ConfigurationManager(confSource);
- }
-
- private NonMetaArtifactInfo createNonMetaArtifactInfoTestSubject() {
- return new CsarUtils.NonMetaArtifactInfo("mock", "mock", ArtifactTypeEnum.AAI_SERVICE_MODEL.getType(),
- ArtifactGroupTypeEnum.DEPLOYMENT, new byte[0], "mock", true);
- }
-
- @Test
- void testCreateCsar() throws IOException {
- Component component = new Resource();
- Map<String, ArtifactDefinition> artifactDefinitionHashMap = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifactDefinitionHashMap.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(artifactDefinitionHashMap);
- component.setArtifacts(artifactDefinitionHashMap);
- component.setDeploymentArtifacts(artifactDefinitionHashMap);
+ component.setToscaArtifacts(artifactDefinitionHashMap);
+ component.setArtifacts(artifactDefinitionHashMap);
+ component.setDeploymentArtifacts(artifactDefinitionHashMap);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(out);
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class)))
- .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class)))
+ .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
- Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class)))
- .thenReturn(ActionStatus.GENERAL_ERROR);
+ Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class)))
+ .thenReturn(ActionStatus.GENERAL_ERROR);
assertNotNull(commonCsarGenerator.generateCsarZip(component, false, zip,
- false, true,
+ false, true,
"Definitions/", true, false).right());
- }
-
- @Test
- void testCreateCsarWithGenerateCsarZipResponseIsLeft() throws IOException {
- Component component = new Resource();
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
- DAOArtifactData artifactData = new DAOArtifactData();
- byte[] data = "value".getBytes();
- ByteBuffer bufferData = ByteBuffer.wrap(data);
- artifactData.setData(bufferData);
-
- ToscaTemplate toscaTemplate = new ToscaTemplate("version");
- List<Triple<String, String, Component>> dependencies = new ArrayList<>();
- toscaTemplate.setDependencies(dependencies);
-
- List<SdcSchemaFilesData> filesData = new ArrayList<>();
- SdcSchemaFilesData filedata = new SdcSchemaFilesData();
- filedata.setPayloadAsArray(data);
- filesData.add(filedata);
+ }
+
+ @Test
+ void testCreateCsarWithGenerateCsarZipResponseIsLeft() throws IOException {
+ Component component = new Resource();
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+ DAOArtifactData artifactData = new DAOArtifactData();
+ byte[] data = "value".getBytes();
+ ByteBuffer bufferData = ByteBuffer.wrap(data);
+ artifactData.setData(bufferData);
+
+ ToscaTemplate toscaTemplate = new ToscaTemplate("version");
+ List<Triple<String, String, Component>> dependencies = new ArrayList<>();
+ toscaTemplate.setDependencies(dependencies);
+
+ List<SdcSchemaFilesData> filesData = new ArrayList<>();
+ SdcSchemaFilesData filedata = new SdcSchemaFilesData();
+ filedata.setPayloadAsArray(data);
+ filesData.add(filedata);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(out);
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
- Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class)))
- .thenReturn(ActionStatus.GENERAL_ERROR);
+ Mockito.when(componentsUtils.convertFromStorageResponse(Mockito.any(StorageOperationStatus.class)))
+ .thenReturn(ActionStatus.GENERAL_ERROR);
- Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
- .thenReturn(Either.left(toscaTemplate));
+ Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
+ .thenReturn(Either.left(toscaTemplate));
- Mockito.when(
- sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
- .thenReturn(Either.left(filesData));
+ Mockito.when(
+ sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
+ .thenReturn(Either.left(filesData));
assertNotNull(commonCsarGenerator.generateCsarZip(component, false, zip,
false, true,
"Definitions/", true, false).right());
- }
+ }
- @Test
- void testPopulateZipWhenGetDependenciesIsRight() {
- Component component = new Service();
- boolean getFromCS = false;
+ @Test
+ void testPopulateZipWhenGetDependenciesIsRight() {
+ Component component = new Service();
+ boolean getFromCS = false;
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- toscaArtifacts.put("assettoscatemplate", artifact);
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ toscaArtifacts.put("assettoscatemplate", artifact);
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
- component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- DAOArtifactData artifactData = new DAOArtifactData();
- byte[] data = "value".getBytes();
- ByteBuffer bufferData = ByteBuffer.wrap(data);
- artifactData.setData(bufferData);
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ DAOArtifactData artifactData = new DAOArtifactData();
+ byte[] data = "value".getBytes();
+ ByteBuffer bufferData = ByteBuffer.wrap(data);
+ artifactData.setData(bufferData);
- ToscaRepresentation tosca = ToscaRepresentation.make("value".getBytes());
+ ToscaRepresentation tosca = ToscaRepresentation.make("value".getBytes());
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
- Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
+ Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
- Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
- .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
+ Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
+ .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, true, "Definitions/", true, false);
} catch (Exception e) {
e.printStackTrace();
}
- }
-
- @Test
- void testPopulateZipWhenExportComponentIsRight() {
- Component component = new Resource();
- boolean getFromCS = false;
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
- component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- DAOArtifactData artifactData = new DAOArtifactData();
- byte[] data = "value".getBytes();
- ByteBuffer bufferData = ByteBuffer.wrap(data);
- artifactData.setData(bufferData);
-
- Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class)))
- .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
+ }
+
+ @Test
+ void testPopulateZipWhenExportComponentIsRight() {
+ Component component = new Resource();
+ boolean getFromCS = false;
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ DAOArtifactData artifactData = new DAOArtifactData();
+ byte[] data = "value".getBytes();
+ ByteBuffer bufferData = ByteBuffer.wrap(data);
+ artifactData.setData(bufferData);
+
+ Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class)))
+ .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, true, "Definitions/", true, false);
} catch (Exception e) {
e.printStackTrace();
}
- }
-
- @Test
- void testPopulateZipWhenComponentIsServiceAndCollectComponentCsarDefinitionIsRight() {
- Component component = new Service();
- boolean getFromCS = false;
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- artifact.setDescription("description");
- artifact.setArtifactLabel("artifactLabel");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
- component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- component.setVersion("1.0");
- component.setLastUpdaterUserId("userId");
- component.setUniqueId("uid");
- DAOArtifactData artifactData = new DAOArtifactData();
- ByteBuffer bufferData = ByteBuffer.wrap(contentData);
- artifactData.setData(bufferData);
-
- List<SdcSchemaFilesData> filesData = new ArrayList<>();
- SdcSchemaFilesData filedata = new SdcSchemaFilesData();
- filedata.setPayloadAsArray(contentData);
- filesData.add(filedata);
-
- ToscaTemplate toscaTemplate = new ToscaTemplate("version");
- List<Triple<String, String, Component>> dependencies = new ArrayList<>();
- Triple<String, String, Component> triple = Triple.of("fileName", "cassandraId", component);
- dependencies.add(triple);
- toscaTemplate.setDependencies(dependencies);
-
- ToscaRepresentation tosca = ToscaRepresentation.make("value".getBytes());
-
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
-
- Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
-
- Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
- .thenReturn(Either.left(toscaTemplate));
-
- Mockito.when(
- sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
- .thenReturn(Either.left(filesData));
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
-
- Mockito.when(artifactsBusinessLogic.validateUserExists(Mockito.any(User.class))).thenReturn(new User());
-
-
- Mockito.when(artifactsBusinessLogic.validateAndHandleArtifact(Mockito.any(String.class),
- Mockito.any(ComponentTypeEnum.class), Mockito.any(ArtifactOperationInfo.class), Mockito.isNull(),
- Mockito.any(ArtifactDefinition.class), Mockito.any(String.class), Mockito.any(String.class),
- Mockito.isNull(), Mockito.isNull(), Mockito.any(User.class), Mockito.any(Component.class),
- Mockito.any(Boolean.class), Mockito.any(Boolean.class), Mockito.any(Boolean.class)))
- .thenReturn(Either.left(Mockito.any(ArtifactDefinition.class)));
-
- try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
- Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, true, "/Definitions", true, false);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- void testPopulateZipWhenGetEntryDataIsRight() {
- Component component = new Service();
- boolean getFromCS = true;
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- artifact.setDescription("description");
- artifact.setArtifactLabel("artifactLabel");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
- component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- component.setVersion("1.0");
- component.setLastUpdaterUserId("userId");
- component.setUniqueId("uid");
- DAOArtifactData artifactData = new DAOArtifactData();
- byte[] data = "value".getBytes();
- ByteBuffer bufferData = ByteBuffer.wrap(data);
- artifactData.setData(bufferData);
-
- ToscaTemplate toscaTemplate = new ToscaTemplate("version");
- List<Triple<String, String, Component>> dependencies = new ArrayList<>();
- Triple<String, String, Component> triple = Triple.of("fileName", "", component);
- dependencies.add(triple);
- toscaTemplate.setDependencies(dependencies);
-
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
-
- Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class)))
- .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
-
- Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
- .thenReturn(Either.left(toscaTemplate));
+ }
+
+ @Test
+ void testPopulateZipWhenComponentIsServiceAndCollectComponentCsarDefinitionIsRight() {
+ Component component = new Service();
+ boolean getFromCS = false;
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ artifact.setDescription("description");
+ artifact.setArtifactLabel("artifactLabel");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setVersion("1.0");
+ component.setLastUpdaterUserId("userId");
+ component.setUniqueId("uid");
+ DAOArtifactData artifactData = new DAOArtifactData();
+ ByteBuffer bufferData = ByteBuffer.wrap(contentData);
+ artifactData.setData(bufferData);
+
+ List<SdcSchemaFilesData> filesData = new ArrayList<>();
+ SdcSchemaFilesData filedata = new SdcSchemaFilesData();
+ filedata.setPayloadAsArray(contentData);
+ filesData.add(filedata);
+
+ ToscaTemplate toscaTemplate = new ToscaTemplate("version");
+ List<Triple<String, String, Component>> dependencies = new ArrayList<>();
+ Triple<String, String, Component> triple = Triple.of("fileName", "cassandraId", component);
+ dependencies.add(triple);
+ toscaTemplate.setDependencies(dependencies);
+
+ ToscaRepresentation tosca = ToscaRepresentation.make("value".getBytes());
+
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
+
+ Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
+
+ Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
+ .thenReturn(Either.left(toscaTemplate));
+
+ Mockito.when(
+ sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
+ .thenReturn(Either.left(filesData));
+
+ Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+
+ Mockito.when(artifactsBusinessLogic.validateUserExists(Mockito.any(User.class))).thenReturn(new User());
+
+
+ Mockito.when(artifactsBusinessLogic.validateAndHandleArtifact(Mockito.any(String.class),
+ Mockito.any(ComponentTypeEnum.class), Mockito.any(ArtifactOperationInfo.class), Mockito.isNull(),
+ Mockito.any(ArtifactDefinition.class), Mockito.any(String.class), Mockito.any(String.class),
+ Mockito.isNull(), Mockito.isNull(), Mockito.any(User.class), Mockito.any(Component.class),
+ Mockito.any(Boolean.class), Mockito.any(Boolean.class), Mockito.any(Boolean.class)))
+ .thenReturn(Either.left(Mockito.any(ArtifactDefinition.class)));
+
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
+ Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, true, "/Definitions", true, false);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ void testPopulateZipWhenGetEntryDataIsRight() {
+ Component component = new Service();
+ boolean getFromCS = true;
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ artifact.setDescription("description");
+ artifact.setArtifactLabel("artifactLabel");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setVersion("1.0");
+ component.setLastUpdaterUserId("userId");
+ component.setUniqueId("uid");
+ DAOArtifactData artifactData = new DAOArtifactData();
+ byte[] data = "value".getBytes();
+ ByteBuffer bufferData = ByteBuffer.wrap(data);
+ artifactData.setData(bufferData);
+
+ ToscaTemplate toscaTemplate = new ToscaTemplate("version");
+ List<Triple<String, String, Component>> dependencies = new ArrayList<>();
+ Triple<String, String, Component> triple = Triple.of("fileName", "", component);
+ dependencies.add(triple);
+ toscaTemplate.setDependencies(dependencies);
+
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
+
+ Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class)))
+ .thenReturn(Either.right(ToscaError.GENERAL_ERROR));
+
+ Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
+ .thenReturn(Either.left(toscaTemplate));
try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, true, "Definitions/", true, false);
} catch (Exception e) {
e.printStackTrace();
}
- }
-
- @Test
- void testPopulateZipWhenGetEntryDataOfInnerComponentIsRight() {
- Component component = new Service();
- boolean getFromCS = false;
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- artifact.setDescription("description");
- artifact.setArtifactLabel("artifactLabel");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
- component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- component.setVersion("1.0");
- component.setLastUpdaterUserId("userId");
- component.setUniqueId("uid");
- DAOArtifactData artifactData = new DAOArtifactData();
- ByteBuffer bufferData = ByteBuffer.wrap(contentData);
- artifactData.setData(bufferData);
-
- ToscaTemplate toscaTemplate = new ToscaTemplate("version");
- List<Triple<String, String, Component>> dependencies = new ArrayList<>();
- Triple<String, String, Component> triple = Triple.of("fileName", "", component);
- dependencies.add(triple);
- toscaTemplate.setDependencies(dependencies);
-
- ToscaRepresentation tosca = ToscaRepresentation.make(contentData);
-
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
-
- Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca),
- Either.left(tosca), Either.right(ToscaError.GENERAL_ERROR));
-
- Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
- .thenReturn(Either.left(toscaTemplate));
+ }
+
+ @Test
+ void testPopulateZipWhenGetEntryDataOfInnerComponentIsRight() {
+ Component component = new Service();
+ boolean getFromCS = false;
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ artifact.setDescription("description");
+ artifact.setArtifactLabel("artifactLabel");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setVersion("1.0");
+ component.setLastUpdaterUserId("userId");
+ component.setUniqueId("uid");
+ DAOArtifactData artifactData = new DAOArtifactData();
+ ByteBuffer bufferData = ByteBuffer.wrap(contentData);
+ artifactData.setData(bufferData);
+
+ ToscaTemplate toscaTemplate = new ToscaTemplate("version");
+ List<Triple<String, String, Component>> dependencies = new ArrayList<>();
+ Triple<String, String, Component> triple = Triple.of("fileName", "", component);
+ dependencies.add(triple);
+ toscaTemplate.setDependencies(dependencies);
+
+ ToscaRepresentation tosca = ToscaRepresentation.make(contentData);
+
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
+
+ Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca),
+ Either.left(tosca), Either.right(ToscaError.GENERAL_ERROR));
+
+ Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
+ .thenReturn(Either.left(toscaTemplate));
try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, true, "Definitions/", true, false);
} catch (Exception e) {
e.printStackTrace();
}
- }
-
- @Test
- void testPopulateZipWhenLatestSchemaFilesFromCassandraIsRight() {
- Component component = new Service();
- boolean getFromCS = false;
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- artifact.setDescription("description");
- artifact.setArtifactLabel("artifactLabel");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
- component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
- component.setVersion("1.0");
- component.setLastUpdaterUserId("userId");
- component.setUniqueId("uid");
- DAOArtifactData artifactData = new DAOArtifactData();
- ByteBuffer bufferData = ByteBuffer.wrap(contentData);
- artifactData.setData(bufferData);
-
- ToscaTemplate toscaTemplate = new ToscaTemplate("version");
- List<Triple<String, String, Component>> dependencies = new ArrayList<>();
- Triple<String, String, Component> triple = Triple.of("fileName", "", component);
- dependencies.add(triple);
- toscaTemplate.setDependencies(dependencies);
-
- ToscaRepresentation tosca = ToscaRepresentation.make(contentData);
-
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
-
- Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
-
- Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
- .thenReturn(Either.left(toscaTemplate));
-
- Mockito.when(
- sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
- .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
-
- try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
- Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, "toscaMetaFileName", true, "Definitions/", true, false);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Test
- void testAddInnerComponentsToCache() {
- ComponentCache componentCache = ComponentCache.overwritable(overwriteIfSameVersions());
- Component childComponent = new Resource();
- Component componentRI = new Service();
- List<ComponentInstance> componentInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setComponentUid("resourceUid");
- componentInstances.add(instance);
- childComponent.setComponentInstances(componentInstances);
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- artifact.setDescription("description");
- artifact.setArtifactLabel("artifactLabel");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- componentRI.setToscaArtifacts(toscaArtifacts);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
- .thenReturn(Either.left(componentRI));
-
- Deencapsulation.invoke(commonCsarGenerator, "addInnerComponentsToCache", componentCache, childComponent);
-
- io.vavr.collection.List<CacheEntry> expected = io.vavr.collection.List.of(entry("esId","artifactName",componentRI));
- assertEquals(expected, componentCache.all().toList());
- }
-
- @Test
- void testAddInnerComponentsToCacheWhenGetToscaElementIsRight() {
- Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>();
- Component childComponent = new Resource();
-
- List<ComponentInstance> componentInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setComponentUid("abc");
- componentInstances.add(instance);
- childComponent.setComponentInstances(componentInstances);
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
- artifact.setDescription("description");
- artifact.setArtifactLabel("artifactLabel");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- Component componentRI = new Service();
-
- componentRI.setToscaArtifacts(toscaArtifacts);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
- .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
-
-
- assertTrue(componentCache.isEmpty());
- }
-
- @Test
- void testWriteComponentInterface() throws IOException {
- String fileName = "name.hello";
- ToscaRepresentation tosca = ToscaRepresentation.make("value".getBytes());
-
- Mockito.when(toscaExportUtils.exportComponentInterface(Mockito.any(Component.class), Mockito.any(Boolean.class)))
- .thenReturn(Either.left(tosca));
-
-
- try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out)) {
- List<Triple<String, String, Component>> output = Deencapsulation.invoke(commonCsarGenerator, "writeComponentInterface", new Resource(),
+ }
+
+ @Test
+ void testPopulateZipWhenLatestSchemaFilesFromCassandraIsRight() {
+ Component component = new Service();
+ boolean getFromCS = false;
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ artifact.setDescription("description");
+ artifact.setArtifactLabel("artifactLabel");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+ component.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN);
+ component.setVersion("1.0");
+ component.setLastUpdaterUserId("userId");
+ component.setUniqueId("uid");
+ DAOArtifactData artifactData = new DAOArtifactData();
+ ByteBuffer bufferData = ByteBuffer.wrap(contentData);
+ artifactData.setData(bufferData);
+
+ ToscaTemplate toscaTemplate = new ToscaTemplate("version");
+ List<Triple<String, String, Component>> dependencies = new ArrayList<>();
+ Triple<String, String, Component> triple = Triple.of("fileName", "", component);
+ dependencies.add(triple);
+ toscaTemplate.setDependencies(dependencies);
+
+ ToscaRepresentation tosca = ToscaRepresentation.make(contentData);
+
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class))).thenReturn(Either.left(artifactData));
+
+ Mockito.when(toscaExportUtils.exportComponent(Mockito.any(Component.class))).thenReturn(Either.left(tosca));
+
+ Mockito.when(toscaExportUtils.getDependencies(Mockito.any(Component.class)))
+ .thenReturn(Either.left(toscaTemplate));
+
+ Mockito.when(
+ sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
+ .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
+
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out);) {
+ Deencapsulation.invoke(commonCsarGenerator, "generateCsarZip", component, getFromCS, zip, true, "toscaMetaFileName", true, "Definitions/",
+ true, false);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ void testAddInnerComponentsToCache() {
+ ComponentCache componentCache = ComponentCache.overwritable(overwriteIfSameVersions());
+ Component childComponent = new Resource();
+ Component componentRI = new Service();
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setComponentUid("resourceUid");
+ componentInstances.add(instance);
+ childComponent.setComponentInstances(componentInstances);
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ artifact.setDescription("description");
+ artifact.setArtifactLabel("artifactLabel");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ componentRI.setToscaArtifacts(toscaArtifacts);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
+ .thenReturn(Either.left(componentRI));
+
+ Deencapsulation.invoke(commonCsarGenerator, "addInnerComponentsToCache", componentCache, childComponent);
+
+ io.vavr.collection.List<CacheEntry> expected = io.vavr.collection.List.of(entry("esId", "artifactName", componentRI));
+ assertEquals(expected, componentCache.all().toList());
+ }
+
+ @Test
+ void testAddInnerComponentsToCacheWhenGetToscaElementIsRight() {
+ Map<String, ImmutableTriple<String, String, Component>> componentCache = new HashMap<>();
+ Component childComponent = new Resource();
+
+ List<ComponentInstance> componentInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setComponentUid("abc");
+ componentInstances.add(instance);
+ childComponent.setComponentInstances(componentInstances);
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ artifact.setArtifactGroupType(ArtifactGroupTypeEnum.DEPLOYMENT);
+ artifact.setDescription("description");
+ artifact.setArtifactLabel("artifactLabel");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ Component componentRI = new Service();
+
+ componentRI.setToscaArtifacts(toscaArtifacts);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class)))
+ .thenReturn(Either.right(StorageOperationStatus.BAD_REQUEST));
+
+
+ assertTrue(componentCache.isEmpty());
+ }
+
+ @Test
+ void testWriteComponentInterface() throws IOException {
+ String fileName = "name.hello";
+ ToscaRepresentation tosca = ToscaRepresentation.make("value".getBytes());
+
+ Mockito.when(toscaExportUtils.exportComponentInterface(Mockito.any(Component.class), Mockito.any(Boolean.class)))
+ .thenReturn(Either.left(tosca));
+
+
+ try (ByteArrayOutputStream out = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(out)) {
+ List<Triple<String, String, Component>> output = Deencapsulation.invoke(commonCsarGenerator, "writeComponentInterface", new Resource(),
zip, fileName, "Definitions/");
- assertNotNull(output);
- }
- }
-
- @Test
- void testGetEntryData() {
- String cassandraId = "id";
- Component childComponent = new Resource();
-
- Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class)))
- .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
-
- Either<byte[], ActionStatus> output = Deencapsulation.invoke(commonCsarGenerator, "getEntryData", cassandraId, childComponent);
-
- assertNotNull(output);
- assertTrue(output.isRight());
- }
-
- @Test
- void testGetLatestSchemaFilesFromCassandraWhenListOfSchemasIsEmpty() {
- List<SdcSchemaFilesData> filesData = new ArrayList<>();
-
- Mockito.when(
- sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
- .thenReturn(Either.left(filesData));
-
- Either<byte[], ResponseFormat> output = Deencapsulation.invoke(commonCsarGenerator, "getLatestSchemaFilesFromCassandra");
-
- assertNotNull(output);
- assertTrue(output.isRight());
- }
-
- @Test
- void testExtractVfcsArtifactsFromCsar() {
- String key = "Artifacts/org.openecomp.resource.some/Deployment/to/resource";
- byte[] data = "value".getBytes();
-
- Map<String, byte[]> csar = new HashMap<>();
- csar.put(key, data);
-
- Map<String, List<ArtifactDefinition>> output = CsarUtils.extractVfcsArtifactsFromCsar(csar);
-
- assertNotNull(output);
- assertTrue(output.containsKey("org.openecomp.resource.some"));
- assertEquals(1, output.get("org.openecomp.resource.some").size());
- }
-
- @Test
- void testAddExtractedVfcArtifactWhenArtifactsContainsExtractedArtifactKey() {
- ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>(
- "key", new ArtifactDefinition());
- Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>();
- artifacts.put("key", new ArrayList<>());
-
- Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts);
-
- assertEquals(1, artifacts.get("key").size());
- }
-
- @Test
- void testAddExtractedVfcArtifactWhenArtifactsDoesntContainsExtractedArtifactKey() {
- ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>(
- "key", new ArtifactDefinition());
- Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>();
- artifacts.put("key1", new ArrayList<>());
-
- Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts);
-
- assertEquals(0, artifacts.get("key1").size());
- assertEquals(1, artifacts.get("key").size());
- assertEquals(2, artifacts.size());
- }
-
- @Test
- void testExtractVfcArtifact() {
- String path = "path/to/informational/artificat";
- Map<String, byte[]> map = new HashMap<>();
- map.put(path, "value".getBytes());
- Entry<String, byte[]> entry = map.entrySet().iterator().next();
-
- Optional<ImmutablePair<String, ArtifactDefinition>> output =
- Deencapsulation.invoke(testSubject, "extractVfcArtifact", entry, new HashMap<>());
-
- if(output.isPresent()) {
- assertEquals("to", output.get().left);
- } else {
- fail("`output` is empty!");
- }
- }
-
- @Test
- void testDetectArtifactGroupTypeWithExceptionBeingCaught() {
- Either<ArtifactGroupTypeEnum, Boolean> output = Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", Map.class);
-
- assertNotNull(output);
- assertTrue(output.isRight());
- assertFalse(output.right().value());
- }
-
- @Test
- void testDetectArtifactGroupTypeWWhenCollectedWarningMessagesContainesKey() {
- Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
-
- collectedWarningMessages.put("Warning - unrecognized artifact group type {} was received.", new HashSet<>());
- Either<ArtifactGroupTypeEnum, Boolean> output = Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", collectedWarningMessages);
-
- assertNotNull(output);
- assertTrue(output.isRight());
- assertFalse(output.right().value());
- }
-
- @Test
- void testValidateNonMetaArtifactWithExceptionCaught() {
- CsarUtils.validateNonMetaArtifact("", new byte[0], new HashMap<>());
- }
-
- @Test
- void testCollectComponentCsarDefinitionWhenComponentIsServiceAndGetToscaElementIsLeft() {
- Component component = new Service();
- component.setUniqueId("uniqueId");
- List<ComponentInstance> resourceInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setComponentUid("resourceUid");
- instance.setOriginType(OriginTypeEnum.SERVICE);
- resourceInstances.add(instance);
- component.setComponentInstances(resourceInstances);
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
- Either.right(StorageOperationStatus.BAD_REQUEST));
-
- Either<Object, ResponseFormat> output = Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
-
- assertNotNull(output);
- assertTrue(output.isRight());
- }
-
- @Test
- void testCollectComponentTypeArtifactsWhenFetchedComponentHasComponentInstances() {
- Component component = new Service();
- Component fetchedComponent = new Resource();
- component.setUniqueId("uniqueId");
- List<ComponentInstance> resourceInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setComponentUid("resourceUid");
- instance.setOriginType(OriginTypeEnum.SERVICE);
- resourceInstances.add(instance);
- component.setComponentInstances(resourceInstances);
- fetchedComponent.setComponentInstances(resourceInstances);
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("YANG");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
-
- fetchedComponent.setToscaArtifacts(toscaArtifacts);
- fetchedComponent.setDeploymentArtifacts(toscaArtifacts);
- fetchedComponent.setArtifacts(toscaArtifacts);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
- Either.left(fetchedComponent), Either.right(StorageOperationStatus.BAD_REQUEST));
-
- Either<Object, ResponseFormat> output = Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
-
- assertNotNull(output);
- assertTrue(output.isRight());
- }
-
- @Test
- void testCollectComponentTypeArtifactsWhenFetchedComponentDontHaveComponentInstances() {
- Component component = new Service();
- Component fetchedComponent = new Resource();
- component.setUniqueId("uniqueId");
- List<ComponentInstance> resourceInstances = new ArrayList<>();
- ComponentInstance instance = new ComponentInstance();
- instance.setComponentUid("resourceUid");
- instance.setOriginType(OriginTypeEnum.SERVICE);
-
- Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
- ArtifactDefinition artifact = new ArtifactDefinition();
- artifact.setArtifactName("artifactName");
- artifact.setEsId("esId");
- artifact.setArtifactUUID("artifactUUID");
- artifact.setArtifactType("PLAN");
- toscaArtifacts.put("assettoscatemplate", artifact);
-
- instance.setDeploymentArtifacts(toscaArtifacts);
-
- resourceInstances.add(instance);
- component.setComponentInstances(resourceInstances);
-
- component.setToscaArtifacts(toscaArtifacts);
- component.setDeploymentArtifacts(toscaArtifacts);
- component.setArtifacts(toscaArtifacts);
-
- fetchedComponent.setToscaArtifacts(toscaArtifacts);
- fetchedComponent.setDeploymentArtifacts(toscaArtifacts);
- fetchedComponent.setArtifacts(toscaArtifacts);
-
- Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
- Either.left(fetchedComponent));
-
- Either<Object, ResponseFormat> output = Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
-
- assertNotNull(output);
- assertTrue(output.isLeft());
- }
-
- @Test
- void testValidateNonMetaArtifactHappyScenario() {
- String artifactPath = "Artifacts/Deployment/YANG_XML/myYang.xml";
- byte[] payloadData = "some payload data".getBytes();
- Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
- Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
- payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft());
- assertTrue(collectedWarningMessages.isEmpty());
-
- artifactPath = "Artifacts/Informational/OTHER/someArtifact.xml";
- eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft());
- assertTrue(collectedWarningMessages.isEmpty());
- }
-
- @Test
- void testValidateNonMetaArtifactScenarioWithWarnnings() {
- String artifactPath = "Artifacts/Deployment/Buga/myYang.xml";
- byte[] payloadData = "some payload data".getBytes();
- Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
- Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
- payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft());
-
- artifactPath = "Artifacts/Informational/Buga2/someArtifact.xml";
- eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft());
-
- assertEquals(1, collectedWarningMessages.size());
- assertEquals(2, collectedWarningMessages.values().iterator().next().size());
- }
-
- @Test
- void testValidateNonMetaArtifactUnhappyScenario() {
- String artifactPath = "Artifacts/Buga/YANG_XML/myYang.xml";
- byte[] payloadData = "some payload data".getBytes();
- Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
- Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
- payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isRight());
- assertFalse(collectedWarningMessages.isEmpty());
- }
-
- @Test
- void testAddSchemaFilesFromCassandraAddingDuplicatedEntry() throws IOException {
- final String rootPath = System.getProperty("user.dir");
- final Path path = Paths.get(rootPath + "/src/test/resources/sdc.zip");
- final byte[] data = Files.readAllBytes(path);
- try (final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ZipOutputStream zip = new ZipOutputStream(out)) {
- Deencapsulation.invoke(commonCsarGenerator, "addSchemaFilesFromCassandra", zip, data, nodesFromPackage, "Definitions/");
- final IOException actualException = assertThrows(IOException.class, () -> zip.putNextEntry(new ZipEntry("Definitions/nodes.yml")));
- assertEquals("duplicate entry: Definitions/nodes.yml", actualException.getMessage());
- }
- }
-
- @Test
- void testFindNonRootNodesFromPackage() {
- final Resource resource = new Resource();
- resource.setDerivedList(nodesFromPackage);
- final Component component = resource;
- final List<Triple<String, String, Component>> dependencies = new ArrayList<>();
- final Triple<String, String, Component> triple = Triple.of("fileName", "cassandraId", component);
- dependencies.add(triple);
- final List<String> expectedResult = Arrays.asList("tosca.nodes.Container.Application");
- final List<String> result = Deencapsulation.invoke(commonCsarGenerator,
- "findNonRootNodesFromPackage", dependencies);
- assertTrue(CollectionUtils.isNotEmpty(result));
- assertEquals(expectedResult, result);
- }
+ assertNotNull(output);
+ }
+ }
+
+ @Test
+ void testGetEntryData() {
+ String cassandraId = "id";
+ Component childComponent = new Resource();
+
+ Mockito.when(artifactCassandraDao.getArtifact(Mockito.any(String.class)))
+ .thenReturn(Either.right(CassandraOperationStatus.GENERAL_ERROR));
+
+ Either<byte[], ActionStatus> output = Deencapsulation.invoke(commonCsarGenerator, "getEntryData", cassandraId, childComponent);
+
+ assertNotNull(output);
+ assertTrue(output.isRight());
+ }
+
+ @Test
+ void testGetLatestSchemaFilesFromCassandraWhenListOfSchemasIsEmpty() {
+ List<SdcSchemaFilesData> filesData = new ArrayList<>();
+
+ Mockito.when(
+ sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(Mockito.any(String.class), Mockito.any(String.class)))
+ .thenReturn(Either.left(filesData));
+
+ Either<byte[], ResponseFormat> output = Deencapsulation.invoke(commonCsarGenerator, "getLatestSchemaFilesFromCassandra");
+
+ assertNotNull(output);
+ assertTrue(output.isRight());
+ }
+
+ @Test
+ void testExtractVfcsArtifactsFromCsar() {
+ String key = "Artifacts/org.openecomp.resource.some/Deployment/to/resource";
+ byte[] data = "value".getBytes();
+
+ Map<String, byte[]> csar = new HashMap<>();
+ csar.put(key, data);
+
+ Map<String, List<ArtifactDefinition>> output = CsarUtils.extractVfcsArtifactsFromCsar(csar);
+
+ assertNotNull(output);
+ assertTrue(output.containsKey("org.openecomp.resource.some"));
+ assertEquals(1, output.get("org.openecomp.resource.some").size());
+ }
+
+ @Test
+ void testAddExtractedVfcArtifactWhenArtifactsContainsExtractedArtifactKey() {
+ ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>(
+ "key", new ArtifactDefinition());
+ Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>();
+ artifacts.put("key", new ArrayList<>());
+
+ Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts);
+
+ assertEquals(1, artifacts.get("key").size());
+ }
+
+ @Test
+ void testAddExtractedVfcArtifactWhenArtifactsDoesntContainsExtractedArtifactKey() {
+ ImmutablePair<String, ArtifactDefinition> extractedVfcArtifact = new ImmutablePair<String, ArtifactDefinition>(
+ "key", new ArtifactDefinition());
+ Map<String, List<ArtifactDefinition>> artifacts = new HashMap<>();
+ artifacts.put("key1", new ArrayList<>());
+
+ Deencapsulation.invoke(testSubject, "addExtractedVfcArtifact", extractedVfcArtifact, artifacts);
+
+ assertEquals(0, artifacts.get("key1").size());
+ assertEquals(1, artifacts.get("key").size());
+ assertEquals(2, artifacts.size());
+ }
+
+ @Test
+ void testExtractVfcArtifact() {
+ String path = "path/to/informational/artificat";
+ Map<String, byte[]> map = new HashMap<>();
+ map.put(path, "value".getBytes());
+ Entry<String, byte[]> entry = map.entrySet().iterator().next();
+
+ Optional<ImmutablePair<String, ArtifactDefinition>> output =
+ Deencapsulation.invoke(testSubject, "extractVfcArtifact", entry, new HashMap<>());
+
+ if (output.isPresent()) {
+ assertEquals("to", output.get().left);
+ } else {
+ fail("`output` is empty!");
+ }
+ }
+
+ @Test
+ void testDetectArtifactGroupTypeWithExceptionBeingCaught() {
+ Either<ArtifactGroupTypeEnum, Boolean> output = Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", Map.class);
+
+ assertNotNull(output);
+ assertTrue(output.isRight());
+ assertFalse(output.right().value());
+ }
+
+ @Test
+ void testDetectArtifactGroupTypeWWhenCollectedWarningMessagesContainesKey() {
+ Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
+
+ collectedWarningMessages.put("Warning - unrecognized artifact group type {} was received.", new HashSet<>());
+ Either<ArtifactGroupTypeEnum, Boolean> output =
+ Deencapsulation.invoke(testSubject, "detectArtifactGroupType", "type", collectedWarningMessages);
+
+ assertNotNull(output);
+ assertTrue(output.isRight());
+ assertFalse(output.right().value());
+ }
+
+ @Test
+ void testValidateNonMetaArtifactWithExceptionCaught() {
+ CsarUtils.validateNonMetaArtifact("", new byte[0], new HashMap<>());
+ }
+
+ @Test
+ void testCollectComponentCsarDefinitionWhenComponentIsServiceAndGetToscaElementIsLeft() {
+ Component component = new Service();
+ component.setUniqueId("uniqueId");
+ List<ComponentInstance> resourceInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setComponentUid("resourceUid");
+ instance.setOriginType(OriginTypeEnum.SERVICE);
+ resourceInstances.add(instance);
+ component.setComponentInstances(resourceInstances);
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
+ Either.right(StorageOperationStatus.BAD_REQUEST));
+
+ Either<Object, ResponseFormat> output = Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
+
+ assertNotNull(output);
+ assertTrue(output.isRight());
+ }
+
+ @Test
+ void testCollectComponentTypeArtifactsWhenFetchedComponentHasComponentInstances() {
+ Component component = new Service();
+ Component fetchedComponent = new Resource();
+ component.setUniqueId("uniqueId");
+ List<ComponentInstance> resourceInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setComponentUid("resourceUid");
+ instance.setOriginType(OriginTypeEnum.SERVICE);
+ resourceInstances.add(instance);
+ component.setComponentInstances(resourceInstances);
+ fetchedComponent.setComponentInstances(resourceInstances);
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("YANG");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+
+ fetchedComponent.setToscaArtifacts(toscaArtifacts);
+ fetchedComponent.setDeploymentArtifacts(toscaArtifacts);
+ fetchedComponent.setArtifacts(toscaArtifacts);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
+ Either.left(fetchedComponent), Either.right(StorageOperationStatus.BAD_REQUEST));
+
+ Either<Object, ResponseFormat> output = Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
+
+ assertNotNull(output);
+ assertTrue(output.isRight());
+ }
+
+ @Test
+ void testCollectComponentTypeArtifactsWhenFetchedComponentDontHaveComponentInstances() {
+ Component component = new Service();
+ Component fetchedComponent = new Resource();
+ component.setUniqueId("uniqueId");
+ List<ComponentInstance> resourceInstances = new ArrayList<>();
+ ComponentInstance instance = new ComponentInstance();
+ instance.setComponentUid("resourceUid");
+ instance.setOriginType(OriginTypeEnum.SERVICE);
+
+ Map<String, ArtifactDefinition> toscaArtifacts = new HashMap<>();
+ ArtifactDefinition artifact = new ArtifactDefinition();
+ artifact.setArtifactName("artifactName");
+ artifact.setEsId("esId");
+ artifact.setArtifactUUID("artifactUUID");
+ artifact.setArtifactType("PLAN");
+ toscaArtifacts.put("assettoscatemplate", artifact);
+
+ instance.setDeploymentArtifacts(toscaArtifacts);
+
+ resourceInstances.add(instance);
+ component.setComponentInstances(resourceInstances);
+
+ component.setToscaArtifacts(toscaArtifacts);
+ component.setDeploymentArtifacts(toscaArtifacts);
+ component.setArtifacts(toscaArtifacts);
+
+ fetchedComponent.setToscaArtifacts(toscaArtifacts);
+ fetchedComponent.setDeploymentArtifacts(toscaArtifacts);
+ fetchedComponent.setArtifacts(toscaArtifacts);
+
+ Mockito.when(toscaOperationFacade.getToscaElement(Mockito.any(String.class))).thenReturn(Either.left(component),
+ Either.left(fetchedComponent));
+
+ Either<Object, ResponseFormat> output = Deencapsulation.invoke(testSubject, "collectComponentCsarDefinition", component);
+
+ assertNotNull(output);
+ assertTrue(output.isLeft());
+ }
+
+ @Test
+ void testValidateNonMetaArtifactHappyScenario() {
+ String artifactPath = "Artifacts/Deployment/YANG_XML/myYang.xml";
+ byte[] payloadData = "some payload data".getBytes();
+ Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
+ Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
+ payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isLeft());
+ assertTrue(collectedWarningMessages.isEmpty());
+
+ artifactPath = "Artifacts/Informational/OTHER/someArtifact.xml";
+ eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isLeft());
+ assertTrue(collectedWarningMessages.isEmpty());
+ }
+
+ @Test
+ void testValidateNonMetaArtifactScenarioWithWarnnings() {
+ String artifactPath = "Artifacts/Deployment/Buga/myYang.xml";
+ byte[] payloadData = "some payload data".getBytes();
+ Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
+ Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
+ payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isLeft());
+
+ artifactPath = "Artifacts/Informational/Buga2/someArtifact.xml";
+ eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isLeft());
+
+ assertEquals(1, collectedWarningMessages.size());
+ assertEquals(2, collectedWarningMessages.values().iterator().next().size());
+ }
+
+ @Test
+ void testValidateNonMetaArtifactUnhappyScenario() {
+ String artifactPath = "Artifacts/Buga/YANG_XML/myYang.xml";
+ byte[] payloadData = "some payload data".getBytes();
+ Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
+ Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
+ payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isRight());
+ assertFalse(collectedWarningMessages.isEmpty());
+ }
+
+ @Test
+ void testAddSchemaFilesFromCassandraAddingDuplicatedEntry() throws IOException {
+ final String rootPath = System.getProperty("user.dir");
+ final Path path = Paths.get(rootPath + "/src/test/resources/sdc.zip");
+ final byte[] data = Files.readAllBytes(path);
+ try (final ByteArrayOutputStream out = new ByteArrayOutputStream(); final ZipOutputStream zip = new ZipOutputStream(out)) {
+ Deencapsulation.invoke(commonCsarGenerator, "addSchemaFilesFromCassandra", zip, data, nodesFromPackage, "Definitions/");
+ final IOException actualException = assertThrows(IOException.class, () -> zip.putNextEntry(new ZipEntry("Definitions/nodes.yml")));
+ assertEquals("duplicate entry: Definitions/nodes.yml", actualException.getMessage());
+ }
+ }
+
+ @Test
+ void testFindNonRootNodesFromPackage() {
+ final Resource resource = new Resource();
+ resource.setDerivedList(nodesFromPackage);
+ final Component component = resource;
+ final List<Triple<String, String, Component>> dependencies = new ArrayList<>();
+ final Triple<String, String, Component> triple = Triple.of("fileName", "cassandraId", component);
+ dependencies.add(triple);
+ final List<String> expectedResult = Arrays.asList("tosca.nodes.Container.Application");
+ final List<String> result = Deencapsulation.invoke(commonCsarGenerator,
+ "findNonRootNodesFromPackage", dependencies);
+ assertTrue(CollectionUtils.isNotEmpty(result));
+ assertEquals(expectedResult, result);
+ }
private byte[] getFileResource(final String filePath) throws IOException {
try (final InputStream inputStream = getFileResourceAsInputStream(filePath)) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
index 0b3796261a..dc60cc81d5 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
@@ -69,6 +69,9 @@ import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyFilterConstraintDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.RequirementNodeFilterCapabilityDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ToscaArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ConstraintType;
@@ -104,6 +107,7 @@ import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
+import org.openecomp.sdc.be.model.operations.impl.ModelOperation;
import org.openecomp.sdc.be.tosca.exception.ToscaConversionException;
import org.openecomp.sdc.be.tosca.model.ToscaCapability;
import org.openecomp.sdc.be.tosca.model.ToscaNodeTemplate;
@@ -164,6 +168,9 @@ class ToscaExportHandlerTest extends BaseConfDependent {
private InterfacesOperationsConverter interfacesOperationsConverter;
@Mock
+ ModelOperation modelOperation;
+
+ @Mock
private PolicyExportParser policyExportParser;
@Mock
@@ -303,8 +310,15 @@ class ToscaExportHandlerTest extends BaseConfDependent {
void testExportDataType() {
DataTypeDefinition dataTypeDefinition = new DataTypeDefinition();
dataTypeDefinition.setUniqueId("uniqueId");
+ PropertyDefinition propData = new PropertyDataDefinitionBuilder()
+ .setName("property")
+ .setType("type")
+ .build();
+ List<PropertyDefinition> propDataList = Arrays.asList(propData);
+ dataTypeDefinition.setProperties(propDataList);
Either<ToscaRepresentation, ToscaError> result;
when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
+ when(propertyConvertor.convertProperty(any(), any(), any() )).thenReturn(new ToscaProperty());
result = testSubject.exportDataType(dataTypeDefinition);
assertNotNull(result);
}
@@ -476,6 +490,44 @@ class ToscaExportHandlerTest extends BaseConfDependent {
}
@Test
+ void testConvertToscaTemplateWithSubstitutionFilter() throws ToscaConversionException {
+ Component component = getNewResource();
+ ToscaTemplate toscaNode = new ToscaTemplate("");
+ component.setComponentInstances(new ArrayList<>());
+
+ SubstitutionFilterPropertyDataDefinition filterProp = new SubstitutionFilterPropertyDataDefinition();
+ ListDataDefinition<SubstitutionFilterPropertyDataDefinition> filterProperties = new ListDataDefinition<>();
+ filterProperties.add(filterProp);
+ SubstitutionFilterDataDefinition subFilter = new SubstitutionFilterDataDefinition();
+ subFilter.setProperties(filterProperties);
+ component.setSubstitutionFilter(subFilter);
+
+ Map<String, String[]> substitutionMappingMap = new HashMap<>();
+ String[] array = {"value1", "value2"};
+ substitutionMappingMap.put("key", array);
+
+ when(capabilityRequirementConverter.convertSubstitutionMappingCapabilities(anyMap(),
+ any(Component.class))).thenReturn(Either.left(substitutionMappingMap));
+
+ when(capabilityRequirementConverter.convertSubstitutionMappingRequirements(any(Component.class), anyMap()))
+ .thenReturn(Either.left(Collections.emptyMap()));
+
+ when(applicationDataTypeCache.getAll(null)).thenReturn(Either.left(new HashMap<>()));
+
+ when(inputConverter.convertInputs(anyList(), anyMap())).thenReturn(new HashMap<>());
+
+ when(groupExportParser.getGroups(component)).thenReturn(null);
+
+ final Map<String, ToscaProperty> map = new HashMap<>();
+ map.put("mock", new ToscaProperty());
+ doReturn(map).when(outputConverter).convert(any(), any());
+
+ // test component contains group
+ final var result = Deencapsulation.invoke(testSubject, "convertToscaTemplate", component, toscaNode, false);
+ assertNotNull(result);
+ }
+
+ @Test
void testConvertToscaTemplateWhenComponentIsService() throws Exception {
Component component = getNewService();
ToscaTemplate toscaNode = new ToscaTemplate("");
@@ -717,6 +769,16 @@ class ToscaExportHandlerTest extends BaseConfDependent {
instance.setUniqueId("uuid");
instance.setDescription("desc");
instance.setSourceModelUid("sourceModelUid");
+ instance.setMinOccurrences("0");
+ instance.setMaxOccurrences("10");
+ instance.setInstanceCount("{get_input:int}");
+
+ RequirementNodeFilterCapabilityDataDefinition filterCap = new RequirementNodeFilterCapabilityDataDefinition();
+ ListDataDefinition<RequirementNodeFilterCapabilityDataDefinition> instanceFilterCapabilities = new ListDataDefinition<>();
+ instanceFilterCapabilities.add(filterCap);
+ CINodeFilterDataDefinition nodeFilter = new CINodeFilterDataDefinition();
+ nodeFilter.setCapabilities(instanceFilterCapabilities);
+ instance.setNodeFilter(nodeFilter);
componentInstances.add(instance);
@@ -784,6 +846,18 @@ class ToscaExportHandlerTest extends BaseConfDependent {
}
@Test
+ void test () {
+ Component component = getNewService();
+ component.setModel("test");
+
+ when(modelOperation.findAllModelImports("test", true)).thenReturn(new ArrayList<>());
+
+ final Either<ToscaRepresentation, ToscaError> toscaRepresentationToscaErrorEither = testSubject.exportComponent(component, false);
+ assertNotNull(toscaRepresentationToscaErrorEither);
+ assertTrue(toscaRepresentationToscaErrorEither.isRight());
+ }
+
+ @Test
void testConvertWithBooleanNodeFilterWhenComponentIsService() {
final Component component = getNewService();
final List<ComponentInstance> componentInstances = new ArrayList<>();