summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java23
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java13
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java23
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java44
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java14
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java31
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java24
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java9
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java119
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java79
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java6
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java390
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java123
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java211
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java37
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java20
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java79
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java25
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java172
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java201
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java747
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java16
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java149
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java228
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java70
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java271
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java1
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java16
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java8
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java73
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java82
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java69
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java69
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java158
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java231
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java135
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java532
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java463
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java171
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java154
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java98
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java34
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java65
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java151
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java60
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java46
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java119
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java603
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java12
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java17
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java7
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java11
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java21
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java139
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java81
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java293
80 files changed, 2874 insertions, 4452 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
index a651b0bb12..869628e6f5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentDependencyModelManager.java
@@ -4,12 +4,17 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModel
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.List;
public interface ComponentDependencyModelManager {
- void createComponentDependencyModel(List<ComponentDependencyModelEntity> entities, String
- vspId, Version version, String user);
+ Collection<ComponentDependencyModelEntity> list(String vspId, Version version);
- Collection<ComponentDependencyModelEntity> list(String vspId, Version version, String user);
+ ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity entity,
+ String vspId, Version version);
+
+ void delete(String vspId, Version version, String dependencyId);
+
+ void update(ComponentDependencyModelEntity entity);
+
+ ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
index b895f5595f..413529882d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComponentManager.java
@@ -31,24 +31,23 @@ import java.util.Collection;
public interface ComponentManager {
- Collection<ComponentEntity> listComponents(String vspId, Version version, String user);
+ Collection<ComponentEntity> listComponents(String vspId, Version version);
- void deleteComponents(String vspId, Version version, String user);
+ void deleteComponents(String vspId, Version version);
- ComponentEntity createComponent(ComponentEntity componentEntity, String user);
+ ComponentEntity createComponent(ComponentEntity componentEntity);
- CompositionEntityValidationData updateComponent(ComponentEntity componentEntity, String user);
+ CompositionEntityValidationData updateComponent(ComponentEntity componentEntity);
CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId, String user);
+ String componentId);
- void deleteComponent(String vspId, Version version, String componentId, String user);
+ void deleteComponent(String vspId, Version version, String componentId);
- QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId,
- String user);
+ QuestionnaireResponse getQuestionnaire(String vspId, Version version, String componentId);
void updateQuestionnaire(String vspId, Version version, String componentId,
- String questionnaireData, String user);
+ String questionnaireData);
- void validateComponentExistence(String vspId, Version version, String componentId, String user);
+ void validateComponentExistence(String vspId, Version version, String componentId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
index 65bceb9864..7ddd4e20c8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeManager.java
@@ -12,23 +12,20 @@ import java.util.Collection;
public interface ComputeManager {
- Collection<ListComputeResponse> listCompute(String vspId, Version version, String
- componentId, String user);
+ Collection<ListComputeResponse> listComputes(String vspId, Version version, String componentId);
- ComputeEntity createCompute(ComputeEntity compute, String user);
+ ComputeEntity createCompute(ComputeEntity compute);
- CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version, String
- componentId, String computeFlavorId, String user);
+ CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
+ String componentId, String computeFlavorId);
- QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
- componentId, String computeFlavorId, String user);
+ QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String componentId,
+ String computeFlavorId);
- void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
- computeId, String
- questionnaireData, String user);
+ void updateComputeQuestionnaire(String vspId, Version version, String componentId,
+ String computeId, String questionnaireData);
- CompositionEntityValidationData updateCompute(ComputeEntity compute, String user);
+ CompositionEntityValidationData updateCompute(ComputeEntity compute);
- void deleteCompute(String vspId, Version version,String componentId, String computeFlavorId,
- String user);
+ void deleteCompute(String vspId, Version version, String componentId, String computeFlavorId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
index 51ba2f4d40..88d399aa5c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorManager.java
@@ -12,23 +12,19 @@ import java.util.Collection;
public interface DeploymentFlavorManager {
- DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity,
- String user);
+ DeploymentFlavorEntity createDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity);
- Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
- String user);
+ Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version);
CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId, Version version,
- String deploymentFlavorId,
- String user);
+ String deploymentFlavorId);
- CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId, Version
- version, String user);
+ CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
+ Version version);
- void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId, String
- user);
+ void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId);
- CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
- deploymentFlavorEntity, String user);
+ CompositionEntityValidationData updateDeploymentFlavor(
+ DeploymentFlavorEntity deploymentFlavorEntity);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
index 6bbfc0b69a..1a53221951 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ImageManager.java
@@ -10,24 +10,22 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
public interface ImageManager {
- ImageEntity createImage(ImageEntity imageEntity, String user);
+ ImageEntity createImage(ImageEntity imageEntity);
- CompositionEntityResponse<Image> getImageSchema(String vspId, String user);
+ CompositionEntityResponse<Image> getImageSchema(String vspId);
- Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
- String user);
+ Collection<ImageEntity> listImages(String vspId, Version version, String componentId);
CompositionEntityResponse<Image> getImage(String vspId, Version version, String componentId,
- String imageId, String user);
+ String imageId);
- QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
- componentId, String imageId, String user);
+ QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String componentId,
+ String imageId);
- void deleteImage(String vspId, Version version, String componentId, String imageId, String user);
+ void deleteImage(String vspId, Version version, String componentId, String imageId);
- CompositionEntityValidationData updateImage(ImageEntity imageEntity, String user);
+ CompositionEntityValidationData updateImage(ImageEntity imageEntity);
void updateImageQuestionnaire(String vspId, Version version, String componentId, String imageId,
- String
- questionnaireData, String user);
+ String questionnaireData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
index c9a5206383..621374ad3c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ManualVspToscaManager.java
@@ -6,7 +6,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface ManualVspToscaManager {
- public VspModelInfo gatherVspInformation(String vspId, Version version, String user);
+ VspModelInfo gatherVspInformation(String vspId, Version version);
- public ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
+ ToscaServiceModel generateToscaModel(VspModelInfo vspModelInfo);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
index f5e34a01be..36f06507dc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/MonitoringUploadsManager.java
@@ -28,11 +28,10 @@ import java.io.InputStream;
public interface MonitoringUploadsManager {
void delete(String vspId, Version version, String componentId,
- MonitoringUploadType monitoringUploadType, String user);
+ MonitoringUploadType monitoringUploadType);
void upload(InputStream object, String filename, String vspId, Version version,
- String componentId, MonitoringUploadType monitoringUploadType, String user);
+ String componentId, MonitoringUploadType monitoringUploadType);
- MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
- String user);
+ MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
index b647735188..fa740690b7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NetworkManager.java
@@ -29,14 +29,13 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
public interface NetworkManager {
- Collection<NetworkEntity> listNetworks(String vspId, Version version, String user);
+ Collection<NetworkEntity> listNetworks(String vspId, Version version);
- NetworkEntity createNetwork(NetworkEntity network, String user);
+ NetworkEntity createNetwork(NetworkEntity network);
- CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity, String user);
+ CompositionEntityValidationData updateNetwork(NetworkEntity networkEntity);
- CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId,
- String user);
+ CompositionEntityResponse<Network> getNetwork(String vspId, Version version, String networkId);
- void deleteNetwork(String vspId, Version version, String networkId, String user);
+ void deleteNetwork(String vspId, Version version, String networkId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
index 466583edfd..b055d97ef3 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/NicManager.java
@@ -31,20 +31,20 @@ import java.util.Collection;
public interface NicManager {
- Collection<NicEntity> listNics(String vspId, Version version, String componentId, String user);
+ Collection<NicEntity> listNics(String vspId, Version version, String componentId);
- NicEntity createNic(NicEntity nic, String user);
+ NicEntity createNic(NicEntity nic);
- CompositionEntityValidationData updateNic(NicEntity nicEntity, String user);
+ CompositionEntityValidationData updateNic(NicEntity nicEntity);
CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId, String user);
+ String nicId);
- void deleteNic(String vspId, Version version, String componentId, String nicId, String user);
+ void deleteNic(String vspId, Version version, String componentId, String nicId);
QuestionnaireResponse getNicQuestionnaire(String vspId, Version version, String componentId,
- String nicId, String user);
+ String nicId);
void updateNicQuestionnaire(String vspId, Version version, String componentId, String nicId,
- String questionnaireData, String user);
+ String questionnaireData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
index e2ef86149b..84318dbdd8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.vendorsoftwareproduct;
import org.apache.commons.lang3.tuple.Pair;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
@@ -33,14 +34,16 @@ import java.util.Optional;
public interface OrchestrationTemplateCandidateManager {
UploadFileResponse upload(String vspId, Version version, InputStream heatFileToUpload,
- String user, String filePrefix, String networkPackageName);
+ String fileSuffix, String networkPackageName);
- OrchestrationTemplateActionResponse process(String vspId, Version version, String user);
+ OrchestrationTemplateActionResponse process(String vspId, Version version);
- Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version, String user);
+ Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version);
- ValidationResponse updateFilesDataStructure(String vspId, Version version, String user,
+ ValidationResponse updateFilesDataStructure(String vspId, Version version,
FilesDataStructure fileDataStructure);
- Optional<Pair<String, byte[]>> get(String vspId, Version version, String user) throws IOException;
+ Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException;
+
+ OrchestrationTemplateCandidateData getInfo(String vspId, Version version);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
index afe88d2053..979eea0fb8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/ProcessManager.java
@@ -28,27 +28,22 @@ import java.io.InputStream;
import java.util.Collection;
public interface ProcessManager {
- Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId,
- String user);
+ Collection<ProcessEntity> listProcesses(String vspId, Version version, String componentId);
- void deleteProcesses(String vspId, Version version, String componentId, String user);
+ void deleteProcesses(String vspId, Version version, String componentId);
- ProcessEntity createProcess(ProcessEntity processEntity, String user);
+ ProcessEntity createProcess(ProcessEntity processEntity);
- ProcessEntity getProcess(String vspId, Version version, String componentId, String processId,
- String user);
+ ProcessEntity getProcess(String vspId, Version version, String componentId, String processId);
- void updateProcess(ProcessEntity processEntity, String user);
+ void updateProcess(ProcessEntity processEntity);
- void deleteProcess(String vspId, Version version, String componentId, String processId,
- String user);
+ void deleteProcess(String vspId, Version version, String componentId, String processId);
- File getProcessArtifact(String vspId, Version version, String componentId, String processId,
- String user);
+ File getProcessArtifact(String vspId, Version version, String componentId, String processId);
- void deleteProcessArtifact(String vspId, Version version, String componentId, String processId,
- String user);
+ void deleteProcessArtifact(String vspId, Version version, String componentId, String processId);
void uploadProcessArtifact(InputStream uploadFile, String fileName, String vspId,
- Version version, String componentId, String processId, String user);
+ Version version, String componentId, String processId);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
index 0adca1c695..2e38122856 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java
@@ -20,65 +20,55 @@
package org.openecomp.sdc.vendorsoftwareproduct;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
public interface VendorSoftwareProductManager {
- Version checkout(String vendorSoftwareProductId, String user);
+ VspDetails createVsp(VspDetails vspDetails);
- Version undoCheckout(String vendorSoftwareProductId, String user);
+ void updateVsp(VspDetails vspDetails);
- Version checkin(String vendorSoftwareProductId, String user);
+ VspDetails getVsp(String vspId, Version version);
- ValidationResponse submit(String vendorSoftwareProductId, String user) throws IOException;
+ void deleteVsp(String vspIdToDelete);
+ ValidationResponse validate(String vspId, Version version) throws IOException;
- List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user);
+ Map<String, List<ErrorMessage>> compile(String vspId, Version version);
- VspDetails createVsp(VspDetails vspDetails, String user);
- void updateVsp(VspDetails vspDetails, String user);
+ QuestionnaireResponse getVspQuestionnaire(String vspId, Version version);
- VspDetails getVsp(String vspId, Version version, String user);
+ void updateVspQuestionnaire(String vspId, Version version, String questionnaireData);
- Version callAutoHeal(String vspId, VersionInfo versionInfo,
- VspDetails vendorSoftwareProductInfo, String user) throws Exception;
- void deleteVsp(String vspIdToDelete, String user);
+ byte[] getOrchestrationTemplateFile(String vspId, Version version);
- QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user);
+ OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version);
- void updateVspQuestionnaire(String vspId, Version version, String questionnaireData, String user);
-
- byte[] getOrchestrationTemplateFile(String vspId, Version version, String user);
-
- PackageInfo createPackage(String vspId, Version version, String user) throws IOException;
+ PackageInfo createPackage(String vspId, Version version) throws IOException;
List<PackageInfo> listPackages(String category, String subCategory);
- File getTranslatedFile(String vspId, Version version, String user);
-
- void heal(String vspId, Version version, String user);
- File getInformationArtifact(String vspId, Version version, String user);
+ File getTranslatedFile(String vspId, Version version);
- String fetchValidationVsp(String user);
+ File getInformationArtifact(String vspId, Version version);
- Collection<ComputeEntity> getComputeByVsp(String vspId, Version version, String user);
- Version healAndAdvanceFinalVersion(String vspId, VspDetails vendorSoftwareProductInfo,
- String user) throws IOException;
+ Collection<ComputeEntity> getComputeByVsp(String vspId, Version version);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
index 78605c86fc..53ad74b772 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ComponentDependencyModelErrorBuilder.java
@@ -1,18 +1,14 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .CYCLIC_DEPENDENCY_IN_COMPONENTS;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .INVALID_COMPONENT_RELATION_TYPE;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .NO_SOURCE_COMPONENT;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .SAME_SOURCE_TARGET_COMPONENT;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CYCLIC_DEPENDENCY_IN_COMPONENTS;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPONENT_RELATION_TYPE;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NO_SOURCE_COMPONENT;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.SAME_SOURCE_TARGET_COMPONENT;
+
public class ComponentDependencyModelErrorBuilder {
private static final String CYCLIC_DEPENDENCY_COMPONENT_MSG = "Cyclic dependency exists between"
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
index b242b7169c..5d58f5c35b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/DuplicateComputeInComponentErrorBuilder.java
@@ -2,41 +2,16 @@ package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED;
public class DuplicateComputeInComponentErrorBuilder {
-
- private static final String DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG =
- "Invalid request, Compute with name %s already exists for component with ID %s.";
- private static final String COMPUTE_HEAT_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
- + "for VSP onboarded via HEAT.";
- private static final String COMPUTE_MANUAL_READONLY_ATTR_MSG = "Update of attribute %s not allowed "
- + "for VSP onboarded manually.";
-
+ private static final String COMPUTE_HEAT_READONLY_ATTR_MSG =
+ "Update of attribute %s not allowed for VSP onboarded via HEAT.";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- public DuplicateComputeInComponentErrorBuilder(String computeName, String componentId ){
- builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG,computeName,
- componentId));
- }
-
- /**
- * Gets duplicate compute name error builder.
- *
- * @return the duplicate compute name error builder
- */
- public static ErrorCode getDuplicateComputeNameErrorBuilder(String computeName, String componenetId) {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(DUPLICATE_COMPUTE_NAME_NOT_ALLOWED_MSG, computeName, componenetId ));
- return builder.build();
- }
-
public static ErrorCode getComputeHeatReadOnlyErrorBuilder(String name) {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(UPDATE_COMPUTE_NOT_ALLOWED);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
index 9ac6e1b1bb..2d22d01774 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/ImageErrorBuilder.java
@@ -3,7 +3,11 @@ package org.openecomp.sdc.vendorsoftwareproduct.errors;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.*;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_VERSION_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.IMAGE_NAME_FORMAT_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT;
/**
* The Image error builder.
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
index 5fc29d5a4f..eed56e1a1a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/MonitoringUploadErrorBuilder.java
@@ -28,8 +28,7 @@ import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProdu
public class MonitoringUploadErrorBuilder extends BaseErrorBuilder {
private static final String UPLOAD_INVALID_DETAILED_MSG =
- "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid:" +
- " %s";
+ "Monitoring file uploaded for vendor software product with Id %s and version %s is invalid: %s";
/**
@@ -44,7 +43,7 @@ public class MonitoringUploadErrorBuilder extends BaseErrorBuilder {
getErrorCodeBuilder().withId(MONITORING_UPLOAD_INVALID);
getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION);
getErrorCodeBuilder().withMessage(String.format(UPLOAD_INVALID_DETAILED_MSG,
- vendorSoftwareProductId, version == null ? null : version.toString(), error));
+ vendorSoftwareProductId, version == null ? null : version.getId(), error));
}
/**
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
index 0850d2e704..2acfde48ff 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NicInternalNetworkErrorBuilder.java
@@ -1,11 +1,11 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_TYPE_UPDATE_NOT_ALLOWED;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.NETWORK_TYPE_UPDATE_NOT_ALLOWED;
+
public class NicInternalNetworkErrorBuilder {
private static final String NULL_NETWORKID_NOT_ALLOWED_MSG =
"Internal Networks are currently not supported for VSP created Manually, so please fix all the NIC to be of Type External and re-submit the VSP.";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
index 7801df8fd7..1b6896211b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/NotSupportedHeatOnboardMethodErrorBuilder.java
@@ -1,5 +1,8 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING;
@@ -7,9 +10,6 @@ import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProdu
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED;
import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
-import org.openecomp.sdc.common.errors.ErrorCategory;
-import org.openecomp.sdc.common.errors.ErrorCode;
-
public class NotSupportedHeatOnboardMethodErrorBuilder {
private static final String ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
"NIC cannot be added for VSPs onboarded with HEAT.";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
index 8aad900102..49785a38f8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/OnboardingMethodErrorBuilder.java
@@ -1,37 +1,19 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .VSP_INVALID_ONBOARDING_METHOD;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes
- .VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.VSP_INVALID_ONBOARDING_METHOD;
+
/**
* The type Onboarding method error builder.
*/
public class OnboardingMethodErrorBuilder {
- private static final String VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG =
- "onboardingMethod update is not allowed.";
private static final String VSP_INVALID_ONBOARDING_METHOD_MSG =
"The onboardingMethod value doesn't meet the expected attribute value.";
/**
- * Gets onboarding update error.
- *
- * @return the onboarding update error
- */
- public static ErrorCode getOnboardingUpdateError() {
- ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
- builder.withId(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED);
- builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VSP_ONBOARD_METHOD_UPDATE_NOT_ALLOWED_MSG));
- return builder.build();
- }
-
- /**
* Get invalid onboarding method error builder error code.
*
* @return the error code
@@ -40,7 +22,7 @@ public class OnboardingMethodErrorBuilder {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VSP_INVALID_ONBOARDING_METHOD);
builder.withCategory(ErrorCategory.APPLICATION);
- builder.withMessage(String.format(VSP_INVALID_ONBOARDING_METHOD_MSG));
+ builder.withMessage(VSP_INVALID_ONBOARDING_METHOD_MSG);
return builder.build();
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
index 1ec3af397f..fd8acd1497 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/TranslationFileCreationErrorBuilder.java
@@ -20,12 +20,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.errors;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.TRANSLATION_FILE_CREATION;
-
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.versioning.dao.types.Version;
+import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.TRANSLATION_FILE_CREATION;
+
public class TranslationFileCreationErrorBuilder {
private static final String TRANSLATION_FILE_CREATION_ERROR_MSG =
"Error while trying to create translation file from the package of vendor software product "
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
index 4a84c83338..4fc0b6e6f7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/errors/VendorSoftwareProductInvalidErrorBuilder.java
@@ -28,7 +28,7 @@ public class VendorSoftwareProductInvalidErrorBuilder {
private static final String VSP_INVALID_MSG =
"Vendor software product with Id %s and version %s is invalid - does not contain "
+ "service model.";
- private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG ="VSP has to have a " +
+ private static final String VSP_INVALID_MISSING_DEPLOYMENT_FLAVOR_MSG = "VSP has to have a " +
"minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP.";
private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
@@ -39,13 +39,13 @@ public class VendorSoftwareProductInvalidErrorBuilder {
* @param version the version
*/
public static ErrorCode VendorSoftwareProductMissingServiceModelErrorBuilder(String
- vendorSoftwareProductId,
- Version version) {
+ vendorSoftwareProductId,
+ Version version) {
ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder();
builder.withId(VendorSoftwareProductErrorCodes.VSP_INVALID);
builder.withCategory(ErrorCategory.APPLICATION);
builder
- .withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.toString()));
+ .withMessage(String.format(VSP_INVALID_MSG, vendorSoftwareProductId, version.getId()));
return builder.build();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
index b4513dec79..1f9a35cb2c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerFactoryImpl.java
@@ -3,13 +3,16 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
public class ComponentDependencyModelManagerFactoryImpl extends
ComponentDependencyModelManagerFactory {
+
private static final ComponentDependencyModelManager INSTANCE =
- new ComponentDependencyModelManagerImpl(VendorSoftwareProductDaoFactory.getInstance()
- .createInterface(), ComponentManagerFactory.getInstance().createInterface());
+ new ComponentDependencyModelManagerImpl(
+ ComponentManagerFactory.getInstance().createInterface(),
+ ComponentDependencyModelDaoFactory.getInstance().createInterface()
+ );
@Override
public ComponentDependencyModelManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
index 5dc1446601..17d1833af6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelManagerImpl.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.apache.commons.lang3.StringUtils;
+import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
@@ -12,72 +13,114 @@ import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentDependencyModelManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
+import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.List;
public class ComponentDependencyModelManagerImpl implements ComponentDependencyModelManager {
- private VendorSoftwareProductDao vendorSoftwareProductDao;
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
protected static final Logger logger =
LoggerFactory.getLogger(ComponentDependencyModelManagerImpl.class);
private ComponentManager componentManager;
+ private ComponentDependencyModelDao componentDependencyModelDao;
- public ComponentDependencyModelManagerImpl(VendorSoftwareProductDao vendorSoftwareProductDao, ComponentManager componentManager) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+ public ComponentDependencyModelManagerImpl(
+ ComponentManager componentManager, ComponentDependencyModelDao componentDependencyModelDao) {
this.componentManager = componentManager;
+ this.componentDependencyModelDao = componentDependencyModelDao;
+ }
+
+ private void raiseException(ErrorCode errorCode) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
+ LoggerTragetServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
+ throw new CoreException(errorCode);
}
@Override
- public void createComponentDependencyModel(List<ComponentDependencyModelEntity> entities,
- String vspId, Version version, String user) {
-
- mdcDataDebugMessage.debugEntryMessage("createComponentDependencyModel");
- for(ComponentDependencyModelEntity entity : entities) {
- if (!StringUtils.isEmpty(entity.getSourceComponentId())) {
- componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
- entity.getSourceComponentId(), user);
- if (entity.getSourceComponentId().equals(entity.getTargetComponentId())) {
- ErrorCode errorCode =
- ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
- raiseException(errorCode);
- }
- } else {
- ErrorCode errorCode = ComponentDependencyModelErrorBuilder
- .getNoSourceComponentErrorBuilder();
- raiseException(errorCode);
- }
+ public Collection<ComponentDependencyModelEntity> list(String vspId, Version version) {
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, version", vspId, version.toString());
+
+ return componentDependencyModelDao
+ .list(new ComponentDependencyModelEntity(vspId, version, null));
+ }
+
+ @Override
+ public ComponentDependencyModelEntity createComponentDependency(ComponentDependencyModelEntity
+ entity, String vspId,
+ Version version) {
+
+ validateComponentDependency(entity);
+ entity.setId(CommonMethods.nextUuId());
+ componentDependencyModelDao.create(entity);
+ return entity;
+ }
- if (!StringUtils.isEmpty(entity.getTargetComponentId())) {
- componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
- entity.getTargetComponentId(), user);
+ private void validateComponentDependency(ComponentDependencyModelEntity entity) {
+ if (!StringUtils.isEmpty(entity.getSourceComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
+ entity.getSourceComponentId());
+ if (entity.getSourceComponentId().equals(entity.getTargetComponentId())) {
+ ErrorCode errorCode =
+ ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder();
+ raiseException(errorCode);
}
+ } else {
+ ErrorCode errorCode = ComponentDependencyModelErrorBuilder
+ .getNoSourceComponentErrorBuilder();
+ raiseException(errorCode);
}
- vendorSoftwareProductDao.createComponentDependencyModel(entities, vspId, version );
-
- mdcDataDebugMessage.debugExitMessage("createComponentDependencyModel");
+ if (!StringUtils.isEmpty(entity.getTargetComponentId())) {
+ componentManager.validateComponentExistence(entity.getVspId(), entity.getVersion(),
+ entity.getTargetComponentId());
+ }
}
- private void raiseException(ErrorCode errorCode) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
- LoggerTragetServiceName.CREATE_COMPONENT_DEPENDENCY_MODEL, ErrorLevel.ERROR.name(),
- errorCode.id(), errorCode.message());
- throw new CoreException(errorCode);
+ @Override
+ public void delete(String vspId, Version version, String dependencyId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, dependencyId", vspId, dependencyId);
+ ComponentDependencyModelEntity componentDependencyEntity = getComponentDependency(vspId,
+ version, dependencyId);
+ if (componentDependencyEntity != null) {
+ componentDependencyModelDao.delete(componentDependencyEntity);
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, dependencyId", vspId, dependencyId);
}
@Override
- public Collection<ComponentDependencyModelEntity> list(String vspId, Version version, String
- user) {
+ public void update(ComponentDependencyModelEntity entity) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, dependencyId", entity.getVspId(),
+ entity.getId());
+ ComponentDependencyModelEntity componentDependencyEntity = getComponentDependency(
+ entity.getVspId(), entity.getVersion(), entity.getId());
+ validateComponentDependency(entity);
+ componentDependencyModelDao.update(entity);
+ }
- mdcDataDebugMessage.debugExitMessage("VSP id, version", vspId, version.toString());
+ @Override
+ public ComponentDependencyModelEntity get(String vspId, Version version, String dependencyId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, dependencyId", vspId, dependencyId);
+ ComponentDependencyModelEntity componentDependency =
+ getComponentDependency(vspId, version, dependencyId);
+ return componentDependency;
+ }
- return vendorSoftwareProductDao.listComponentDependencies(vspId, version);
+ private ComponentDependencyModelEntity getComponentDependency(String vspId, Version version,
+ String dependencyId) {
+ ComponentDependencyModelEntity retrieved = componentDependencyModelDao.get(
+ new ComponentDependencyModelEntity(vspId, version, dependencyId));
+ VersioningUtil.validateEntityExistence(retrieved, new ComponentDependencyModelEntity(
+ vspId, version, dependencyId), VspDetails.ENTITY_TYPE);
+ return retrieved;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
index 72a38bbb5d..1834bf05d6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImpl.java
@@ -67,10 +67,10 @@ public class ComponentManagerImpl implements ComponentManager {
private NicManager nicManager;
private VendorSoftwareProductInfoDao vspInfoDao;
- public ComponentManagerImpl(
- ComponentDao componentDao,
- CompositionEntityDataManager compositionEntityDataManager,
- NicManager nicManager, VendorSoftwareProductInfoDao vspInfoDao) {
+ public ComponentManagerImpl(ComponentDao componentDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ NicManager nicManager,
+ VendorSoftwareProductInfoDao vspInfoDao) {
this.componentDao = componentDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.nicManager = nicManager;
@@ -78,14 +78,14 @@ public class ComponentManagerImpl implements ComponentManager {
}
@Override
- public Collection<ComponentEntity> listComponents(String vspId, Version version, String user) {
+ public Collection<ComponentEntity> listComponents(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return componentDao.list(new ComponentEntity(vspId, version, null));
}
@Override
- public void deleteComponents(String vspId, Version version, String user) {
+ public void deleteComponents(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -95,12 +95,11 @@ public class ComponentManagerImpl implements ComponentManager {
new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
}
- //componentDao.updateVspLatestModificationTime(vspId, version);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
}
/*@Override
- public ComponentEntity createComponent(ComponentEntity component, String user) {
+ public ComponentEntity createComponent(ComponentEntity component) {
mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
if (!isManual(component.getVspId(), component.getVersion())) {
@@ -112,24 +111,18 @@ public class ComponentManagerImpl implements ComponentManager {
.build());
}
- //componentDao.updateVspLatestModificationTime(component.getVspId(), component.getVersion());
mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
return null;
}*/
@Override
- public ComponentEntity createComponent(ComponentEntity component, String user) {
+ public ComponentEntity createComponent(ComponentEntity component) {
mdcDataDebugMessage.debugEntryMessage("VSP id", component.getId());
- /*Version activeVersion =
- getVersionInfo(component.getVspId(), VersionableEntityAction.Write, user)
- .getActiveVersion();
- component.setVersion(activeVersion);*/
final String VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING_MSG =
"VFCs cannot be added for VSPs onboarded with HEAT.";
- ComponentEntity createdComponent = null;
-
+ ComponentEntity createdComponent;
if (!vspInfoDao.isManual(component.getVspId(), component.getVersion())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_COMPONENT, ErrorLevel.ERROR.name(),
@@ -141,7 +134,7 @@ public class ComponentManagerImpl implements ComponentManager {
} else {
validateComponentManual(component);
updateComponentName(component);
- createdComponent = createComponent(component);
+ createdComponent = compositionEntityDataManager.createComponent(component);
}
mdcDataDebugMessage.debugExitMessage("VSP id", component.getId());
@@ -149,10 +142,6 @@ public class ComponentManagerImpl implements ComponentManager {
return createdComponent;
}
- private ComponentEntity createComponent(ComponentEntity component) {
- return compositionEntityDataManager.createComponent(component);
- }
-
private void updateComponentName(ComponentEntity component) {
ComponentData data = component.getComponentCompositionData();
data.setName(COMPUTE_TYPE_PREFIX + data.getDisplayName());
@@ -166,8 +155,8 @@ public class ComponentManagerImpl implements ComponentManager {
final String VSP_VFC_DUPLICATE_NAME_MSG = "VFC with specified name "
+ "already present in given VSP.";
- Collection<ComponentEntity> vspComponentList = listComponents(component.getVspId()
- , component.getVersion(), null);
+ Collection<ComponentEntity> vspComponentList =
+ listComponents(component.getVspId(), component.getVersion());
if (vspComponentList.size() >= 1) //1707 release only supports 1 VFC in VSP (manual creation)
{
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -202,18 +191,17 @@ public class ComponentManagerImpl implements ComponentManager {
}
@Override
- public CompositionEntityValidationData updateComponent(ComponentEntity component, String user) {
+ public CompositionEntityValidationData updateComponent(ComponentEntity component) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", component
.getVspId(), component.getId());
ComponentEntity retrieved =
- getComponent(component.getVspId(), component.getVersion(), component.getId());
+ getValidatedComponent(component.getVspId(), component.getVersion(), component.getId());
boolean isManual = vspInfoDao.isManual(component.getVspId(), component.getVersion());
if (isManual) {
- validateComponentUpdateManual(component, retrieved, user);
+ validateComponentUpdateManual(retrieved);
}
-
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
schemaInput.setManual(isManual);
schemaInput.setComponent(retrieved.getComponentCompositionData());
@@ -232,19 +220,18 @@ public class ComponentManagerImpl implements ComponentManager {
return validationData;
}
- private void validateComponentUpdateManual(ComponentEntity component, ComponentEntity
- retrieved, String user) {
+ private void validateComponentUpdateManual(ComponentEntity component) {
Collection<ComponentEntity> vspComponentList =
- listComponents(component.getVspId(), component.getVersion(), user);
+ listComponents(component.getVspId(), component.getVersion());
//VFC name should be unique within VSP
//Removing VFC with same ID from list to avoid self compare
- for(ComponentEntity ce : vspComponentList) {
+ for (ComponentEntity ce : vspComponentList) {
if (ce.getId().equals(component.getId())) {
vspComponentList.remove(ce);
break;
}
}
- if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
+ if (!isVfcNameUnique(vspComponentList, component.getComponentCompositionData()
.getDisplayName())) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPDATE_COMPONENT, ErrorLevel.ERROR.name(),
@@ -259,9 +246,9 @@ public class ComponentManagerImpl implements ComponentManager {
}
public CompositionEntityResponse<ComponentData> getComponent(String vspId, Version version,
- String componentId, String user) {
+ String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ComponentEntity componentEntity = getComponent(vspId, version, componentId);
+ ComponentEntity componentEntity = getValidatedComponent(vspId, version, componentId);
ComponentData component = componentEntity.getComponentCompositionData();
ComponentCompositionSchemaInput schemaInput = new ComponentCompositionSchemaInput();
@@ -278,7 +265,7 @@ public class ComponentManagerImpl implements ComponentManager {
}
@Override
- public void deleteComponent(String vspId, Version version, String componentId, String user) {
+ public void deleteComponent(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
if (!vspInfoDao.isManual(vspId, version)) {
@@ -289,14 +276,12 @@ public class ComponentManagerImpl implements ComponentManager {
new CompositionEditNotAllowedErrorBuilder(vspId, version).build());
}
- //componentDao.updateVspLatestModificationTime(vspId, version);
-
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public QuestionnaireResponse getQuestionnaire(String vspId, Version version,
- String componentId, String user) {
+ String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
@@ -306,7 +291,7 @@ public class ComponentManagerImpl implements ComponentManager {
VspDetails.ENTITY_TYPE);
questionnaireResponse.setData(component.getQuestionnaireData());
- List<String> nicNames = nicManager.listNics(vspId, version, componentId, user).stream()
+ List<String> nicNames = nicManager.listNics(vspId, version, componentId).stream()
.map(nic -> nic.getNicCompositionData().getName()).collect(Collectors.toList());
questionnaireResponse.setSchema(getComponentQuestionnaireSchema(
new ComponentQuestionnaireSchemaInput(nicNames, questionnaireResponse.getData() == null
@@ -319,23 +304,21 @@ public class ComponentManagerImpl implements ComponentManager {
@Override
public void updateQuestionnaire(String vspId, Version version, String componentId,
- String questionnaireData, String user) {
+ String questionnaireData) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- validateComponentExistence(vspId, version, componentId, user);
+ validateComponentExistence(vspId, version, componentId);
componentDao.updateQuestionnaireData(vspId, version, componentId, questionnaireData);
- //componentDao.updateVspLatestModificationTime(vspId, version);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
- public void validateComponentExistence(String vspId, Version version, String componentId,
- String user) {
- getComponent(vspId, version, componentId);
+ public void validateComponentExistence(String vspId, Version version, String componentId) {
+ getValidatedComponent(vspId, version, componentId);
}
- private ComponentEntity getComponent(String vspId, Version version, String componentId) {
+ private ComponentEntity getValidatedComponent(String vspId, Version version, String componentId) {
ComponentEntity retrieved = componentDao.get(new ComponentEntity(vspId, version, componentId));
VersioningUtil
.validateEntityExistence(retrieved, new ComponentEntity(vspId, version, componentId),
@@ -353,8 +336,4 @@ public class ComponentManagerImpl implements ComponentManager {
.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component,
schemaInput);
}
-
- /*private boolean isManual(String vspId, Version version) {
- return false;
- }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
index 71985fa83e..598c45f323 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerFactoryImpl.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
import org.openecomp.sdc.vendorsoftwareproduct.ComputeManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
@@ -15,10 +14,7 @@ public class ComputeManagerFactoryImpl extends ComputeManagerFactory {
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
ComputeDaoFactory.getInstance().createInterface(),
CompositionEntityDataManagerFactory.getInstance().createInterface(),
- DeploymentFlavorDaoFactory.getInstance().createInterface(),
- ComponentDaoFactory.getInstance().createInterface()
-
- );
+ DeploymentFlavorDaoFactory.getInstance().createInterface());
@Override
public ComputeManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
index be90b08af9..0fc0aaffb1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImpl.java
@@ -2,6 +2,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.util.UniqueValueUtil;
+import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -12,7 +14,7 @@ import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ComputeManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
@@ -51,33 +53,22 @@ public class ComputeManagerImpl implements ComputeManager {
private CompositionEntityDataManager compositionEntityDataManager;
private VendorSoftwareProductInfoDao vspInfoDao;
private DeploymentFlavorDao deploymentFlavorDao;
- private ComponentDao componentDao;
- private static final String MANUAL = "Manual";
-
- public ComputeManagerImpl(
- VendorSoftwareProductInfoDao vspInfoDao,
- ComputeDao computeDao,
- CompositionEntityDataManager compositionEntityDataManager,
- DeploymentFlavorDao deploymentFlavorDao,
- ComponentDao componentDao
- ) {
+
+ public ComputeManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ ComputeDao computeDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ DeploymentFlavorDao deploymentFlavorDao) {
this.computeDao = computeDao;
this.compositionEntityDataManager = compositionEntityDataManager;
this.vspInfoDao = vspInfoDao;
this.deploymentFlavorDao = deploymentFlavorDao;
- this.componentDao = componentDao;
}
@Override
- public ComputeEntity createCompute(ComputeEntity compute, String user) {
- ComputeEntity createdCompute = null;
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id", compute.getVspId(),
- compute.getComponentId());
-
- /*Version activeVersion =
- getVersionInfo(compute.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- compute.setVersion(activeVersion);*/
- //if (!isManual(compute.getVspId(), activeVersion)) {
+ public ComputeEntity createCompute(ComputeEntity compute) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId());
+
if (!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
.getAddComputeNotSupportedHeatOnboardMethodErrorBuilder();
@@ -87,92 +78,45 @@ public class ComputeManagerImpl implements ComputeManager {
onboardingMethodUpdateErrorCode.message());
throw new CoreException(onboardingMethodUpdateErrorCode);
} else {
-
- //validateComponentId(compute.getVspId(),compute.getVersion(),compute.getComponentId());
- Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
- (),compute.getComponentId());
-
- validateVfcCompute(compute, vfcComputeList, LoggerTragetServiceName.CREATE_COMPUTE);
- createdCompute = createCompute(compute);
+ validateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ compute.getComputeCompositionData().getName());
+
+ compute.setQuestionnaireData(
+ new JsonSchemaDataGenerator(getComputeQuestionnaireSchema(null)).generateData());
+ computeDao.create(compute);
+ createUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ compute.getComputeCompositionData().getName());
}
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId());
- return createdCompute;
+ return compute;
}
- private ComputeEntity createCompute(ComputeEntity compute) {
-
- return compositionEntityDataManager.createCompute(compute);
- }
-
- /*private void validateCompute(ComputeEntity compute) {
- Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
- (),compute.getComponentId());
-
- if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
- final ErrorCode duplicateComputeInComponentErrorBuilder =
- new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
- compute.getComponentId()).build();
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_COMPUTE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- duplicateComputeInComponentErrorBuilder.message());
- throw new CoreException(duplicateComputeInComponentErrorBuilder);
- }
-
- }*/
-
- private void validateComputeUpdate(ComputeEntity compute) {
- Collection<ComputeEntity> vfcComputeList = listCompute(compute.getVspId(),compute.getVersion
- (),compute.getComponentId());
-
- for (ComputeEntity ce : vfcComputeList) {
- if (ce.getId().equals(compute.getId())) {
- vfcComputeList.remove(ce);
- break;
- }
- }
-
- if (!isComputeNameUnique(vfcComputeList,compute.getComputeCompositionData().getName())) {
- final ErrorCode duplicateComputeInComponentErrorBuilder =
- new DuplicateComputeInComponentErrorBuilder(compute.getComputeCompositionData().getName(),
- compute.getComponentId()).build();
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(),
- duplicateComputeInComponentErrorBuilder.message());
- throw new CoreException(duplicateComputeInComponentErrorBuilder);
- }
-
- }
@Override
- public Collection<ListComputeResponse> listCompute(String vspId, Version version,
- String componentId, String user) {
-
+ public Collection<ListComputeResponse> listComputes(String vspId, Version version,
+ String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- //validateComponentId(vspId, version, componentId);
- ComputeEntity entity = new ComputeEntity(vspId, version, componentId, null);
- Collection<ComputeEntity> computes = computeDao.list(entity);
+ Collection<ComputeEntity> computes =
+ computeDao.list(new ComputeEntity(vspId, version, componentId, null));
Collection<ListComputeResponse> computeResponse =
- getListComputeResponse(vspId, version, user, computes);
+ getListComputeResponse(vspId, version, computes);
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
return computeResponse;
}
private Collection<ListComputeResponse> getListComputeResponse(String vspId, Version version,
- String user,
Collection<ComputeEntity> computes) {
- Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version, user);
- Collection<ListComputeResponse> computeResponse = new ArrayList<ListComputeResponse>();
- for(ComputeEntity computeEntity : computes) {
+ Set<String> vspComputes = getComputeAssociatedWithDepFlavors(vspId, version);
+ Collection<ListComputeResponse> computeResponse = new ArrayList<>();
+ for (ComputeEntity computeEntity : computes) {
ListComputeResponse response = new ListComputeResponse();
response.setComputeEntity(computeEntity);
- if(vspComputes.contains(computeEntity.getId())) {
+ if (vspComputes.contains(computeEntity.getId())) {
response.setAssociatedWithDeploymentFlavor(true);
} else {
response.setAssociatedWithDeploymentFlavor(false);
@@ -182,16 +126,15 @@ public class ComputeManagerImpl implements ComputeManager {
return computeResponse;
}
- private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version,
- String user) {
+ private Set<String> getComputeAssociatedWithDepFlavors(String vspId, Version version) {
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- Set<String> vspComputes = new HashSet<String>();
- for(DeploymentFlavorEntity entity : deploymentFlavorEntities) {
+ Set<String> vspComputes = new HashSet<>();
+ for (DeploymentFlavorEntity entity : deploymentFlavorEntities) {
final List<ComponentComputeAssociation> componentComputeAssociations =
entity.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
- if(componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
- for(ComponentComputeAssociation association : componentComputeAssociations) {
+ if (componentComputeAssociations != null && !componentComputeAssociations.isEmpty()) {
+ for (ComponentComputeAssociation association : componentComputeAssociations) {
vspComputes.add(association.getComputeFlavorId());
}
}
@@ -199,32 +142,14 @@ public class ComputeManagerImpl implements ComputeManager {
return vspComputes;
}
- private boolean isComputeNameUnique(Collection<ComputeEntity> vfcComputeList, String name) {
- for (ComputeEntity compute : vfcComputeList) {
- if (compute.getComputeCompositionData().getName().equalsIgnoreCase(name)) {
- return false;
- }
- }
- return true;
- }
-
- private Collection<ComputeEntity> listCompute(String vspId, Version version,String componentId) {
- Collection<ComputeEntity> computeEntities =
- computeDao.list(new ComputeEntity(vspId, version, componentId, null));
-
- return computeEntities;
- }
-
@Override
public CompositionEntityResponse<ComputeData> getCompute(String vspId, Version version,
String componentId,
- String computeFlavorId, String user) {
+ String computeFlavorId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
componentId, computeFlavorId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- ComputeEntity computeEntity = getCompute(vspId, version, componentId, computeFlavorId);
+ ComputeEntity computeEntity = getValidatedCompute(vspId, version, componentId, computeFlavorId);
ComputeData compute = computeEntity.getComputeCompositionData();
ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
@@ -242,9 +167,8 @@ public class ComputeManagerImpl implements ComputeManager {
return response;
}
- private ComputeEntity getCompute(String vspId, Version version, String componentId, String
- computeFlavorId) {
- //validateComponentId(vspId,version,componentId);
+ private ComputeEntity getValidatedCompute(String vspId, Version version, String componentId,
+ String computeFlavorId) {
ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
computeFlavorId));
VersioningUtil
@@ -253,186 +177,113 @@ public class ComputeManagerImpl implements ComputeManager {
return retrieved;
}
- /*private void validateComponentId(String vspId, Version version, String componentId) {
- ComponentEntity retrivedComponent = componentDao.get(new ComponentEntity(vspId, version,
- componentId));
- VersioningUtil
- .validateEntityExistence(retrivedComponent, new ComponentEntity(vspId, version,
- componentId),VspDetails.ENTITY_TYPE);
- }*/
-
@Override
public QuestionnaireResponse getComputeQuestionnaire(String vspId, Version version, String
- componentId, String computeId, String user) {
+ componentId, String computeId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, componentId", vspId, componentId, computeId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- //validateComponentId(vspId,version,componentId);
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- //validateComponentId(vspId,version,componentId);
- ComputeEntity computeQuestionnaire = computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
+ ComputeEntity computeQuestionnaire =
+ computeDao.getQuestionnaireData(vspId, version, componentId, computeId);
VersioningUtil
- .validateEntityExistence(computeQuestionnaire, new ComputeEntity(vspId, version, componentId,
- computeId), VspDetails.ENTITY_TYPE);
+ .validateEntityExistence(computeQuestionnaire,
+ new ComputeEntity(vspId, version, componentId, computeId), VspDetails.ENTITY_TYPE);
questionnaireResponse.setData(computeQuestionnaire.getQuestionnaireData());
questionnaireResponse.setSchema(getComputeQuestionnaireSchema(null));
- mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId,
- componentId, computeId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId, computeId);
return questionnaireResponse;
}
- protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
-
- mdcDataDebugMessage.debugExitMessage(null, null);
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute,
- schemaInput);
- }
-
-
@Override
- public void updateComputeQuestionnaire(String vspId, Version version, String componentId, String
- computeId,
- String questionnaireData, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
- componentId, computeId);
+ public void updateComputeQuestionnaire(String vspId, Version version, String componentId,
+ String computeId, String questionnaireData) {
+ mdcDataDebugMessage
+ .debugEntryMessage("VSP id, component id, compute id", vspId, componentId, computeId);
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- getComponent(vspId, activeVersion, componentId);*/
- ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId,version,componentId,
+ ComputeEntity retrieved = computeDao.get(new ComputeEntity(vspId, version, componentId,
computeId));
VersioningUtil.validateEntityExistence(retrieved, new ComputeEntity(vspId, version,
componentId, computeId), VspDetails.ENTITY_TYPE);
computeDao.updateQuestionnaireData(vspId, version, componentId, computeId, questionnaireData);
- mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
- componentId, computeId);
+ mdcDataDebugMessage
+ .debugExitMessage("VSP id, component id, compute id", vspId, componentId, computeId);
}
@Override
- public CompositionEntityValidationData updateCompute(ComputeEntity compute, String user) {
+ public CompositionEntityValidationData updateCompute(ComputeEntity compute) {
mdcDataDebugMessage
- .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
- compute.getId());
-
- /*Version activeVersion =
- getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- image.setVersion(activeVersion);*/
+ .debugEntryMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
+ compute.getId());
- ComputeEntity retrieved = getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ ComputeEntity retrieved =
+ getComputeEntity(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
compute.getId());
- if(!vspInfoDao.isManual(compute.getVspId(), compute.getVersion())) {
- final ComputeData computeCompositionData = compute.getComputeCompositionData();
- final String name = computeCompositionData.getName();
- //final String format = computeCompositionData.getFormat();
- validateHeatVspComputeUpdate("Name", name, retrieved.getComputeCompositionData()
- .getName());
- /*validateHeatVspComputeUpdate("format", format, retrieved.getComputeCompositionData()
- .getFormat());*/
+ boolean manual = vspInfoDao.isManual(compute.getVspId(), compute.getVersion());
+ if (!manual) {
+ validateHeatVspComputeUpdate("Name",
+ compute.getComputeCompositionData().getName(),
+ retrieved.getComputeCompositionData().getName());
}
- Collection<ComputeEntity> vfcComputeList = listComputes(compute.getVspId() ,
- compute.getVersion(), compute.getComponentId());
-
- //Set to null so that retrieved object is equal to one in list and gets removed.
- retrieved.setQuestionnaireData(null);
- vfcComputeList.remove(retrieved);
- if(vspInfoDao.isManual(compute.getVspId(), compute.getVersion()))
- validateVfcCompute(compute, vfcComputeList, LoggerTragetServiceName.UPDATE_COMPUTE);
-
- //Set format to default value in order to handle FTL validation when compute format is null
- /*if(compute.getComputeCompositionData().getFormat() == null)
- compute.getComputeCompositionData().setFormat(ComputeFormat.qcow2.name());*/
-
ComputeCompositionSchemaInput schemaInput = new ComputeCompositionSchemaInput();
schemaInput.setCompute(compute.getComputeCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
+ .validateEntity(compute, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
+ updateUniqueName(compute.getVspId(), compute.getVersion(), compute.getComponentId(),
+ retrieved.getComputeCompositionData().getName(),
+ compute.getComputeCompositionData().getName());
computeDao.update(compute);
}
mdcDataDebugMessage
- .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
- compute.getId());
+ .debugExitMessage("VSP id, component id", compute.getVspId(), compute.getComponentId(),
+ compute.getId());
return validationData;
}
private void validateHeatVspComputeUpdate(String name, String value, String retrivedValue) {
- if(value != null && !value.equals(retrivedValue)) {
+ if (value != null && !value.equals(retrivedValue)) {
final ErrorCode updateHeatComputeErrorBuilder =
- DuplicateComputeInComponentErrorBuilder.getComputeHeatReadOnlyErrorBuilder(name);
+ DuplicateComputeInComponentErrorBuilder.getComputeHeatReadOnlyErrorBuilder(name);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
- updateHeatComputeErrorBuilder.message());
+ LoggerTragetServiceName.UPDATE_COMPUTE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatComputeErrorBuilder.message());
throw new CoreException(updateHeatComputeErrorBuilder);
}
}
- private void validateVfcCompute(ComputeEntity compute, Collection<ComputeEntity> vfcComputeList,
- String event) {
- if (isComputeNameDuplicate(vfcComputeList,compute.getComputeCompositionData().getName(),
- compute.getId())) {
- ErrorCode errorCode = DuplicateComputeInComponentErrorBuilder
- .getDuplicateComputeNameErrorBuilder(compute.getComputeCompositionData().getName(),
- compute.getComponentId());
-
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- event, ErrorLevel.ERROR.name(),
- errorCode.id(),errorCode.message());
-
- throw new CoreException(errorCode);
- }
- }
-
- private boolean isComputeNameDuplicate(Collection<ComputeEntity> computes, String name, String computeId) {
- for (ComputeEntity compute : computes) {
- if (compute.getComputeCompositionData().getName().equalsIgnoreCase(name) && !compute.getId().equals(computeId)) {
- return true;
- }
- }
- return false;
- }
-
-
private ComputeEntity getComputeEntity(String vspId, Version version, String componentId,
- String computeId) {
- //validateComponentId(vspId,version,componentId);
- ComputeEntity computeEntity = computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
- VersioningUtil.validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId,
- computeId), VspDetails.ENTITY_TYPE);
- return computeEntity;
- }
-
- private Collection<ComputeEntity> listComputes(String vspId, Version version, String componentId) {
- return computeDao.list(new ComputeEntity(vspId, version, componentId, null));
+ String computeId) {
+ ComputeEntity computeEntity =
+ computeDao.get(new ComputeEntity(vspId, version, componentId, computeId));
+ VersioningUtil
+ .validateEntityExistence(computeEntity, new ComputeEntity(vspId, version, componentId,
+ computeId), VspDetails.ENTITY_TYPE);
+ return computeEntity;
}
@Override
- public void deleteCompute(String vspId, Version version, String componentId, String
- computeFlavorId, String user) {
+ public void deleteCompute(String vspId, Version version, String componentId,
+ String computeFlavorId) {
final String VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG =
"Composition entities may not be created / deleted for Vendor Software Product "
+ "whose entities were uploaded";
mdcDataDebugMessage.debugEntryMessage("VSP id, component id, compute id", vspId,
componentId, computeFlavorId);
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
if (!vspInfoDao.isManual(vspId, version)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_COMPUTE, ErrorLevel.ERROR.name(),
@@ -442,30 +293,32 @@ public class ComputeManagerImpl implements ComputeManager {
.withId(VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED)
.withMessage(VSP_COMPOSITION_EDIT_NOT_ALLOWED_MSG).build());
}
- ComputeEntity retrived = getCompute(vspId,version,componentId,computeFlavorId);
- if (retrived != null){
- deleteComputeFromDeploymentFlavors(vspId,version,computeFlavorId);
+ ComputeEntity retrieved = getValidatedCompute(vspId, version, componentId, computeFlavorId);
+ if (retrieved != null) {
+ deleteComputeFromDeploymentFlavors(vspId, version, computeFlavorId);
computeDao.delete(new ComputeEntity(vspId, version, componentId, computeFlavorId));
+ deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
+ retrieved.getComputeCompositionData().getName());
}
mdcDataDebugMessage.debugExitMessage("VSP id, component id, compute id", vspId,
componentId, computeFlavorId);
}
- private void deleteComputeFromDeploymentFlavors(String vspId, Version activeVersion,
+ private void deleteComputeFromDeploymentFlavors(String vspId, Version version,
String computeFlavorId) {
- //Collection<DeploymentFlavorEntity> listDF = listDeploymentFlavors(vspId, activeVersion);
- Collection<DeploymentFlavorEntity> listDF = deploymentFlavorDao.list(new DeploymentFlavorEntity
- (vspId, activeVersion, null));
- for(DeploymentFlavorEntity df : listDF) {
- DeploymentFlavorEntity deploymentFlavorEntity=removeComputeFromDF(df, computeFlavorId);
- if(deploymentFlavorEntity!=null)
+ Collection<DeploymentFlavorEntity> listDF =
+ deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
+ for (DeploymentFlavorEntity df : listDF) {
+ DeploymentFlavorEntity deploymentFlavorEntity = removeComputeFromDF(df, computeFlavorId);
+ if (deploymentFlavorEntity != null) {
deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
}
}
- private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df, String
- computeFlavorId) {
+ private DeploymentFlavorEntity removeComputeFromDF(DeploymentFlavorEntity df,
+ String computeFlavorId) {
DeploymentFlavor flavor = df.getDeploymentFlavorCompositionData();
List<ComponentComputeAssociation> associations = flavor.getComponentComputeAssociations();
if (associations != null) {
@@ -486,20 +339,47 @@ public class ComputeManagerImpl implements ComputeManager {
return null;
}
- protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput){
- mdcDataDebugMessage.debugEntryMessage(null, null);
- mdcDataDebugMessage.debugExitMessage(null, null);
- return SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
+ protected String getComputeCompositionSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugExitMessage(null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.compute, schemaInput);
+ }
+
+ protected String getComputeQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugExitMessage(null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.compute, schemaInput);
}
- /*boolean isManual(String vspId, Version version) {
+ protected void validateUniqueName(String vspId, Version version, String componentId,
+ String name) {
+ UniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME,
+ vspId, version.getId(), componentId, name);
+ }
- VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
- String onboardingMethod = vsp.getOnboardingMethod();
- if (MANUAL.equals(onboardingMethod)) {
- return true;
- }
- return false;
- }*/
+ protected void createUniqueName(String vspId, Version version, String componentId, String name) {
+ UniqueValueUtil
+ .createUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
+ version.getId(), componentId, name);
+ }
+
+ protected void updateUniqueName(String vspId, Version version, String componentId,
+ String oldName, String newName) {
+ UniqueValueUtil
+ .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, oldName,
+ newName, vspId, version.getId(), componentId);
+ }
+ protected void deleteUniqueValue(String vspId, Version version, String componentId, String name) {
+ if (componentId == null) {
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
+ version.getId(), name);
+ }
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.COMPUTE_NAME, vspId,
+ version.getId(), componentId, name);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
index 0873eaf921..f1acaae178 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImpl.java
@@ -44,18 +44,14 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
private VendorSoftwareProductInfoDao vspInfoDao;
private DeploymentFlavorDao deploymentFlavorDao;
private CompositionEntityDataManager compositionEntityDataManager;
- private ComponentDao componentDao;
+ private ComponentDao componentDao;
private ComputeDao computeDao;
- public DeploymentFlavorManagerImpl(
- VendorSoftwareProductInfoDao vspInfoDao,
- DeploymentFlavorDao deploymentFlavorDao,
- CompositionEntityDataManager compositionEntityDataManager,
- ComponentDao componentDao,
- ComputeDao computeDao
-
- ) {
-
+ public DeploymentFlavorManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ DeploymentFlavorDao deploymentFlavorDao,
+ CompositionEntityDataManager compositionEntityDataManager,
+ ComponentDao componentDao,
+ ComputeDao computeDao) {
this.vspInfoDao = vspInfoDao;
this.deploymentFlavorDao = deploymentFlavorDao;
this.compositionEntityDataManager = compositionEntityDataManager;
@@ -65,31 +61,17 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
}
@Override
- public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version,
- String user) {
+ public Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
-
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return listDeploymentFlavors(vspId, version);
- }
-
- private Collection<DeploymentFlavorEntity> listDeploymentFlavors(String vspId, Version version) {
- Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
- return deploymentFlavorEntities;
+ return deploymentFlavorDao.list(new DeploymentFlavorEntity(vspId, version, null));
}
@Override
public DeploymentFlavorEntity createDeploymentFlavor(
- DeploymentFlavorEntity deploymentFlavorEntity, String user) {
- DeploymentFlavorEntity createDeploymentFlavor = null;
+ DeploymentFlavorEntity deploymentFlavorEntity) {
+ DeploymentFlavorEntity createDeploymentFlavor;
mdcDataDebugMessage.debugEntryMessage("VSP id ", deploymentFlavorEntity.getVspId());
- /*Version activeVersion =
- getVersionInfo(deploymentFlavorEntity.getVspId(), VersionableEntityAction.Write, user)
- .getActiveVersion();
- deploymentFlavorEntity.setVersion(activeVersion);*/
if (!vspInfoDao.isManual(deploymentFlavorEntity.getVspId(),
deploymentFlavorEntity.getVersion())) {
@@ -100,31 +82,30 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
throw new CoreException(deploymentFlavorErrorBuilder);
} else {
- validateDeploymentFlavor(deploymentFlavorEntity, user, deploymentFlavorEntity.getVersion());
+ validateDeploymentFlavor(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
createDeploymentFlavor =
compositionEntityDataManager.createDeploymentFlavor(deploymentFlavorEntity);
}
return createDeploymentFlavor;
}
- private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity, String
- user, Version activeVersion) {
-
+ private void validateDeploymentFlavor(DeploymentFlavorEntity deploymentFlavorEntity,
+ Version version) {
//Validation for unique model.
Collection<DeploymentFlavorEntity> listDeploymentFlavors =
listDeploymentFlavors(deploymentFlavorEntity.getVspId(),
- activeVersion);
+ version);
isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
List<String> featureGroups =
- getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user, activeVersion);
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), version);
String featureGroup = deploymentFlavorEntity.getDeploymentFlavorCompositionData()
.getFeatureGroupId();
- if (featureGroup != null && featureGroup.trim().length()>0) {
+ if (featureGroup != null && featureGroup.trim().length() > 0) {
if (isEmpty(featureGroups) || (!(validFeatureGroup(featureGroups, featureGroup)))) {
ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
.getFeatureGroupNotexistErrorBuilder(featureGroup, deploymentFlavorEntity.getVspId(),
- activeVersion);
+ version);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_DEPLOYMENT_FLAVOR, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), deploymentFlavorErrorBuilder.message());
@@ -132,7 +113,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
}
}
- validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
+ validateComponentComputeAssociation(deploymentFlavorEntity, version);
}
private void isDeploymentFlavorModelDuplicate(DeploymentFlavorEntity deploymentFlavorEntity,
@@ -152,14 +133,8 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
});
}
- private List<String> getFeatureGroupListForVsp(String vspId,
- String user, Version activeVersion) {
- /*VersionedVendorSoftwareProductInfo versionedVendorSoftwareProductInfo = getVspDetails(
- vspId,activeVersion, user);
- return versionedVendorSoftwareProductInfo.getVspDetails()
- .getFeatureGroups();*/
-
- final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, activeVersion));
+ private List<String> getFeatureGroupListForVsp(String vspId, Version version) {
+ final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
return vspDetails.getFeatureGroups();
}
@@ -183,7 +158,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
}
private void validateComponentComputeAssociation(DeploymentFlavorEntity deploymentFlavorEntity,
- Version activeVersion) {
+ Version version) {
List<ComponentComputeAssociation> componentComputeAssociationList = deploymentFlavorEntity
.getDeploymentFlavorCompositionData().getComponentComputeAssociations();
List<String> vfcList = new ArrayList<>();
@@ -201,14 +176,14 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
LoggerErrorCode.DATA_ERROR.getErrorCode(), invalidAssociationErrorBuilder.message());
throw new CoreException(invalidAssociationErrorBuilder);
} else if (componentComputeAssociation.getComponentId() != null &&
- componentComputeAssociation.getComponentId().trim().length() > 0 ) {
- ComponentEntity component = getComponent(deploymentFlavorEntity.getVspId(), activeVersion,
+ componentComputeAssociation.getComponentId().trim().length() > 0) {
+ ComponentEntity component = getComponent(deploymentFlavorEntity.getVspId(), version,
componentComputeAssociation.getComponentId());
if (componentComputeAssociation
.getComputeFlavorId() != null && componentComputeAssociation
- .getComputeFlavorId().trim().length() > 0 ) {
+ .getComputeFlavorId().trim().length() > 0) {
ComputeEntity computeFlavor = computeDao.get(new ComputeEntity(deploymentFlavorEntity
- .getVspId(), activeVersion, componentComputeAssociation.getComponentId(),
+ .getVspId(), version, componentComputeAssociation.getComponentId(),
componentComputeAssociation.getComputeFlavorId()));
if (computeFlavor == null) {
ErrorCode invalidComputeIdErrorBuilder = DeploymentFlavorErrorBuilder
@@ -251,22 +226,19 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
@Override
public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavor(String vspId,
Version version,
- String deploymentFlavorId,
- String user) {
+ String deploymentFlavorId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
- deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
DeploymentFlavor deploymentFlavor = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
DeploymentFlavorCompositionSchemaInput schemaInput = new
DeploymentFlavorCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setDeploymentFlavor(deploymentFlavor);
List<String> featureGroups =
- getFeatureGroupListForVsp(vspId, user, version);
+ getFeatureGroupListForVsp(vspId, version);
schemaInput.setFeatureGroupIds(featureGroups);
CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
response.setId(deploymentFlavorId);
@@ -280,27 +252,24 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
return response;
}
- private DeploymentFlavorEntity getDeploymentFlavor(String vspId, Version version, String
+ private DeploymentFlavorEntity getValidatedDeploymentFlavor(String vspId, Version version, String
deploymentFlavorId) {
DeploymentFlavorEntity retrieved = deploymentFlavorDao.get(new DeploymentFlavorEntity(vspId,
version, deploymentFlavorId));
VersioningUtil
.validateEntityExistence(retrieved, new DeploymentFlavorEntity(vspId, version,
- deploymentFlavorId ), VspDetails.ENTITY_TYPE);
+ deploymentFlavorId), VspDetails.ENTITY_TYPE);
return retrieved;
}
@Override
public CompositionEntityResponse<DeploymentFlavor> getDeploymentFlavorSchema(String vspId,
- Version version,
- String user) {
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
- DeploymentFlavorCompositionSchemaInput schemaInput= new
- DeploymentFlavorCompositionSchemaInput();
+ Version version) {
+ DeploymentFlavorCompositionSchemaInput schemaInput =
+ new DeploymentFlavorCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(vspId, version));
List<String> featureGroups =
- getFeatureGroupListForVsp(vspId, user, version);
+ getFeatureGroupListForVsp(vspId, version);
schemaInput.setFeatureGroupIds(featureGroups);
CompositionEntityResponse<DeploymentFlavor> response = new CompositionEntityResponse<>();
response.setSchema((SchemaGenerator
@@ -310,14 +279,13 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
}
@Override
- public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId,
- String user) {
+ public void deleteDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
/*Version activeVersion =
getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();*/
- DeploymentFlavorEntity deploymentFlavorEntity = getDeploymentFlavor(vspId,version,
- deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ getValidatedDeploymentFlavor(vspId, version, deploymentFlavorId);
if (!vspInfoDao.isManual(vspId, version)) {
final ErrorCode deleteDeploymentFlavorErrorBuilder =
NotSupportedHeatOnboardMethodErrorBuilder
@@ -328,7 +296,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
deleteDeploymentFlavorErrorBuilder.message());
throw new CoreException(deleteDeploymentFlavorErrorBuilder);
}
- if(deploymentFlavorEntity != null) {
+ if (deploymentFlavorEntity != null) {
deploymentFlavorDao.delete(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
}
@@ -336,8 +304,8 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
.debugExitMessage("VSP id, deployment flavor id", vspId, deploymentFlavorId);
}
- public CompositionEntityValidationData updateDeploymentFlavor(DeploymentFlavorEntity
- deploymentFlavorEntity, String user) {
+ public CompositionEntityValidationData updateDeploymentFlavor(
+ DeploymentFlavorEntity deploymentFlavorEntity) {
mdcDataDebugMessage.debugEntryMessage("VSP id, deploymentFlavor id", deploymentFlavorEntity
.getVspId(), deploymentFlavorEntity.getId());
/*Version activeVersion =
@@ -355,9 +323,9 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
updateDeploymentFlavorErrorBuilder.message());
throw new CoreException(updateDeploymentFlavorErrorBuilder);
}
- //deploymentFlavorEntity.setVersion(activeVersion);
DeploymentFlavorEntity retrieved =
- getDeploymentFlavor(deploymentFlavorEntity.getVspId(), deploymentFlavorEntity.getVersion(),
+ getValidatedDeploymentFlavor(deploymentFlavorEntity.getVspId(),
+ deploymentFlavorEntity.getVersion(),
deploymentFlavorEntity.getId());
@@ -367,7 +335,8 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
isDeploymentFlavorModelDuplicate(deploymentFlavorEntity, listDeploymentFlavors);
//validateComponentComputeAssociation(deploymentFlavorEntity, activeVersion);
- validateComponentComputeAssociation(deploymentFlavorEntity, deploymentFlavorEntity.getVersion());
+ validateComponentComputeAssociation(deploymentFlavorEntity,
+ deploymentFlavorEntity.getVersion());
DeploymentFlavorCompositionSchemaInput schemaInput = new
DeploymentFlavorCompositionSchemaInput();
@@ -376,7 +345,7 @@ public class DeploymentFlavorManagerImpl implements DeploymentFlavorManager {
schemaInput.setDeploymentFlavor(retrieved.getDeploymentFlavorCompositionData());
List<String> featureGroups =
- getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(), user,
+ getFeatureGroupListForVsp(deploymentFlavorEntity.getVspId(),
deploymentFlavorEntity.getVersion());
schemaInput.setFeatureGroupIds(featureGroups);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
index 82b71399aa..0429ba4de8 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImpl.java
@@ -37,72 +37,49 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
import java.util.stream.Collectors;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
public class ImageManagerImpl implements ImageManager {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private VendorSoftwareProductInfoDao vspInfoDao;
private ImageDao imageDao;
private CompositionEntityDataManager compositionEntityDataManager;
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- public ImageManagerImpl(
- VendorSoftwareProductInfoDao vspInfoDao,
- ImageDao imageDao,
- CompositionEntityDataManager compositionEntityDataManager
-
- ) {
-
+ public ImageManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ ImageDao imageDao,
+ CompositionEntityDataManager compositionEntityDataManager) {
this.vspInfoDao = vspInfoDao;
this.imageDao = imageDao;
this.compositionEntityDataManager = compositionEntityDataManager;
-
}
@Override
- public ImageEntity createImage(ImageEntity imageEntity, String user) {
- /*Version activeVersion = getVersionInfo(imageEntity.getVspId(),
- VersionableEntityAction.Write, user).getActiveVersion();
-
- imageEntity.setVersion(activeVersion);*/
+ public ImageEntity createImage(ImageEntity imageEntity) {
boolean isManual = vspInfoDao.isManual(imageEntity.getVspId(), imageEntity.getVersion());
if (!isManual) {
-
ErrorCode errorCode = NotSupportedHeatOnboardMethodErrorBuilder
- .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
+ .getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_IMAGE, ErrorLevel.ERROR.name(),
- errorCode.id(), errorCode.message());
+ LoggerTragetServiceName.CREATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
throw new CoreException(errorCode);
}
-
- /*Collection<ImageEntity> vfcImageList = listImages(imageEntity.getVspId() ,
- imageEntity.getVersion(), imageEntity.getComponentId());*/
compositionEntityDataManager.createImage(imageEntity);
return imageEntity;
}
@Override
- public Collection<ImageEntity> listImages(String vspId, Version version, String componentId,
- String user) {
+ public Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- Collection<ImageEntity> imageEntities = listImages(vspId, version, componentId);
+ Collection<ImageEntity> imageEntities =
+ imageDao.list(new ImageEntity(vspId, version, componentId, null));
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
-
return imageEntities;
}
- private Collection<ImageEntity> listImages(String vspId, Version version, String componentId) {
- return imageDao.list(new ImageEntity(vspId, version, componentId, null));
- }
-
@Override
- public CompositionEntityResponse getImageSchema(String vspId, String user) {
+ public CompositionEntityResponse<Image> getImageSchema(String vspId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, image id", vspId);
CompositionEntityResponse<Image> response = new CompositionEntityResponse<>();
@@ -118,14 +95,10 @@ public class ImageManagerImpl implements ImageManager {
@Override
public CompositionEntityResponse<Image> getImage(String vspId, Version version, String
- componentId, String imageId, String user) {
+ componentId, String imageId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, componentId, image id", vspId, componentId,
- imageId);
-
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));*/
-
+ imageId);
ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
Image image = imageEntity.getImageCompositionData();
@@ -142,25 +115,21 @@ public class ImageManagerImpl implements ImageManager {
response.setSchema(getImageCompositionSchema(schemaInput));
mdcDataDebugMessage.debugExitMessage("VSP id, componentId, image id", vspId, componentId,
- imageId);
+ imageId);
return response;
}
@Override
public QuestionnaireResponse getImageQuestionnaire(String vspId, Version version, String
- componentId, String imageId, String user) {
+ componentId, String imageId) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- /*version = VersioningUtil
- .resolveVersion(version, getVersionInfo(vspId, VersionableEntityAction.Read, user));
- validateComponentId(vspId,version,componentId);*/
QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
//validateComponentId(vspId,version,componentId);
ImageEntity retrieved = imageDao.getQuestionnaireData(vspId, version, componentId, imageId);
VersioningUtil.validateEntityExistence(retrieved, new ImageEntity(vspId, version, componentId,
- imageId), ComponentEntity.ENTITY_TYPE);
+ imageId), ComponentEntity.ENTITY_TYPE);
questionnaireResponse.setData(retrieved.getQuestionnaireData());
questionnaireResponse.setSchema(getImageQuestionnaireSchema(null));
@@ -170,72 +139,63 @@ public class ImageManagerImpl implements ImageManager {
}
@Override
- public void deleteImage(String vspId, Version version, String componentId, String imageId, String
- user) {
+ public void deleteImage(String vspId, Version version, String componentId, String imageId) {
mdcDataDebugMessage
- .debugEntryMessage("VSP id, component id", vspId, componentId, imageId);
-
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
- ComponentEntity component = getComponent(vspId, activeVersion, componentId);*/
+ .debugEntryMessage("VSP id, component id", vspId, componentId, imageId);
ImageEntity imageEntity = getImageEntity(vspId, version, componentId, imageId);
if (!vspInfoDao.isManual(vspId, version)) {
final ErrorCode deleteImageErrorBuilder =
- NotSupportedHeatOnboardMethodErrorBuilder
- .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
+ NotSupportedHeatOnboardMethodErrorBuilder
+ .getDelImageNotSupportedHeatOnboardMethodErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.DELETE_IMAGE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
- deleteImageErrorBuilder.message());
+ LoggerTragetServiceName.DELETE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ deleteImageErrorBuilder.message());
throw new CoreException(deleteImageErrorBuilder);
}
if (imageEntity != null) {
imageDao.delete(new ImageEntity(vspId, version, componentId, imageId));
}
mdcDataDebugMessage
- .debugExitMessage("VSP id, component id", vspId, componentId, imageId);
+ .debugExitMessage("VSP id, component id", vspId, componentId, imageId);
}
private void validateHeatVspImageUpdate(String name, String value, String retrivedValue) {
-
- if(value != null && !value.equals(retrivedValue)) {
-
+ if (value != null && !value.equals(retrivedValue)) {
final ErrorCode updateHeatImageErrorBuilder =
- ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
+ ImageErrorBuilder.getImageHeatReadOnlyErrorBuilder(name);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
- updateHeatImageErrorBuilder.message());
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
+ updateHeatImageErrorBuilder.message());
throw new CoreException(updateHeatImageErrorBuilder);
}
}
@Override
- public CompositionEntityValidationData updateImage(ImageEntity image, String user) {
+ public CompositionEntityValidationData updateImage(ImageEntity image) {
mdcDataDebugMessage
- .debugEntryMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
- image.getId());
+ .debugEntryMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
+ image.getId());
- /*Version activeVersion =
- getVersionInfo(image.getVspId(), VersionableEntityAction.Write, user).getActiveVersion();
- image.setVersion(activeVersion);*/
boolean isManual = vspInfoDao.isManual(image.getVspId(), image.getVersion());
- ImageEntity retrieved = getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
+ ImageEntity retrieved =
+ getImageEntity(image.getVspId(), image.getVersion(), image.getComponentId(),
image.getId());
- if(!isManual) {
+ if (!isManual) {
final Image imageCompositionData = image.getImageCompositionData();
final String fileName = imageCompositionData.getFileName();
//final String format = imageCompositionData.getFormat();
validateHeatVspImageUpdate("fileName", fileName, retrieved.getImageCompositionData()
- .getFileName());
+ .getFileName());
/*validateHeatVspImageUpdate("format", format, retrieved.getImageCompositionData()
.getFormat());*/
}
- Collection<ImageEntity> vfcImageList = listImages(image.getVspId() ,
- image.getVersion(), image.getComponentId());
+ Collection<ImageEntity> vfcImageList = listImages(image.getVspId(),
+ image.getVersion(), image.getComponentId());
//Set to null so that retrieved object is equal to one in list and gets removed.
retrieved.setQuestionnaireData(null);
@@ -249,50 +209,45 @@ public class ImageManagerImpl implements ImageManager {
schemaInput.setImage(image.getImageCompositionData());
CompositionEntityValidationData validationData = compositionEntityDataManager
- .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
+ .validateEntity(image, SchemaTemplateContext.composition, schemaInput);
if (CollectionUtils.isEmpty(validationData.getErrors())) {
imageDao.update(image);
}
mdcDataDebugMessage
- .debugExitMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
- image.getId());
+ .debugExitMessage("VSP id, component id", image.getVspId(), image.getComponentId(),
+ image.getId());
return validationData;
}
@Override
public void updateImageQuestionnaire(String vspId, Version version, String componentId, String
- imageId, String questionnaireData, String user) {
+ imageId, String questionnaireData) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id, imageId", vspId, componentId,
- imageId);
+ imageId);
getImageEntity(vspId, version, componentId, imageId);
- /*Version activeVersion =
- getVersionInfo(vspId, VersionableEntityAction.Write, user).getActiveVersion();
-
- getComponent(vspId, activeVersion, componentId);*/
final ImageDetails image = JsonUtil.json2Object(questionnaireData, ImageDetails.class);
final String format = image.getFormat();
try {
if (format != null) {
- final ImageFormat imageFormat = ImageFormat.valueOf(format);
+ ImageFormat.valueOf(format);
}
} catch (IllegalArgumentException exception) {
- log.debug("", exception);
ErrorCode errorCode = ImageErrorBuilder.getInvalidImageFormatErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
- errorCode.id(), errorCode.message() );
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
throw new CoreException(errorCode);
}
//Validate Format is read only for HEAT Onboarding
if (!vspInfoDao.isManual(vspId, version)) {
final QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
- componentId, imageId, user);
+ componentId, imageId);
final String data = imageQuestionnaire.getData();
if (data != null) {
String retrivedFormat = JsonUtil.json2Object(data, ImageDetails.class).getFormat();
@@ -300,34 +255,33 @@ public class ImageManagerImpl implements ImageManager {
}
}
- if(!isImageVersionUnique(vspId, version, componentId, imageId, image, user))
- {
+ if (!isImageVersionUnique(vspId, version, componentId, imageId, image)) {
ErrorCode errorCode = ImageErrorBuilder.getDuplicateImageVersionErrorBuilder(image
- .getVersion(), componentId);
+ .getVersion(), componentId);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
- errorCode.id(),errorCode.message());
+ LoggerTragetServiceName.UPDATE_IMAGE, ErrorLevel.ERROR.name(),
+ errorCode.id(), errorCode.message());
throw new CoreException(errorCode);
}
imageDao.updateQuestionnaireData(vspId, version, componentId, imageId, questionnaireData);
mdcDataDebugMessage.debugExitMessage("VSP id, component id, imageId", vspId, componentId,
- imageId);
+ imageId);
}
- private boolean isImageVersionUnique(String vspId, Version version, String componentId, String imageId,
- ImageDetails image, String user)
- {
+ private boolean isImageVersionUnique(String vspId, Version version, String componentId,
+ String imageId,
+ ImageDetails image) {
boolean isPresent = true;
- if(image!=null && image.getVersion()!=null)
- {
- Collection<ImageEntity> imageEntities = imageDao.list(new ImageEntity(vspId, version, componentId, null));
- if(CollectionUtils.isNotEmpty(imageEntities))
- {
- imageEntities = imageEntities.stream().filter(imageEntity -> image.getVersion().trim().equalsIgnoreCase(
- getImageVersion(vspId, version, componentId, imageEntity, user))
+ if (image != null && image.getVersion() != null) {
+ Collection<ImageEntity> imageEntities =
+ imageDao.list(new ImageEntity(vspId, version, componentId, null));
+ if (CollectionUtils.isNotEmpty(imageEntities)) {
+ imageEntities =
+ imageEntities.stream().filter(imageEntity -> image.getVersion().trim().equalsIgnoreCase(
+ getImageVersion(vspId, version, componentId, imageEntity))
&& !imageEntity.getId().equals(imageId)).collect(Collectors.toList());
isPresent = CollectionUtils.isEmpty(imageEntities);
@@ -337,14 +291,17 @@ public class ImageManagerImpl implements ImageManager {
return isPresent;
}
- private String getImageVersion(String vspId, Version version, String componentId, ImageEntity imageEntity, String user)
- {
+ private String getImageVersion(String vspId, Version version, String componentId,
+ ImageEntity imageEntity) {
QuestionnaireResponse imageQuestionnaire = getImageQuestionnaire(vspId, version,
- componentId, imageEntity.getId(), user);
- ImageDetails imageDetails = JsonUtil.json2Object(imageQuestionnaire.getData(), ImageDetails.class);
+ componentId, imageEntity.getId());
+ ImageDetails imageDetails =
+ JsonUtil.json2Object(imageQuestionnaire.getData(), ImageDetails.class);
- return imageDetails==null?null:imageDetails.getVersion()!=null?imageDetails.getVersion().trim():null;
+ return imageDetails == null ? null
+ : imageDetails.getVersion() != null ? imageDetails.getVersion().trim() : null;
}
+
private ImageEntity getImageEntity(String vspId, Version version, String componentId,
String imageId) {
//validateComponentId(vspId,version,componentId);
@@ -352,34 +309,24 @@ public class ImageManagerImpl implements ImageManager {
ImageEntity imageEntity = imageDao.get(new ImageEntity(vspId, version, componentId, imageId));
VersioningUtil.validateEntityExistence(imageEntity, new ImageEntity(vspId, version, componentId,
- imageId), VspDetails.ENTITY_TYPE);
+ imageId), VspDetails.ENTITY_TYPE);
return imageEntity;
}
-
- private boolean isImageNameDuplicate(Collection<ImageEntity> images, String fileName) {
- for (ImageEntity image : images) {
- if (image.getImageCompositionData().getFileName().equalsIgnoreCase(fileName)) {
- return true;
- }
- }
- return false;
- }
-
protected String getImageCompositionSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
+ mdcDataDebugMessage.debugExitMessage(null);
return SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.image,
- schemaInput);
+ .generate(SchemaTemplateContext.composition, CompositionEntityType.image,
+ schemaInput);
}
protected String getImageQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null, null);
+ mdcDataDebugMessage.debugEntryMessage(null);
- mdcDataDebugMessage.debugExitMessage(null, null);
+ mdcDataDebugMessage.debugExitMessage(null);
return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image,
- schemaInput);
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.image,
+ schemaInput);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
index 8bdc7fdfce..fdb9621bcb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImpl.java
@@ -6,8 +6,6 @@ import org.openecomp.sdc.generator.core.services.ManualVspToscaGenerationService
import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -29,18 +27,15 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
private ManualVspDataCollectionService
manualVspDataCollectionService = new ManualVspDataCollectionService();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
@Override
- public VspModelInfo gatherVspInformation(String vspId, Version version, String user) {
+ public VspModelInfo gatherVspInformation(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage(null, null);
VspModelInfo vspModelInfo = new VspModelInfo();
//Get Release Vendor Name
Optional<String> releaseVendor;
try {
- releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version, user);
+ releaseVendor = manualVspDataCollectionService.getReleaseVendor(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
releaseVendor = Optional.empty();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
@@ -52,9 +47,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
//Get Allowed Deployment flavors information
Map<String, DeploymentFlavorModel> allowedFlavors;
try {
- allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version, user);
+ allowedFlavors = manualVspDataCollectionService.getAllowedFlavors(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect allowed flavors : "
@@ -69,9 +63,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
Map<String, List<MultiFlavorVfcImage>> vspComponentImages;
try {
vspComponentImages =
- manualVspDataCollectionService.getVspComponentImages(vspId, version, user);
+ manualVspDataCollectionService.getVspComponentImages(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component images : "
@@ -85,9 +78,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
//Get VFC component information
Map<String, String> vspComponents;
try {
- vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version, user);
+ vspComponents = manualVspDataCollectionService.getVspComponents(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp components : "
@@ -101,9 +93,8 @@ public class ManualVspToscaManagerImpl implements ManualVspToscaManager {
//Get VSP component nic information
Map<String, List<Nic>> vspComponentNics;
try {
- vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version, user);
+ vspComponentNics = manualVspDataCollectionService.getVspComponentNics(vspId, version);
} catch (Exception ex) {
- log.debug("", ex);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_API,
LoggerTragetServiceName.COLLECT_MANUAL_VSP_TOSCA_DATA, ErrorLevel.INFO.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Unable to collect vsp component nics : "
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
index 6569312f02..eed566de43 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerFactoryImpl.java
@@ -20,15 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
public class MonitoringUploadsManagerFactoryImpl extends MonitoringUploadsManagerFactory {
private static final MonitoringUploadsManager INSTANCE =
- new MonitoringUploadsManagerImpl(MonitoringUploadDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
+ new MonitoringUploadsManagerImpl(MonitoringUploadDaoFactory.getInstance().createInterface());
@Override
public MonitoringUploadsManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
index 0f4d73f8c5..bcfdefbd0c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImpl.java
@@ -26,8 +26,6 @@ import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.CommonUtil;
@@ -45,7 +43,6 @@ import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.MonitoringUploadErrorBuilder;
@@ -53,7 +50,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.MonitoringU
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersionableSubEntityNotFoundErrorBuilder;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
import java.io.IOException;
import java.io.InputStream;
@@ -67,26 +63,20 @@ import java.util.Optional;
public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private ActivityLogManager activityLogManager;
private ComponentArtifactDao componentArtifactDao;
- private VendorSoftwareProductDao vendorSoftwareProductDao;
private static final Logger logger =
LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao,
- ActivityLogManager activityLogManager) {
+ MonitoringUploadsManagerImpl(ComponentArtifactDao componentArtifactDao) {
this.componentArtifactDao = componentArtifactDao;
- this.activityLogManager = activityLogManager;
componentArtifactDao.registerVersioning(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
@Override
public void delete(String vspId, Version version, String componentId,
- MonitoringUploadType monitoringUploadType, String user) {
+ MonitoringUploadType monitoringUploadType) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
ComponentMonitoringUploadEntity componentMonitoringUploadEntity =
@@ -112,8 +102,7 @@ public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
@Override
public void upload(InputStream object, String filename, String vspId,
Version version, String componentId,
- MonitoringUploadType type,
- String user) {
+ MonitoringUploadType type) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
if (object == null) {
@@ -130,7 +119,7 @@ public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
final FileContentHandler upload =
validateZip(vspId, version, uploadedFileData, errors);
if (type.equals(MonitoringUploadType.VES_EVENTS)) {
- validateVesEventUpload(upload, errors, vspId, version);
+ validateVesEventUpload(upload, errors);
}
if (MapUtils.isNotEmpty(errors)) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -147,27 +136,18 @@ public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
uploadedFileData);
} catch (Exception exception) {
- log.debug("", exception);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_MONITORING_FILE, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid " + type.toString() + "zip file");
throw new CoreException(new MonitoringUploadErrorBuilder(exception.getMessage()).build());
}
}
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
- ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
logger.audit("Uploaded Monitoring File for component id:" + componentId + " ,vspId:" + vspId);
-
-
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
private void validateVesEventUpload(FileContentHandler upload,
- Map<String, List<ErrorMessage>> errors, String vspId,
- Version version) {
+ Map<String, List<ErrorMessage>> errors) {
if (!CommonUtil.validateAllFilesYml(upload)) {
ErrorMessage.ErrorMessageUtil.addMessage(SdcCommon.UPLOAD_FILE, errors)
.add(new ErrorMessage(ErrorLevel.ERROR,
@@ -194,8 +174,7 @@ public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
}
@Override
- public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId,
- String user) {
+ public MonitoringUploadStatus listFilenames(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
ComponentMonitoringUploadEntity current =
@@ -259,10 +238,10 @@ public class MonitoringUploadsManagerImpl implements MonitoringUploadsManager {
Map<String, List<ErrorMessage>> errors) {
FileContentHandler contentMap;
try {
- contentMap = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadedFileData);
+ contentMap =
+ CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadedFileData);
VendorSoftwareProductUtils.validateContentZipData(contentMap, errors);
} catch (IOException exception) {
- log.debug("", exception);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.VALIDATE_MONITORING_FILE, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Invalid Monitoring zip file");
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
index 77b6b0039e..e6233bb79c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImpl.java
@@ -59,7 +59,7 @@ public class NetworkManagerImpl implements NetworkManager {
}
@Override
- public Collection<NetworkEntity> listNetworks(String vspId, Version version, String user) {
+ public Collection<NetworkEntity> listNetworks(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
@@ -67,7 +67,7 @@ public class NetworkManagerImpl implements NetworkManager {
}
@Override
- public NetworkEntity createNetwork(NetworkEntity network, String user) {
+ public NetworkEntity createNetwork(NetworkEntity network) {
mdcDataDebugMessage.debugEntryMessage("VSP id", network.getVspId());
if (!isManual(network.getVspId(), network.getVersion())) {
@@ -87,16 +87,12 @@ public class NetworkManagerImpl implements NetworkManager {
return null;
}
- private NetworkEntity createNetwork(NetworkEntity network) {
- return compositionEntityDataManager.createNetwork(network);
- }
-
@Override
- public CompositionEntityValidationData updateNetwork(NetworkEntity network, String user) {
+ public CompositionEntityValidationData updateNetwork(NetworkEntity network) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, network id", network.getVspId(), network.getId());
- NetworkEntity retrieved = getNetwork(network.getVspId(), network.getVersion(), network.getId());
+ NetworkEntity retrieved = getValidatedNetwork(network.getVspId(), network.getVersion(), network.getId());
NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
schemaInput.setManual(isManual(network.getVspId(), network.getVersion()));
@@ -119,10 +115,10 @@ public class NetworkManagerImpl implements NetworkManager {
@Override
public CompositionEntityResponse<Network> getNetwork(String vspId, Version version,
- String networkId, String user) {
+ String networkId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, network id", vspId, networkId);
- NetworkEntity networkEntity = getNetwork(vspId, version, networkId);
+ NetworkEntity networkEntity = getValidatedNetwork(vspId, version, networkId);
Network network = networkEntity.getNetworkCompositionData();
NetworkCompositionSchemaInput schemaInput = new NetworkCompositionSchemaInput();
@@ -140,7 +136,7 @@ public class NetworkManagerImpl implements NetworkManager {
}
- private NetworkEntity getNetwork(String vspId, Version version, String networkId) {
+ private NetworkEntity getValidatedNetwork(String vspId, Version version, String networkId) {
NetworkEntity retrieved = networkDao.get(new NetworkEntity(vspId, version, networkId));
VersioningUtil.validateEntityExistence(retrieved, new NetworkEntity(vspId, version, networkId),
VspDetails.ENTITY_TYPE);
@@ -148,7 +144,7 @@ public class NetworkManagerImpl implements NetworkManager {
}
@Override
- public void deleteNetwork(String vspId, Version version, String networkId, String user) {
+ public void deleteNetwork(String vspId, Version version, String networkId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, network id", vspId, networkId);
if (!isManual(vspId, version)) {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
index 0304353113..f2bb0baf95 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImpl.java
@@ -37,7 +37,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.*;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DeleteNicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.DuplicateNicInComponentErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NicNetworkIdNotAllowedExternalNetworkErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.errors.NotSupportedHeatOnboardMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
@@ -63,7 +68,7 @@ public class NicManagerImpl implements NicManager {
private NicDao nicDao;
private CompositionEntityDataManager compositionEntityDataManager;
private NetworkManager networkManager;
- private VendorSoftwareProductInfoDao vspInfoDao;
+ private VendorSoftwareProductInfoDao vspInfoDao;
public NicManagerImpl(NicDao nicDao,
CompositionEntityDataManager compositionEntityDataManager,
@@ -76,14 +81,13 @@ public class NicManagerImpl implements NicManager {
}
@Override
- public Collection<NicEntity> listNics(String vspId, Version version, String componentId,
- String user) {
+ public Collection<NicEntity> listNics(String vspId, Version version, String componentId) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, componentId, null));
if (!nics.isEmpty()) {
- Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version);
nics.forEach(nicEntity -> {
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
@@ -96,18 +100,18 @@ public class NicManagerImpl implements NicManager {
return nics;
}
- private Map<String, String> listNetworksNameById(String vspId, Version version, String user) {
- Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, version, user);
+ private Map<String, String> listNetworksNameById(String vspId, Version version) {
+ Collection<NetworkEntity> networks = networkManager.listNetworks(vspId, version);
return networks.stream().collect(Collectors.toMap(NetworkEntity::getId,
networkEntity -> networkEntity.getNetworkCompositionData().getName()));
}
@Override
- public NicEntity createNic(NicEntity nic, String user) {
- NicEntity createdNic = null;
+ public NicEntity createNic(NicEntity nic) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", nic.getVspId(),
nic.getComponentId());
+ NicEntity createdNic;
if (!vspInfoDao.isManual(nic.getVspId(), nic.getVersion())) {
ErrorCode onboardingMethodUpdateErrorCode = NotSupportedHeatOnboardMethodErrorBuilder
.getAddNicNotSupportedHeatOnboardMethodErrorBuilder();
@@ -117,25 +121,20 @@ public class NicManagerImpl implements NicManager {
onboardingMethodUpdateErrorCode.message());
throw new CoreException(onboardingMethodUpdateErrorCode);
} else {
- validateNic(nic, user);
- createdNic = createNic(nic);
+ validateNic(nic);
+ createdNic = compositionEntityDataManager.createNic(nic);
}
- //nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
-
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId());
return createdNic;
}
- private NicEntity createNic(NicEntity nic) {
- return compositionEntityDataManager.createNic(nic);
- }
- private void validateNic(NicEntity nic, String user) {
+ private void validateNic(NicEntity nic) {
Collection<NicEntity> listNics = listNics(nic.getVspId(), nic.getVersion(), nic
- .getComponentId(), user);
+ .getComponentId());
String networkId = nic.getNicCompositionData().getNetworkId();
NetworkType networkType = nic.getNicCompositionData().getNetworkType();
String networkDescription = nic.getNicCompositionData().getNetworkDescription();
@@ -171,14 +170,12 @@ public class NicManagerImpl implements NicManager {
if (!(networkId == null || networkId.equals(""))) {
//NetworkEntity ne = getNetwork(nic.getVspId(), activeVersion, networkId);
final CompositionEntityResponse<Network> network =
- networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId,
- user);
+ networkManager.getNetwork(nic.getVspId(), nic.getVersion(), networkId);
}
if (!(networkDescription == null || networkDescription.equals(""))) {
final ErrorCode nicNetworkDescriptionErrorBuilder =
- new NicInternalNetworkErrorBuilder()
- .getNetworkDescriptionInternalNetworkErrorBuilder();
+ NicInternalNetworkErrorBuilder.getNetworkDescriptionInternalNetworkErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.CREATE_NIC, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), nicNetworkDescriptionErrorBuilder.message());
@@ -200,17 +197,17 @@ public class NicManagerImpl implements NicManager {
@Override
public CompositionEntityResponse<Nic> getNic(String vspId, Version version, String componentId,
- String nicId, String user) {
+ String nicId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id, nic id", vspId, componentId, nicId);
- NicEntity nicEntity = getNic(vspId, version, componentId, nicId);
+ NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
Nic nic = nicEntity.getNicCompositionData();
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(vspId, version));
schemaInput.setNic(nic);
- Map<String, String> networksNameById = listNetworksNameById(vspId, version, user);
+ Map<String, String> networksNameById = listNetworksNameById(vspId, version);
nic.setNetworkName(networksNameById.get(nic.getNetworkId()));
schemaInput.setNetworkIds(networksNameById.keySet());
@@ -226,7 +223,8 @@ public class NicManagerImpl implements NicManager {
}
- private NicEntity getNic(String vspId, Version version, String componentId, String nicId) {
+ private NicEntity getValidatedNic(String vspId, Version version, String componentId,
+ String nicId) {
NicEntity retrieved = nicDao.get(new NicEntity(vspId, version, componentId, nicId));
VersioningUtil
.validateEntityExistence(retrieved, new NicEntity(vspId, version, componentId, nicId),
@@ -235,14 +233,13 @@ public class NicManagerImpl implements NicManager {
}
@Override
- public void deleteNic(String vspId, Version version, String componentId, String nicId,
- String user) {
+ public void deleteNic(String vspId, Version version, String componentId, String nicId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
if (!vspInfoDao.isManual(vspId, version)) {
final ErrorCode deleteNicErrorBuilder =
- new DeleteNicErrorBuilder().getDeleteNicForHeatOnboardedVspErrorBuilder();
+ DeleteNicErrorBuilder.getDeleteNicForHeatOnboardedVspErrorBuilder();
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.DELETE_NIC, ErrorLevel.ERROR.name(),
LoggerErrorCode.PERMISSION_ERROR.getErrorCode(),
@@ -250,23 +247,21 @@ public class NicManagerImpl implements NicManager {
throw new CoreException(deleteNicErrorBuilder);
}
- NicEntity nicEntity = getNic(vspId, version, componentId, nicId);
- if (nicEntity != null) {
- nicDao.delete(nicEntity);
- }
+ NicEntity nicEntity = getValidatedNic(vspId, version, componentId, nicId);
+ nicDao.delete(nicEntity);
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", vspId, componentId, nicId);
}
@Override
- public CompositionEntityValidationData updateNic(NicEntity nic, String user) {
+ public CompositionEntityValidationData updateNic(NicEntity nic) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", nic.getVspId(), nic.getComponentId(),
nic.getId());
NicEntity retrieved =
- getNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
+ getValidatedNic(nic.getVspId(), nic.getVersion(), nic.getComponentId(), nic.getId());
NicCompositionSchemaInput schemaInput = new NicCompositionSchemaInput();
schemaInput.setManual(vspInfoDao.isManual(nic.getVspId(), nic.getVersion()));
@@ -289,9 +284,6 @@ public class NicManagerImpl implements NicManager {
if (CollectionUtils.isEmpty(validationData.getErrors())) {
nicDao.update(nic);
}
-
- //nicDao.updateVspLatestModificationTime(nic.getVspId(), nic.getVersion());
-
mdcDataDebugMessage
.debugExitMessage("VSP id, component id", nic.getVspId(), nic.getComponentId(),
nic.getId());
@@ -301,7 +293,7 @@ public class NicManagerImpl implements NicManager {
@Override
public QuestionnaireResponse getNicQuestionnaire(String vspId, Version version,
- String componentId, String nicId, String user) {
+ String componentId, String nicId) {
mdcDataDebugMessage
.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
@@ -321,15 +313,13 @@ public class NicManagerImpl implements NicManager {
@Override
public void updateNicQuestionnaire(String vspId, Version version, String componentId,
- String nicId, String questionnaireData, String user) {
+ String nicId, String questionnaireData) {
mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId, nicId);
getNic(vspId, version, componentId, nicId);
nicDao.updateQuestionnaireData(vspId, version, componentId, nicId, questionnaireData);
- //nicDao.updateVspLatestModificationTime(vspId, version);
-
mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId, nicId);
}
@@ -342,9 +332,4 @@ public class NicManagerImpl implements NicManager {
return SchemaGenerator
.generate(SchemaTemplateContext.composition, CompositionEntityType.nic, schemaInput);
}
- // todo *************************** move to reusable place! *************************
-
- /*private boolean isManual(String vspId, Version version) {
- return false;
- }*/
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
index b5464e5708..b8fddcd075 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerFactoryImpl.java
@@ -20,40 +20,21 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.MonitoringUploadDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
public class OrchestrationTemplateCandidateManagerFactoryImpl extends
OrchestrationTemplateCandidateManagerFactory {
+
private static final OrchestrationTemplateCandidateManager INSTANCE =
new OrchestrationTemplateCandidateManagerImpl(
- VendorSoftwareProductDaoFactory.getInstance().createInterface(),
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
- OrchestrationTemplateDaoFactory.getInstance().createInterface(),
CandidateServiceFactory.getInstance().createInterface(),
- HealingManagerFactory.getInstance().createInterface(),
- CompositionDataExtractorFactory.getInstance().createInterface(),
- ServiceModelDaoFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
- NicDaoFactory.getInstance().createInterface(),
- ComponentDaoFactory.getInstance().createInterface(),
- MonitoringUploadDaoFactory.getInstance().createInterface(),
- ProcessDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
-
+ HealingManagerFactory.getInstance().createInterface()
+ );
@Override
public OrchestrationTemplateCandidateManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
index 07a3fa7f2c..f613dbb54f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java
@@ -23,11 +23,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
-import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.CommonUtil;
@@ -35,7 +32,6 @@ import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.healing.api.HealingManager;
-import org.openecomp.sdc.healing.types.HealCode;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.api.annotations.Metrics;
@@ -43,14 +39,7 @@ import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.messages.AuditMessages;
import org.openecomp.sdc.logging.types.LoggerServiceName;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentArtifactDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
@@ -58,9 +47,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.errors.OrchestrationTemplateNotFo
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationTemplateFileHandler;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUploadFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationProcessFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationTemplateProcessHandler;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
@@ -80,114 +66,52 @@ public class OrchestrationTemplateCandidateManagerImpl
private static final Logger logger =
LoggerFactory.getLogger(OrchestrationTemplateCandidateManagerImpl.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private VendorSoftwareProductDao vendorSoftwareProductDao;
+
private VendorSoftwareProductInfoDao vspInfoDao;
- private OrchestrationTemplateDao orchestrationTemplateDataDao;
private CandidateService candidateService;
private HealingManager healingManager;
- private CompositionDataExtractor compositionDataExtractor;
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private CompositionEntityDataManager compositionEntityDataManager;
- private NicDao nicDao;
- private ComponentDao componentDao;
- private ComponentArtifactDao componentArtifactDao;
- private ActivityLogManager activityLogManager;
- private ProcessDao processDao;
-
- /**
- * Instantiates a new Orchestration template candidate manager.
- *
- * @param vendorSoftwareProductDao the vendor software product dao
- * @param vspInfoDao the vsp info dao
- * @param orchestrationTemplateDataDao the orchestration template data dao
- * @param candidateService the candidate service
- * @param healingManager the healing manager
- * @param compositionDataExtractor the composition data extractor
- * @param serviceModelDao the service model dao
- * @param compositionEntityDataManager the composition entity data manager
- * @param nicDao the nic dao
- * @param componentDao the component dao
- * @param componentArtifactDao the mib dao
- * @param processDao the process dao
- * @param activityLogManager the activity log manager
- */
- public OrchestrationTemplateCandidateManagerImpl(
- VendorSoftwareProductDao vendorSoftwareProductDao, VendorSoftwareProductInfoDao
- vspInfoDao,
- OrchestrationTemplateDao orchestrationTemplateDataDao,
- CandidateService candidateService, HealingManager healingManager,
- CompositionDataExtractor compositionDataExtractor,
- ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
- CompositionEntityDataManager compositionEntityDataManager,
- NicDao nicDao,
- ComponentDao componentDao,
- ComponentArtifactDao componentArtifactDao,
- ProcessDao processDao,
- ActivityLogManager activityLogManager) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
+
+ public OrchestrationTemplateCandidateManagerImpl(VendorSoftwareProductInfoDao vspInfoDao,
+ CandidateService candidateService,
+ HealingManager healingManager) {
this.vspInfoDao = vspInfoDao;
- this.orchestrationTemplateDataDao = orchestrationTemplateDataDao;
this.candidateService = candidateService;
this.healingManager = healingManager;
- this.compositionDataExtractor = compositionDataExtractor;
- this.serviceModelDao = serviceModelDao;
- this.compositionEntityDataManager = compositionEntityDataManager;
- this.nicDao = nicDao;
- this.componentDao = componentDao;
- this.componentArtifactDao = componentArtifactDao;
- this.processDao = processDao;
- this.activityLogManager = activityLogManager;
}
@Override
@Metrics
public UploadFileResponse upload(String vspId, Version version, InputStream fileToUpload,
- String user, String filePrefix,
- String networkPackageName) {
+ String fileSuffix, String networkPackageName) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
OrchestrationTemplateFileHandler orchestrationTemplateFileHandler =
- OrchestrationUploadFactory.createOrchestrationTemplateFileHandler(filePrefix);
+ OrchestrationUploadFactory.createOrchestrationTemplateFileHandler(fileSuffix);
+
VspDetails vspDetails = getVspDetails(vspId, version);
+
UploadFileResponse uploadResponse = orchestrationTemplateFileHandler
- .upload(vspId, version, fileToUpload, user, candidateService,
- vspDetails);
- vspDetails.setOnboardingOrigin(filePrefix);
- vspDetails.setNetworkPackageName(networkPackageName);
- vspInfoDao.update(vspDetails);
+ .upload(vspDetails, fileToUpload, fileSuffix, networkPackageName, candidateService);
uploadResponse.setNetworkPackageName(networkPackageName);
return uploadResponse;
}
-
-
@Override
- public OrchestrationTemplateActionResponse process(String vspId,
- Version version, String user) {
+ public OrchestrationTemplateActionResponse process(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
-
- Optional<OrchestrationTemplateCandidateData> candidate =
- fetchCandidateDataEntity(vspId, version);
- if (!candidate.isPresent()) {
- throw new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build());
- }
- VspDetails vspDetails =
- getVspDetails(vspId, version);
- Optional<OrchestrationTemplateProcessHandler> processInstance =
- OrchestrationProcessFactory.getInstance(vspDetails.getOnboardingOrigin());
+ OrchestrationTemplateCandidateData candidate = fetchCandidateDataEntity(vspId, version)
+ .orElseThrow(
+ () -> new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build()));
- if(processInstance.isPresent()){
- response = processInstance.get().process(vspDetails, candidate.get(), user);
- }
-
- return response;
+ return OrchestrationProcessFactory.getInstance(candidate.getFileSuffix())
+ .map(processor -> processor.process(getVspDetails(vspId, version), candidate))
+ .orElse(new OrchestrationTemplateActionResponse());
}
@Override
- public Optional<FilesDataStructure> getFilesDataStructure(
- String vspId, Version version, String user) {
+ public Optional<FilesDataStructure> getFilesDataStructure(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
Optional<FilesDataStructure> candidateFileDataStructure =
@@ -195,19 +119,13 @@ public class OrchestrationTemplateCandidateManagerImpl
if (candidateFileDataStructure.isPresent()) {
return candidateFileDataStructure;
} else {
- Map<String, Object> healingParams = getHealingParamsAsMap(vspId, version, user);
-
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
- return (Optional<FilesDataStructure>) healingManager
- .heal(HealCode.FILE_DATA_STRUCTURE_HEALER, healingParams);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return Optional.empty();
}
}
@Override
-
- public ValidationResponse updateFilesDataStructure(String vspId,
- Version version, String user,
+ public ValidationResponse updateFilesDataStructure(String vspId, Version version,
FilesDataStructure fileDataStructure) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
@@ -222,27 +140,23 @@ public class OrchestrationTemplateCandidateManagerImpl
response.setUploadDataErrors(errorsMap, LoggerServiceName.Update_Manifest,
LoggerTragetServiceName.VALIDATE_FILE_DATA_STRUCTURE);
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return response;
}
}
- candidateService.updateOrchestrationTemplateCandidateFileDataStructure(vspId, version,
- fileDataStructure);
+ candidateService
+ .updateOrchestrationTemplateCandidateFileDataStructure(vspId, version, fileDataStructure);
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return response;
}
@Override
- public Optional<Pair<String, byte[]>> get(String vspId, Version version, String user)
- throws IOException {
+ public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- VspDetails vspDetails =
- getVspDetails(vspId, version);
+ VspDetails vspDetails = getVspDetails(vspId, version);
Optional<OrchestrationTemplateCandidateData> candidateDataEntity =
fetchCandidateDataEntity(vspId, version);
@@ -252,31 +166,34 @@ public class OrchestrationTemplateCandidateManagerImpl
Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage());
logger.error(errorMessage.getMessage());
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return Optional.empty();
}
OnboardingTypesEnum type =
- OnboardingTypesEnum.getOnboardingTypesEnum(vspDetails.getOnboardingOrigin());
+ OnboardingTypesEnum.getOnboardingTypesEnum(candidateDataEntity.get().getFileSuffix());
- if(CommonUtil.isFileOriginFromZip(vspDetails.getOnboardingOrigin())) {
+ if (CommonUtil.isFileOriginFromZip(candidateDataEntity.get().getFileSuffix())) {
FilesDataStructure structure = JsonUtil
.json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class);
String manifest = candidateService.createManifest(vspDetails, structure);
- mdcDataDebugMessage
- .debugExitMessage("VSP id", vspId);
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return Optional.of(
- new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(),candidateService
+ new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(), candidateService
.replaceManifestInZip(candidateDataEntity.get().getContentData(),
- manifest, vspId, type)));
+ manifest, vspId, type)));
}
return Optional.of(
- new ImmutablePair<>(vspDetails.getOnboardingOrigin(),candidateDataEntity.get()
+ new ImmutablePair<>(candidateDataEntity.get().getFileSuffix(), candidateDataEntity.get()
.getContentData().array()));
}
+ @Override
+ public OrchestrationTemplateCandidateData getInfo(String vspId, Version version) {
+ return candidateService.getOrchestrationTemplateCandidateInfo(vspId, version);
+ }
+
private Optional<OrchestrationTemplateCandidateData> fetchCandidateDataEntity(
String vspId, Version version) {
return Optional
@@ -286,19 +203,22 @@ public class OrchestrationTemplateCandidateManagerImpl
// todo *************************** move to reusable place! *************************
- private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
+ private Map<String, Object> getHealingParamsAsMap(String vspId, Version version) {
Map<String, Object> healingParams = new HashMap<>();
healingParams.put(SdcCommon.VSP_ID, vspId);
healingParams.put(SdcCommon.VERSION, version);
- healingParams.put(SdcCommon.USER, user);
return healingParams;
}
private VspDetails getVspDetails(String vspId, Version version) {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId, version));
+/* OrchestrationTemplateEntity orchestrationTemplateInfo =
+ orchestrationTemplateDao.getInfo(vspId, version);
+ vspDetails.setValidationData(orchestrationTemplateInfo.getValidationData());
+ vspDetails.setNetworkPackageName(orchestrationTemplateInfo.getFileName());
+ vspDetails.setOnboardingOrigin(orchestrationTemplateInfo.getFileSuffix());*/
return vspDetails;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
index d870454de7..7a4e4876d2 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerFactoryImpl.java
@@ -20,16 +20,13 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManagerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
public class ProcessManagerFactoryImpl extends ProcessManagerFactory {
private static final ProcessManager INSTANCE =
- new ProcessManagerImpl(
- VendorSoftwareProductDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface());
+ new ProcessManagerImpl(ProcessDaoFactory.getInstance().createInterface());
@Override
public ProcessManager createInterface() {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
index a3d0286019..121abda1ee 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImpl.java
@@ -22,12 +22,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
@@ -35,138 +33,133 @@ import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
import org.openecomp.sdc.vendorsoftwareproduct.ProcessManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.UploadInvalidErrorBuilder;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
+import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.ByteBuffer;
import java.util.Collection;
public class ProcessManagerImpl implements ProcessManager {
- private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
- private final ActivityLogManager activityLogManager;
+ private static final String PROCESS_ARTIFACT_NOT_EXIST_MSG =
+ "Process artifact for process with Id %s does not exist for %s with Id %s and version %s";
- private final VendorSoftwareProductDao vendorSoftwareProductDao;
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private ProcessDao processDao;
- public ProcessManagerImpl(VendorSoftwareProductDao vendorSoftwareProductDao, ActivityLogManager activityLogManager) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
- this.activityLogManager = activityLogManager;
+ public ProcessManagerImpl(ProcessDao processDao) {
+ this.processDao = processDao;
}
@Override
public Collection<ProcessEntity> listProcesses(String vspId, Version version,
- String componentId,
- String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ String componentId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
- return vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
+ return processDao.list(new ProcessEntity(vspId, version, componentId, null));
}
@Override
- public void deleteProcesses(String vspId, Version version, String componentId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ public void deleteProcesses(String vspId, Version version, String componentId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- Collection<ProcessEntity> processes =
- vendorSoftwareProductDao.listProcesses(vspId, version, componentId);
+ ProcessEntity allProcesses = new ProcessEntity(vspId, version, componentId, null);
+ Collection<ProcessEntity> processes = processDao.list(allProcesses);
if (!processes.isEmpty()) {
for (ProcessEntity process : processes) {
deleteUniqueValue(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
}
+ }
- vendorSoftwareProductDao.deleteProcesses(vspId, version, componentId);
+ if (componentId == null) {
+ processDao.deleteVspAll(vspId,version);
+ } else {
+ processDao.deleteAll(allProcesses);
}
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
- public ProcessEntity createProcess(ProcessEntity process, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", process.getId(),
+ public ProcessEntity createProcess(ProcessEntity process) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
process.getComponentId());
validateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
- //process.setId(CommonMethods.nextUuId());
- vendorSoftwareProductDao.createProcess(process);
+ processDao.create(process);
createUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getName());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", process.getId(),
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
process.getComponentId());
return process;
}
-
@Override
public ProcessEntity getProcess(String vspId, Version version, String componentId,
- String processId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
+ processDao.get(new ProcessEntity(vspId, version, componentId, processId));
validateProcessExistence(vspId, version, componentId, processId, retrieved);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
return retrieved;
}
@Override
- public void updateProcess(ProcessEntity process, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", process.getId(),
+ public void updateProcess(ProcessEntity process) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", process.getId(),
process.getComponentId());
- ProcessEntity retrieved = vendorSoftwareProductDao
- .getProcess(process.getVspId(), process.getVersion(), process.getComponentId(),
- process.getId());
+ ProcessEntity retrieved = processDao.get(process);
validateProcessExistence(process.getVspId(), process.getVersion(), process.getComponentId(),
process.getId(), retrieved);
updateUniqueName(process.getVspId(), process.getVersion(), process.getComponentId(),
retrieved.getName(), process.getName());
- vendorSoftwareProductDao.updateProcess(process);
+ processDao.update(process);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", process.getId(),
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", process.getId(),
process.getComponentId());
}
@Override
- public void deleteProcess(String vspId, Version version, String componentId, String processId,
- String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ public void deleteProcess(String vspId, Version version, String componentId, String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
- validateProcessExistence(vspId, version, componentId, processId, retrieved);
+ ProcessEntity retrieved = getProcess(vspId, version, componentId, processId);
- vendorSoftwareProductDao.deleteProcess(vspId, version, componentId, processId);
+ processDao.delete(retrieved);
deleteUniqueValue(retrieved.getVspId(), retrieved.getVersion(), retrieved.getComponentId(),
retrieved.getName());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public File getProcessArtifact(String vspId, Version version, String componentId,
- String processId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
- validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+ ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
File file = new File(String.format("%s_%s_%s", vspId, componentId, processId));
try (FileOutputStream fos = new FileOutputStream(file)) {
@@ -175,125 +168,115 @@ public class ProcessManagerImpl implements ProcessManager {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.GET_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't get process artifact");
- throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
}
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
return file;
}
@Override
public void deleteProcessArtifact(String vspId, Version version, String componentId,
- String processId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
- ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcessArtifact(vspId, version, componentId, processId);
- validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+ ProcessEntity retrieved = getValidatedProcessArtifact(vspId, version, componentId, processId);
- vendorSoftwareProductDao.deleteProcessArtifact(vspId, version, componentId, processId);
+ processDao.deleteArtifact(retrieved);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
}
@Override
public void uploadProcessArtifact(InputStream artifactFile, String artifactFileName, String vspId,
- Version version, String componentId, String processId,
- String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id", vspId, componentId);
+ Version version, String componentId, String processId) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", vspId, componentId);
+
+ ProcessEntity process = getProcess(vspId, version, componentId, processId);
+ process.setArtifactName(artifactFileName);
+ process.setArtifact(readArtifact(artifactFile));
+ processDao.uploadArtifact(process);
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", vspId, componentId);
+ }
+
+ private ProcessEntity getValidatedProcessArtifact(String vspId, Version version,
+ String componentId, String processId) {
ProcessEntity retrieved =
- vendorSoftwareProductDao.getProcess(vspId, version, componentId, processId);
- validateProcessExistence(vspId, version, componentId, processId, retrieved);
+ processDao.getArtifact(new ProcessEntity(vspId, version, componentId, processId));
+ validateProcessArtifactExistence(vspId, version, componentId, processId, retrieved);
+ return retrieved;
+ }
- if (artifactFile == null) {
+ private ByteBuffer readArtifact(InputStream artifactInputStream) {
+ if (artifactInputStream == null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't upload process artifact");
throw new CoreException(new UploadInvalidErrorBuilder().build());
}
-
- byte[] artifact;
try {
- artifact = FileUtils.toByteArray(artifactFile);
+ return ByteBuffer.wrap(FileUtils.toByteArray(artifactInputStream));
} catch (RuntimeException exception) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.UPLOAD_PROCESS_ARTIFACT, ErrorLevel.ERROR.name(),
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't upload process artifact");
- throw new CoreException(new UploadInvalidErrorBuilder().build(), exception);
+ throw new CoreException(new UploadInvalidErrorBuilder().build());
}
-
- vendorSoftwareProductDao.uploadProcessArtifact(vspId, version, componentId, processId, artifact,
- artifactFileName);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
- ActivityType.UPLOAD_MONITORING_FILE.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id", vspId, componentId);
}
private void validateProcessExistence(String vspId, Version version, String componentId,
String processId, ProcessEntity retrieved) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
- processId);
-
- if (retrieved != null) {
- return;
- }
VersioningUtil.validateEntityExistence(retrieved,
new ProcessEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE);//todo retrieved is always null ??
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id, process id", vspId, componentId,
- processId);
+ VspDetails.ENTITY_TYPE);
}
private void validateProcessArtifactExistence(String vspId, Version version, String componentId,
String processId, ProcessEntity retrieved) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id, component id, process id", vspId, componentId,
- processId);
-
- if (retrieved != null) {
- VersioningUtil.validateEntityExistence(retrieved.getArtifact(),
- new ProcessEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE);
- } else {
- VersioningUtil.validateEntityExistence(retrieved,
- new ProcessEntity(vspId, version, componentId, processId),
- VspDetails.ENTITY_TYPE); //todo retrieved is always null ??
+ ProcessEntity inputProcess = new ProcessEntity(vspId, version, componentId, processId);
+ VersioningUtil.validateEntityExistence(retrieved, inputProcess, VspDetails.ENTITY_TYPE);
+ if (retrieved.getArtifact() == null) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withCategory(ErrorCategory.APPLICATION)
+ .withId(VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND)
+ .withMessage(String.format(PROCESS_ARTIFACT_NOT_EXIST_MSG,
+ processId, VspDetails.ENTITY_TYPE, vspId, version)).build());
}
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id, component id, process id", vspId, componentId,
- processId);
}
protected void validateUniqueName(String vspId, Version version, String componentId,
String processName) {
UniqueValueUtil.validateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME,
- vspId, version.toString(), componentId, processName);
+ vspId, version.getId(), componentId, processName);
}
protected void createUniqueName(String vspId, Version version, String componentId,
String processName) {
UniqueValueUtil
.createUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
- version.toString(), componentId, processName);
+ version.getId(), componentId, processName);
}
protected void updateUniqueName(String vspId, Version version, String componentId,
String oldProcessName, String newProcessName) {
UniqueValueUtil
.updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, oldProcessName,
- newProcessName, vspId, version.toString(), componentId);
+ newProcessName, vspId, version.getId(), componentId);
}
protected void deleteUniqueValue(String vspId, Version version, String componentId,
String processName) {
+ if (componentId == null) {
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
+ version.getId(), processName);
+ }
UniqueValueUtil
.deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME, vspId,
- version.toString(), componentId, processName);
+ version.getId(), componentId, processName);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index d4879da8d7..640d5c00c7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -34,18 +34,12 @@ import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.api.ValidationManager;
import org.openecomp.core.validation.util.MessageContainerUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
-import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
-import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
@@ -63,11 +57,14 @@ import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsSe
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
@@ -76,18 +73,17 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.FileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.InformationArtifactCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
@@ -99,7 +95,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGe
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
@@ -111,15 +106,8 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQu
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
import org.openecomp.sdc.vendorsoftwareproduct.utils.ComponentDependencyTracker;
-import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
-import org.slf4j.MDC;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
@@ -136,276 +124,178 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
- private String VALIDATION_VSP_ID = "validationOnlyVspId";
- private static final String VALIDATION_VSP_NAME = "validationOnlyVspName";
- //private static final String VALIDATION_VSP_USER = "validationOnlyVspUser";
-
- private static final MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
+ private static MdcDataDebugMessage MDC_DATA_DEBUG_MESSAGE = new MdcDataDebugMessage();
private static final Logger LOGGER =
LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
- private final OrchestrationTemplateDao orchestrationTemplateDao;
- private final VendorSoftwareProductInfoDao vspInfoDao;
- private final VersioningManager versioningManager;
- private final VendorSoftwareProductDao vendorSoftwareProductDao;
- private final VendorLicenseFacade vendorLicenseFacade;
- private final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private final EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
- private final HealingManager healingManager;
- private final VendorLicenseArtifactsService licenseArtifactsService;
- private final InformationArtifactGenerator informationArtifactGenerator;
- private final PackageInfoDao packageInfoDao;
- private final ActivityLogManager activityLogManager;
- private final DeploymentFlavorDao deploymentFlavorDao;
- private final NicDao nicDao;
- private final ManualVspToscaManager manualVspToscaManager;
-
- /**
- * Instantiates a new Vendor software product manager.
- *
- * @param versioningManager the versioning manager
- * @param vendorSoftwareProductDao the vendor software product dao
- * @param orchestrationTemplateDataDao the orchestration template data dao
- * @param vspInfoDao the vsp info dao
- * @param vendorLicenseFacade the vendor license facade
- * @param serviceModelDao the service model dao
- * @param enrichedServiceModelDao the enriched service model dao
- * @param healingManager the healing manager
- * @param licenseArtifactsService the license artifacts service
- * @param informationArtifactGenerator the information artifact generator
- * @param packageInfoDao the package info dao
- * @param activityLogManager the activity log manager
- * @param deploymentFlavorDao the deployment flavor dao
- * @param nicDao the nic dao
- */
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private VendorLicenseFacade vendorLicenseFacade;
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
+ private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
+ private VendorLicenseArtifactsService licenseArtifactsService;
+ private InformationArtifactGenerator informationArtifactGenerator;
+ private PackageInfoDao packageInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private ComponentDao componentDao;
+ private ComponentDependencyModelDao componentDependencyModelDao;
+ private NicDao nicDao;
+ private ComputeDao computeDao;
+ private ImageDao imageDao;
+ private ManualVspToscaManager manualVspToscaManager;
+
public VendorSoftwareProductManagerImpl(
- VersioningManager versioningManager,
- VendorSoftwareProductDao vendorSoftwareProductDao,
OrchestrationTemplateDao orchestrationTemplateDataDao,
VendorSoftwareProductInfoDao vspInfoDao,
VendorLicenseFacade vendorLicenseFacade,
ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao,
- HealingManager healingManager,
VendorLicenseArtifactsService licenseArtifactsService,
InformationArtifactGenerator informationArtifactGenerator,
PackageInfoDao packageInfoDao,
- ActivityLogManager activityLogManager,
DeploymentFlavorDao deploymentFlavorDao,
+ ComponentDao componentDao,
+ ComponentDependencyModelDao componentDependencyModelDao,
NicDao nicDao,
+ ComputeDao computeDao,
+ ImageDao imageDao,
ManualVspToscaManager manualVspToscaManager) {
- this.versioningManager = versioningManager;
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
this.orchestrationTemplateDao = orchestrationTemplateDataDao;
this.vspInfoDao = vspInfoDao;
this.vendorLicenseFacade = vendorLicenseFacade;
this.serviceModelDao = serviceModelDao;
this.enrichedServiceModelDao = enrichedServiceModelDao;
- this.healingManager = healingManager;
this.licenseArtifactsService = licenseArtifactsService;
this.informationArtifactGenerator = informationArtifactGenerator;
this.packageInfoDao = packageInfoDao;
- this.activityLogManager = activityLogManager;
this.deploymentFlavorDao = deploymentFlavorDao;
+ this.componentDao = componentDao;
+ this.componentDependencyModelDao = componentDependencyModelDao;
this.nicDao = nicDao;
+ this.computeDao = computeDao;
+ this.imageDao = imageDao;
this.manualVspToscaManager = manualVspToscaManager;
registerToVersioning();
}
private void registerToVersioning() {
- vendorSoftwareProductDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
serviceModelDao.registerVersioning(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
enrichedServiceModelDao.registerVersioning(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
}
- @Override
- public Version checkout(String vendorSoftwareProductId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_Entity.toString());
-
- Version newVersion = versioningManager
- .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user);
-
- if (newVersion != null) {
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- }
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
- return newVersion;
- }
-
-
- @Override
- public Version undoCheckout(String vendorSoftwareProductId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
-
- Version version =
- getVersionInfo(vendorSoftwareProductId, VersionableEntityAction.Read, user)
- .getActiveVersion();
-
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(version.getMajor() + 1),
- ActivityType.UNDO_CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
- String preVspName = vspInfoDao
- .get(new VspDetails(vendorSoftwareProductId, version)).getName();
-
- Version newVersion = versioningManager.undoCheckout(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user);
-
- String postVspName = vspInfoDao
- .get(new VspDetails(vendorSoftwareProductId, newVersion))
- .getName();
-
- updateUniqueName(preVspName, postVspName);
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
-
- return newVersion;
- }
@Override
- public Version checkin(String vendorSoftwareProductId, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vendorSoftwareProductId);
-
- Version newVersion = versioningManager.checkin(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, null);
-
- if (newVersion != null) {
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.CHECKIN.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- }
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vendorSoftwareProductId);
-
- return newVersion;
- }
-
- @Override
- public ValidationResponse submit(String vspId, String user) throws IOException {
+ public ValidationResponse validate(String vspId, Version version) throws IOException {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
- Version version = getVersionInfo(vspId, VersionableEntityAction.Read, user).getActiveVersion();
- VspDetails vspDetails = getVsp(vspId, version, user);
- UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
- ToscaServiceModel serviceModel =
- serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
+ VspDetails vspDetails = getValidatedVsp(vspId, version);
+ Collection<ComponentDependencyModelEntity> componentDependencies =
+ componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null));
ValidationResponse validationResponse = new ValidationResponse();
- validationResponse
- .setVspErrors(validateCompletedVendorSoftwareProduct(vspDetails, uploadData, serviceModel),
- LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
-
- if (isCyclicDependencyInComponents(vspId, vspDetails.getVersion())) {
- Collection<ErrorCode> vspErrors = validationResponse.getVspErrors() == null
- ? new ArrayList<>()
- : validationResponse.getVspErrors();
- vspErrors.add(ComponentDependencyModelErrorBuilder
- .getcyclicDependencyComponentErrorBuilder());
- validationResponse.setVspErrors(vspErrors, LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
- }
-
- validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
- validationResponse
- .setUploadDataErrors(validateUploadData(uploadData, vspDetails),
- LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
-
validationResponse.setQuestionnaireValidationResult(
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails
- .getOnboardingMethod()));
-
- if ("Manual".equals(vspDetails.getOnboardingMethod())) {
- Collection<ErrorCode> deploymentFlavourValidationErrList =
- deploymentFlavorValidation(vspDetails.getId(), vspDetails.getVersion());
- if (validationResponse.getVspErrors() != null) {
- if (deploymentFlavourValidationErrList != null) {
- validationResponse.getVspErrors().addAll(deploymentFlavourValidationErrList);
- }
- } else {
- validationResponse
- .setVspErrors(deploymentFlavourValidationErrList, LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
+ validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(),
+ vspDetails.getOnboardingMethod()));
+
+ List<ErrorCode> vspErrors = new ArrayList<>();
+ vspErrors.addAll(validateVspFields(vspDetails));
+ if (validateComponentDependencies(componentDependencies)) {
+ vspErrors
+ .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder());
+ }
+ if (Objects.nonNull(vspDetails.getOnboardingMethod()) &&
+ OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) {
+ vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
+
+ Collection<DeploymentFlavorEntity> deploymentFlavors = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
+ if (CollectionUtils.isEmpty(deploymentFlavors)) {
+ vspErrors
+ .add(VendorSoftwareProductInvalidErrorBuilder.VspMissingDeploymentFlavorErrorBuilder());
}
+ vspErrors.addAll(validateDeploymentFlavors(deploymentFlavors));
- Set<CompositionEntityValidationData> compositionEntityValidationData =
+ Set<CompositionEntityValidationData> componentValidationResult =
componentValidation(vspDetails.getId(), vspDetails.getVersion());
- if (validationResponse.getQuestionnaireValidationResult() != null) {
- if (!CollectionUtils.isEmpty(compositionEntityValidationData)) {
+ if (!CollectionUtils.isEmpty(componentValidationResult)) {
+ if (validationResponse.getQuestionnaireValidationResult() == null ||
+ validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
+ validationResponse.setQuestionnaireValidationResult(
+ new QuestionnaireValidationResult(componentValidationResult));
+ } else {
validationResponse.getQuestionnaireValidationResult().getValidationData()
- .addAll(compositionEntityValidationData);
+ .addAll(componentValidationResult);
}
- } else {
- validationResponse.setQuestionnaireValidationResult(
- CollectionUtils.isEmpty(compositionEntityValidationData) ? null :
- new QuestionnaireValidationResult(compositionEntityValidationData));
}
-
- //Generate Tosca service model for Manual Onboarding flow
- VspModelInfo vspModelInfo = manualVspToscaManager.gatherVspInformation(vspId, version, user);
- serviceModel = manualVspToscaManager.generateToscaModel(vspModelInfo);
- }
- validationResponse.setCompilationErrors(
- compile(vspId, vspDetails.getVersion(), serviceModel),
- LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
-
- if (validationResponse.isValid()) {
- Version newVersion = versioningManager.submit(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vspId, user, null);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
- .valueOf(newVersion.getMajor()),
- ActivityType.SUBMIT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
+ } else {
+ if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
+ || vspDetails.getFeatureGroups() != null) {
+ vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
+ }
+ OrchestrationTemplateEntity orchestrationTemplate =
+ orchestrationTemplateDao.get(vspId, version);
+ ToscaServiceModel serviceModel =
+ serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
+ if (!isOrchestrationTemplateExist(orchestrationTemplate) ||
+ !isServiceModelExist(serviceModel)) {
+ vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
+ .VendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
+ vspDetails.getVersion()));
+ }
+ validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate),
+ LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
}
+ validationResponse
+ .setVspErrors(vspErrors, LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
+ validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
+
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return validationResponse;
}
- private boolean isCyclicDependencyInComponents(String vendorSoftwareProductId,
- Version version) {
- final Collection<ComponentDependencyModelEntity> componentDependencyModelEntities =
- vendorSoftwareProductDao.listComponentDependencies(vendorSoftwareProductId, version);
+ @Override
+ public Map<String, List<ErrorMessage>> compile(String vspId, Version version) {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
+
+ ToscaServiceModel serviceModel =
+ OnboardingMethod.Manual.name().equals(getValidatedVsp(vspId, version).getOnboardingMethod())
+ //Generate Tosca service model for Manual Onboarding flow
+ ? manualVspToscaManager
+ .generateToscaModel(manualVspToscaManager.gatherVspInformation(vspId, version))
+ : serviceModelDao.getServiceModel(vspId, version);
+
+ Map<String, List<ErrorMessage>> compilationErrors = compile(vspId, version, serviceModel);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
+ return compilationErrors;
+ }
+
+ private boolean validateComponentDependencies(
+ Collection<ComponentDependencyModelEntity> componentDependencies) {
ComponentDependencyTracker dependencyTracker = new ComponentDependencyTracker();
- for (ComponentDependencyModelEntity entity : componentDependencyModelEntities) {
- dependencyTracker.addDependency(entity.getSourceComponentId(), entity.getTargetComponentId());
+ for (ComponentDependencyModelEntity componentDependency : componentDependencies) {
+ dependencyTracker.addDependency(componentDependency.getSourceComponentId(),
+ componentDependency.getTargetComponentId());
}
return dependencyTracker.isCyclicDependencyPresent();
}
- private Collection<ErrorCode> deploymentFlavorValidation(String vspId,
- Version version) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
- Set<CompositionEntityValidationData> validationData = new HashSet<>();
+ private Collection<ErrorCode> validateDeploymentFlavors(
+ Collection<DeploymentFlavorEntity> deploymentFlavors) {
+
Collection<ErrorCode> errorCodeList = new ArrayList<>();
- Collection<DeploymentFlavorEntity> deploymentFlavors =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
if (!CollectionUtils.isEmpty(deploymentFlavors)) {
deploymentFlavors.forEach(deploymentFlavor -> {
- DeploymentFlavorEntity deployment = vendorSoftwareProductDao.getDeploymentFlavor(vspId,
- version, deploymentFlavor.getId());
+ DeploymentFlavorEntity deployment = deploymentFlavorDao.get(deploymentFlavor);
DeploymentFlavor deploymentlocalFlavor = deployment.getDeploymentFlavorCompositionData();
if (deploymentlocalFlavor != null) {
if (deploymentlocalFlavor.getFeatureGroupId() == null) {
@@ -455,7 +345,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
Set<CompositionEntityValidationData> validationData = new HashSet<>();
Collection<ComponentEntity> components =
- vendorSoftwareProductDao.listComponents(vspId, version);
+ componentDao.list(new ComponentEntity(vspId, version, null));
if (!CollectionUtils.isEmpty(components)) {
components.forEach(component -> {
validateImage(vspId, version, validationData, component);
@@ -496,13 +386,13 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private void validateImage(String vspId, Version version,
Set<CompositionEntityValidationData> validationData,
ComponentEntity component) {
- Collection<ImageEntity> images = vendorSoftwareProductDao.listImages(vspId, version,
- component.getId());
+ Collection<ImageEntity> images =
+ imageDao.list(new ImageEntity(vspId, version, component.getId(), null));
if (CollectionUtils.isEmpty(images)) {
CompositionEntityValidationData compositionEntityValidationData = new
CompositionEntityValidationData(component.getType(), component.getId());
- compositionEntityValidationData.setEntityName(component.getComponentCompositionData()
- .getDisplayName());
+ compositionEntityValidationData
+ .setEntityName(component.getComponentCompositionData().getDisplayName());
ErrorCode vfcMissingImageErrorBuilder =
ComponentErrorBuilder.VfcMissingImageErrorBuilder();
List<String> errors = new ArrayList<>();
@@ -512,10 +402,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
}
-
- private List<ErrorCode> validateCompletedVendorSoftwareProduct(
- VspDetails vspDetails, UploadDataEntity uploadData, Object serviceModel) {
-
+ private List<ErrorCode> validateVspFields(VspDetails vspDetails) {
List<ErrorCode> errors = new ArrayList<>();
if (vspDetails.getName() == null) {
@@ -533,36 +420,13 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
if (vspDetails.getSubCategory() == null) {
errors.add(createMissingMandatoryFieldError("sub category"));
}
- if ("Manual".equals(vspDetails.getOnboardingMethod())) {
- //Manual Onboarding specific validations
- Collection<DeploymentFlavorEntity> deploymentFlavorEntities = vendorSoftwareProductDao
- .listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion());
- if (CollectionUtils.isEmpty(deploymentFlavorEntities)) {
- ErrorCode vspMissingDeploymentFlavorErrorBuilder =
- VendorSoftwareProductInvalidErrorBuilder.VspMissingDeploymentFlavorErrorBuilder();
- errors.add(vspMissingDeploymentFlavorErrorBuilder);
- }
- errors.addAll(validateMandatoryLicenseFields(vspDetails));
- } else {
- //Heat flow specific VSP validations
- if (uploadData == null || uploadData.getContentData() == null || serviceModel == null) {
- errors.add(VendorSoftwareProductInvalidErrorBuilder
- .VendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
- vspDetails.getVersion()));
- }
- if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
- || vspDetails.getFeatureGroups() != null) {
- errors.addAll(validateMandatoryLicenseFields(vspDetails));
- }
- }
- return errors.isEmpty() ? null : errors;
+ return errors;
}
private List<ErrorCode> validateMandatoryLicenseFields(VspDetails vspDetails) {
List<ErrorCode> errors = new ArrayList<>();
if (vspDetails.getVlmVersion() == null) {
- errors.add(createMissingMandatoryFieldError(
- "licensing version (in the format of: {integer}.{integer})"));
+ errors.add(createMissingMandatoryFieldError("licensing version"));
}
if (vspDetails.getLicenseAgreement() == null) {
errors.add(createMissingMandatoryFieldError("license agreement"));
@@ -577,23 +441,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return new ValidationErrorBuilder("must be supplied", fieldName).build();
}
- String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
- }
-
- private static void sortVspListByModificationTimeDescOrder(
- List<VersionedVendorSoftwareProductInfo> vsps) {
- vsps.sort((o1, o2) -> o2.getVspDetails().getWritetimeMicroSeconds()
- .compareTo(o1.getVspDetails().getWritetimeMicroSeconds()));
- }
-
-
private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version,
ToscaServiceModel serviceModel) {
- if (serviceModel == null) {
+ if (!isServiceModelExist(serviceModel)) {
return null;
}
@@ -636,135 +486,47 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
- public String fetchValidationVsp(String user) {
- try {
- validateUniqueName(VALIDATION_VSP_NAME);
- } catch (Exception ignored) {
- LOGGER.debug("Ignored exception when validating unique VSP name", ignored);
- return VALIDATION_VSP_ID;
- }
- VspDetails validationVsp = new VspDetails();
- validationVsp.setName(VALIDATION_VSP_NAME);
-
- vspInfoDao.create(validationVsp);
- Version version = versioningManager.create(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- validationVsp.getId(), user);
- validationVsp.setVersion(version);
-
- createUniqueName(VALIDATION_VSP_NAME);
- VALIDATION_VSP_ID = validationVsp.getId();
- return VALIDATION_VSP_ID;
- }
-
- @Override
- public VspDetails createVsp(VspDetails vspDetails, String user) {
+ public VspDetails createVsp(VspDetails vspDetails) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
- validateUniqueName(vspDetails.getName());
-
- vspDetails.setOnboardingOrigin(OnboardingTypesEnum.NONE.toString());
-
- vspInfoDao.create(vspDetails);//id will be set in the dao
- vspInfoDao.updateQuestionnaireData(vspDetails.getId(), null,
+ vspInfoDao.create(vspDetails);
+ vspInfoDao.updateQuestionnaireData(vspDetails.getId(), vspDetails.getVersion(),
new JsonSchemaDataGenerator(getVspQuestionnaireSchema(null)).generateData());
- Version version = versioningManager
- .create(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vspDetails.getId(), user);
- vspDetails.setVersion(version);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
- .valueOf(vspDetails.getVersion().getMajor() + 1),
- ActivityType.CREATE_NEW.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- String vspName = vspDetails.getName();
- createUniqueName(vspName);
MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
return vspDetails;
}
@Override
- public List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
-
- Map<String, VersionInfo> idToVersionsInfo = versioningManager.listEntitiesVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, user,
- VersionableEntityAction.Read);
-
- List<VersionedVendorSoftwareProductInfo> vsps = new ArrayList<>();
- for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
- VersionInfo versionInfo = entry.getValue();
- if (versionFilter != null && versionFilter.equals(VersionStatus.Final.name())) {
- if (versionInfo.getLatestFinalVersion() == null) {
- continue;
- }
- versionInfo.setActiveVersion(versionInfo.getLatestFinalVersion());
- versionInfo.setStatus(VersionStatus.Final);
- versionInfo.setLockingUser(null);
- }
-
- Version version = versionInfo.getActiveVersion();
- if (user.equals(versionInfo.getLockingUser())) {
- version.setStatus(VersionStatus.Locked);
- }
- try {
- VspDetails vsp = vspInfoDao.get(new VspDetails(entry.getKey(), version));
- if (vsp != null && !vsp.getId().equals(VALIDATION_VSP_ID)) {
- vsp.setValidationDataStructure(null);
- vsps.add(new VersionedVendorSoftwareProductInfo(vsp, versionInfo));
- }
- } catch (RuntimeException rte) {
- LOGGER.error(
- "Error trying to retrieve vsp[" + entry.getKey() + "] version[" + version.toString
- () + "] " +
- "message:" + rte.getMessage(), rte);
- }
- }
-
- sortVspListByModificationTimeDescOrder(vsps);
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
-
- return vsps;
- }
-
- @Override
- public void updateVsp(VspDetails vspDetails, String user) {
+ public void updateVsp(VspDetails vspDetails) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspDetails.getId());
VspDetails retrieved = vspInfoDao.get(vspDetails);
- if (!Objects.equals(retrieved.getOnboardingMethod(), vspDetails.getOnboardingMethod())) {
- final ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
- .getOnboardingUpdateError();
-
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_VSP, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
-
- throw new CoreException(onboardingMethodUpdateErrorCode);
+ // TODO: 6/21/2017 remove this validation when validation will be added in the REST level
+ if (retrieved == null) {
+ throw new RuntimeException(String.format("Vsp with id %s and version %s does not exist.",
+ vspDetails.getId(), vspDetails.getVersion().getId()));
}
+ vspDetails.setOnboardingMethod(retrieved.getOnboardingMethod());
//If any existing feature group is removed from VSP which is also associated in DF then
//update DF to remove feature group associations.
- updateDeploymentFlavor(vspDetails, user);
+ updateDeploymentFlavor(vspDetails);
updateUniqueName(retrieved.getName(), vspDetails.getName());
- vspDetails.setOldVersion(retrieved.getOldVersion());
-
vspInfoDao.update(vspDetails);
- //vendorSoftwareProductDao.updateVspLatestModificationTime(vspDetails.getId(), activeVersion);
MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspDetails.getId());
}
- private void updateDeploymentFlavor(VspDetails vspDetails, String user) {
+ private void updateDeploymentFlavor(VspDetails vspDetails) {
final List<String> featureGroups = vspDetails.getFeatureGroups();
if (featureGroups != null) {
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
.list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails
.getVersion(), null));
if (Objects.nonNull(deploymentFlavorEntities)) {
- deploymentFlavorEntities.forEach(deploymentFlavorEntity -> {
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
final String featureGroupId =
deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
if (!featureGroups.contains(featureGroupId)) {
@@ -773,18 +535,25 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
deploymentFlavorCompositionData.setFeatureGroupId(null);
deploymentFlavorEntity.setDeploymentFlavorCompositionData
(deploymentFlavorCompositionData);
- vendorSoftwareProductDao.updateDeploymentFlavor(deploymentFlavorEntity);
+ deploymentFlavorDao.update(deploymentFlavorEntity);
}
- });
+ }
}
}
}
@Override
- public VspDetails getVsp(String vspId, Version version, String user) {
+ public VspDetails getVsp(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
+ VspDetails vsp = getValidatedVsp(vspId, version);
+
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
+ return vsp;
+ }
+
+ private VspDetails getValidatedVsp(String vspId, Version version) {
VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
if (vsp == null) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -792,64 +561,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
LoggerErrorCode.DATA_ERROR.getErrorCode(), "Requested VSP not found");
throw new CoreException(new VendorSoftwareProductNotFoundErrorBuilder(vspId).build());
}
- vsp.setValidationData(orchestrationTemplateDao.getValidationData(vspId, version));
- if (Objects.isNull(vsp.getOnboardingOrigin())) { //todo should this only be done for non-Manual?
- vsp.setOnboardingOrigin(OnboardingTypesEnum.ZIP.toString());
- }
-
- if (Objects.isNull(vsp.getNetworkPackageName())) {
- vsp.setNetworkPackageName("Upload File");
- }
-
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
return vsp;
}
@Override
- public Version callAutoHeal(String vspId, VersionInfo versionInfo,
- VspDetails vendorSoftwareProductInfo, String user)
- throws Exception {
- switch (versionInfo.getStatus()) {
- case Locked:
- if (user.equals(versionInfo.getLockingUser())) {
- autoHeal(vspId, versionInfo.getActiveVersion(), vendorSoftwareProductInfo,
- versionInfo.getLockingUser());
- }
- return versionInfo.getActiveVersion();
- case Available:
- Version checkoutVersion = checkout(vspId, user);
- autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
- return checkin(vspId, user);
- case Final:
- return healAndAdvanceFinalVersion(vspId, vendorSoftwareProductInfo, user);
- default:
- //do nothing
- break;
- }
- return versionInfo.getActiveVersion();
- }
-
- public Version healAndAdvanceFinalVersion(String vspId, VspDetails vendorSoftwareProductInfo,
- String user) throws IOException {
-
- Version checkoutVersion = checkout(vspId, user);
- autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
- Version checkinVersion = checkin(vspId, user);
-
- ValidationResponse response = Objects.requireNonNull(submit(vspId, user),
- "Null response not expected");
-
- if (!response.isValid()) {
- return checkinVersion;
- }
-
- Version finalVersion = checkinVersion.calculateNextFinal();
- createPackage(vspId, finalVersion, user);
- return finalVersion;
- }
-
- @Override
- public void deleteVsp(String vspId, String user) {
+ public void deleteVsp(String vspId) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -862,88 +578,16 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
- public void heal(String vspId, Version version, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
-
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
-
- version = VersionStatus.Locked.equals(versionInfo.getStatus())
- ? versionInfo.getActiveVersion()
- : checkout(vspId, user);
- version.setStatus(VersionStatus.Locked);
-
- Optional<String> errorMessages =
- healingManager.healAll(getHealingParamsAsMap(vspId, version, user));
-
- VspDetails vspDetails = new VspDetails(vspId, version);
- vspDetails.setOldVersion(null);
- vspInfoDao.updateOldVersionIndication(vspDetails);
-
- LOGGER.audit("Healed VSP " + vspDetails.getId());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
-
- errorMessages.ifPresent(s -> {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
- .withCategory(ErrorCategory.APPLICATION).withMessage(s).build());
- });
- }
-
- private void autoHeal(String vspId, Version checkoutVersion, VspDetails vspDetails, String user) {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
-
- checkoutVersion.setStatus(VersionStatus.Locked);
- Map<String, Object> healingParams = getHealingParamsAsMap(vspId, checkoutVersion, user);
-
- Optional<String> errorMessages = healingManager.healAll(healingParams);
-
- vspDetails.setVersion(checkoutVersion);
- vspDetails.setOldVersion(null);
- vspInfoDao.updateOldVersionIndication(vspDetails);
-
- LOGGER.audit("Healed VSP " + vspDetails.getName());
- MDC_DATA_DEBUG_MESSAGE.debugExitMessage("VSP id", vspId);
-
- errorMessages.ifPresent(s -> {
- throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
- .withCategory(ErrorCategory.APPLICATION).withMessage(s).build());
- });
- }
-
- private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
- Map<String, Object> healingParams = new HashMap<>();
-
- healingParams.put(SdcCommon.VSP_ID, vspId);
- healingParams.put(SdcCommon.VERSION, version);
- healingParams.put(SdcCommon.USER, user);
-
- return healingParams;
- }
-
- @Override
public List<PackageInfo> listPackages(String category, String subCategory) {
return packageInfoDao.listByCategory(category, subCategory);
}
@Override
- public File getTranslatedFile(String vspId, Version version, String user) {
+ public File getTranslatedFile(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
String errorMessage;
- if (version == null) {
- errorMessage = "Package not found";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new PackageNotFoundErrorBuilder(vspId).build());
- } else if (!version.isFinal()) {
- errorMessage = "Invalid requested version";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_VERSION_INFO, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
- }
- PackageInfo packageInfo =
- packageInfoDao.get(new PackageInfo(vspId, version));
+ PackageInfo packageInfo = packageInfoDao.get(new PackageInfo(vspId, version));
if (packageInfo == null) {
errorMessage = "Package not found";
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
@@ -981,10 +625,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
- public byte[] getOrchestrationTemplateFile(String vspId, Version version, String user) {
+ public byte[] getOrchestrationTemplateFile(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
- UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
+ OrchestrationTemplateEntity uploadData = orchestrationTemplateDao.get(vspId, version);
ByteBuffer contentData = uploadData.getContentData();
if (contentData == null) {
return null;
@@ -993,7 +637,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (final ZipOutputStream zos = new ZipOutputStream(baos);
- ZipInputStream zipStream = new ZipInputStream(
+ ZipInputStream ignored = new ZipInputStream(
new ByteArrayInputStream(contentData.array()))) {
zos.write(contentData.array());
} catch (IOException exception) {
@@ -1008,29 +652,25 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
- public PackageInfo createPackage(String vspId, Version version, String user) throws IOException {
- MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
+ public OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version) {
+ return orchestrationTemplateDao.getInfo(vspId, version);
+ }
- if (!version.isFinal()) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_PACKAGE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create package");
- throw new CoreException(
- new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version)
- .build());
- }
+ @Override
+ public PackageInfo createPackage(String vspId, Version version) throws IOException {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
Version vlmVersion = vspDetails.getVlmVersion();
- PackageInfo packageInfo = createPackageInfo(vspId, vspDetails);
+ PackageInfo packageInfo = createPackageInfo(vspDetails);
ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar =
new ToscaFileOutputServiceCsarImpl();
FileContentHandler licenseArtifacts = licenseArtifactsService
.createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion,
- vspDetails.getFeatureGroups(), user);
+ vspDetails.getFeatureGroups());
//todo add tosca validation here
packageInfo.setTranslatedFile(ByteBuffer.wrap(
toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
@@ -1043,10 +683,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return packageInfo;
}
- private PackageInfo createPackageInfo(String vspId, VspDetails vspDetails) {
- PackageInfo packageInfo = new PackageInfo();
- packageInfo.setVspId(vspId);
- packageInfo.setVersion(vspDetails.getVersion());
+ private PackageInfo createPackageInfo(VspDetails vspDetails) {
+ PackageInfo packageInfo = new PackageInfo(vspDetails.getId(), vspDetails.getVersion());
packageInfo.setVspName(vspDetails.getName());
packageInfo.setVspDescription(vspDetails.getDescription());
packageInfo.setCategory(vspDetails.getCategory());
@@ -1059,7 +697,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
@Override
- public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user) {
+ public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
@@ -1078,8 +716,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
- public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData,
- String user) {
+ public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
@@ -1088,21 +725,19 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
- private Map<String, List<ErrorMessage>> validateUploadData(UploadDataEntity uploadData,
- VspDetails vspDetails)
- throws IOException {
+ private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(
+ OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
- Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
- if (uploadData == null || uploadData.getContentData() == null) {
+ if (!isOrchestrationTemplateExist(orchestrationTemplate)) {
return null;
}
+ Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
- FileContentHandler fileContentMap =
- CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.getOnboardingTypesEnum
- (vspDetails.getOnboardingOrigin()),
- uploadData.getContentData().array());
+ FileContentHandler fileContentMap = CommonUtil.validateAndUploadFileContent(
+ OnboardingTypesEnum.getOnboardingTypesEnum(orchestrationTemplate.getFileSuffix()),
+ orchestrationTemplate.getContentData().array());
- if (CommonUtil.isFileOriginFromZip(vspDetails.getOnboardingOrigin())) {
+ if (CommonUtil.isFileOriginFromZip(orchestrationTemplate.getFileSuffix())) {
ValidationManager validationManager =
ValidationManagerUtil.initValidationManager(fileContentMap);
validationErrors.putAll(validationManager.validate());
@@ -1113,14 +748,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
? null : validationErrors;
}
- private VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action,
- String user) {
- return versioningManager.getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, action);
- }
-
-
private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
String onboardingMethod) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
@@ -1132,7 +759,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
compositionEntityDataManager
.addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
- Collection<NicEntity> nics = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
+ Collection<NicEntity> nics = nicDao.listByVsp(vspId, version);
Map<String, List<String>> nicNamesByComponent = new HashMap<>();
for (NicEntity nicEntity : nics) {
@@ -1147,16 +774,16 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
Collection<ComponentEntity> components =
- vendorSoftwareProductDao.listComponentsCompositionAndQuestionnaire(vspId, version);
+ componentDao.listCompositionAndQuestionnaire(vspId, version);
components.forEach(component -> compositionEntityDataManager.addEntity(component,
new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
JsonUtil.json2Object(component.getQuestionnaireData(), Map.class))));
- Collection<ComputeEntity> computes = vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ Collection<ComputeEntity> computes = computeDao.listByVsp(vspId, version);
computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
- if ("Manual".equals(onboardingMethod)) {
- Collection<ImageEntity> images = vendorSoftwareProductDao.listImagesByVsp(vspId, version);
+ if (OnboardingMethod.Manual.name().equals(onboardingMethod)) {
+ Collection<ImageEntity> images = imageDao.listByVsp(vspId, version);
images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
}
@@ -1179,7 +806,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
- public File getInformationArtifact(String vspId, Version version, String user) {
+ public File getInformationArtifact(String vspId, Version version) {
MDC_DATA_DEBUG_MESSAGE.debugEntryMessage("VSP id", vspId);
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
@@ -1209,14 +836,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return infoArtifactFile;
}
- void validateUniqueName(String vspName) {
- UniqueValueUtil.validateUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
- }
-
- void createUniqueName(String vspName) {
- UniqueValueUtil.createUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
+ String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ MDC_DATA_DEBUG_MESSAGE.debugEntryMessage(null);
+ MDC_DATA_DEBUG_MESSAGE.debugExitMessage(null);
+ return SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
}
void updateUniqueName(String oldVspName, String newVspName) {
@@ -1226,13 +850,22 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
@Override
- public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version,
- String user) {
- return vendorSoftwareProductDao.listComputesByVsp(vspId, version);
+ public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version) {
+ return computeDao.listByVsp(vspId, version);
}
- private void auditIfContainsErrors(List<ErrorMessage> errorList, String vspId, String auditType) {
+ private boolean isOrchestrationTemplateExist(OrchestrationTemplateEntity orchestrationTemplate) {
+ return orchestrationTemplate != null &&
+ orchestrationTemplate.getContentData() != null &&
+ orchestrationTemplate.getFileSuffix() != null &&
+ orchestrationTemplate.getFileName() != null;
+ }
+ private boolean isServiceModelExist(ToscaServiceModel serviceModel) {
+ return serviceModel != null && serviceModel.getEntryDefinitionServiceTemplate() != null;
+ }
+
+ private void auditIfContainsErrors(List<ErrorMessage> errorList, String vspId, String auditType) {
errorList.forEach(errorMessage -> {
if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
LOGGER.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
@@ -1240,4 +873,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
}
});
}
+
+
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
index 5615f8f6b5..a2c0aea423 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java
@@ -22,38 +22,38 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.healing.factory.HealingManagerFactory;
import org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
-import org.openecomp.sdc.versioning.VersioningManagerFactory;
public class VspManagerFactoryImpl extends VspManagerFactory {
private static final VendorSoftwareProductManager INSTANCE =
new VendorSoftwareProductManagerImpl(
- VersioningManagerFactory.getInstance().createInterface(),
- VendorSoftwareProductDaoFactory.getInstance().createInterface(),
OrchestrationTemplateDaoFactory.getInstance().createInterface(),
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
VendorLicenseFacadeFactory.getInstance().createInterface(),
ServiceModelDaoFactory.getInstance().createInterface(),
EnrichedServiceModelDaoFactory.getInstance().createInterface(),
- HealingManagerFactory.getInstance().createInterface(),
VendorLicenseArtifactServiceFactory.getInstance().createInterface(),
InformationArtifactGeneratorFactory.getInstance().createInterface(),
PackageInfoDaoFactory.getInstance().createInterface(),
- ActivityLogManagerFactory.getInstance().createInterface(),
DeploymentFlavorDaoFactory.getInstance().createInterface(),
+ ComponentDaoFactory.getInstance().createInterface(),
+ ComponentDependencyModelDaoFactory.getInstance().createInterface(),
NicDaoFactory.getInstance().createInterface(),
+ ComputeDaoFactory.getInstance().createInterface(),
+ ImageDaoFactory.getInstance().createInterface(),
new ManualVspToscaManagerImpl());
@Override
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
index c7fb43770d..d20dc07b63 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/BaseOrchestrationTemplateHandler.java
@@ -14,87 +14,94 @@ import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.InputStream;
import java.util.Optional;
+
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
public abstract class BaseOrchestrationTemplateHandler implements OrchestrationTemplateFileHandler {
- protected static final Logger logger =
- LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class);
- protected static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
-
- @Override
- public UploadFileResponse upload(String vspId, Version version, InputStream fileToUpload, String user,
- CandidateService candidateService, VspDetails vspDetails) {
- UploadFileResponse uploadFileResponse = new UploadFileResponse();
- uploadFileResponse.setOnboardingType(getHandlerType());
- if (isNotEmptyFileToUpload(fileToUpload, uploadFileResponse, candidateService)) {
- return uploadFileResponse;
- }
-
- byte[] uploadedFileData = FileUtils.toByteArray(fileToUpload);
- if (isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService)) {
- return uploadFileResponse;
- }
-
- Optional<FileContentHandler> optionalContentMap =
- getFileContentMap(uploadFileResponse, uploadedFileData);
- if (!optionalContentMap.isPresent()) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(), getHandlerType().toString()));
- uploadFileResponse
- .addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(), getHandlerType().toString())));
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return uploadFileResponse;
- }
-
- if (!MapUtils.isEmpty(uploadFileResponse.getErrors())) {
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return uploadFileResponse;
- }
- if (updateCandidateData(vspId, user, candidateService, vspDetails, uploadFileResponse,
- uploadedFileData, optionalContentMap))
- return uploadFileResponse;
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return uploadFileResponse;
+ protected static final Logger logger =
+ LoggerFactory.getLogger(BaseOrchestrationTemplateHandler.class);
+ protected static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ @Override
+ public UploadFileResponse upload(VspDetails vspDetails, InputStream fileToUpload,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService) {
+ UploadFileResponse uploadFileResponse = new UploadFileResponse();
+ uploadFileResponse.setOnboardingType(getHandlerType());
+ if (isNotEmptyFileToUpload(fileToUpload, uploadFileResponse, candidateService)) {
+ return uploadFileResponse;
+ }
+
+ byte[] uploadedFileData = FileUtils.toByteArray(fileToUpload);
+ if (isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService)) {
+ return uploadFileResponse;
+ }
+
+ Optional<FileContentHandler> optionalContentMap =
+ getFileContentMap(uploadFileResponse, uploadedFileData);
+ if (!optionalContentMap.isPresent()) {
+ logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString()));
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString())));
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return uploadFileResponse;
}
- protected abstract boolean updateCandidateData(String vspId, String user, CandidateService candidateService,
- VspDetails vspDetails, UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData,
- Optional<FileContentHandler> optionalContentMap);
-
-
- private boolean isNotEmptyFileToUpload(InputStream fileToUpload,
- UploadFileResponse uploadFileResponse, CandidateService candidateService) {
- Optional<ErrorMessage> errorMessage =
- candidateService.validateNonEmptyFileToUpload(fileToUpload);
- if (errorMessage.isPresent()) {
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
- return true;
- }
- return false;
+ if (!MapUtils.isEmpty(uploadFileResponse.getErrors())) {
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return uploadFileResponse;
}
+ if (updateCandidateData(vspDetails, uploadedFileData, optionalContentMap.get(), fileSuffix,
+ networkPackageName, candidateService, uploadFileResponse)) {
+ return uploadFileResponse;
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return uploadFileResponse;
+
+ }
+
+ protected abstract boolean updateCandidateData(VspDetails vspDetails,
+ byte[] uploadedFileData,
+ FileContentHandler contentMap,
+ String fileSuffix,
+ String networkPackageName,
+ CandidateService candidateService,
+ UploadFileResponse uploadFileResponse);
- protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, CandidateService candidateService) {
- Optional<ErrorMessage> errorMessage;
- errorMessage = candidateService.validateRawZipData(uploadedFileData);
- if (errorMessage.isPresent()) {
- uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
- return true;
- }
- return false;
+ private boolean isNotEmptyFileToUpload(InputStream fileToUpload,
+ UploadFileResponse uploadFileResponse,
+ CandidateService candidateService) {
+ Optional<ErrorMessage> errorMessage =
+ candidateService.validateNonEmptyFileToUpload(fileToUpload);
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
}
+ return false;
+ }
+
+ protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData,
+ CandidateService candidateService) {
+ Optional<ErrorMessage> errorMessage;
+ errorMessage = candidateService.validateRawZipData(uploadedFileData);
+ if (errorMessage.isPresent()) {
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
+ return true;
+ }
+ return false;
+ }
+
+ public abstract Optional<FileContentHandler> getFileContentMap(
+ UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData);
- public abstract Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData);
- protected abstract OnboardingTypesEnum getHandlerType();
+ protected abstract OnboardingTypesEnum getHandlerType();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
index db0851cd5f..16147553fe 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateCSARHandler.java
@@ -30,131 +30,139 @@ import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CS
import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME;
public class OrchestrationTemplateCSARHandler extends BaseOrchestrationTemplateHandler
- implements OrchestrationTemplateFileHandler {
-
-
- @Override
- public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData) {
- FileContentHandler contentMap = null;
- List<String> folderList = new ArrayList<>();
- try {
- Pair<FileContentHandler, List<String>> fileContentMapFromOrchestrationCandidateZip = CommonUtil.getFileContentMapFromOrchestrationCandidateZip(uploadedFileData);
- contentMap = fileContentMapFromOrchestrationCandidateZip.getKey();
- folderList = fileContentMapFromOrchestrationCandidateZip.getRight();
- } catch (IOException exception) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_CSAR_FILE.getErrorMessage()));
- } catch (CoreException coreException) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
- }
- validateContent(uploadFileResponse, contentMap, folderList);
- return Optional.ofNullable(contentMap);
+ implements OrchestrationTemplateFileHandler {
+
+
+ @Override
+ public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData) {
+ FileContentHandler contentMap = null;
+ List<String> folderList = new ArrayList<>();
+ try {
+ Pair<FileContentHandler, List<String>> fileContentMapFromOrchestrationCandidateZip =
+ CommonUtil.getFileContentMapFromOrchestrationCandidateZip(uploadedFileData);
+ contentMap = fileContentMapFromOrchestrationCandidateZip.getKey();
+ folderList = fileContentMapFromOrchestrationCandidateZip.getRight();
+ } catch (IOException exception) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_CSAR_FILE.getErrorMessage()));
+ } catch (CoreException coreException) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
}
-
- private void validateContent(UploadFileResponse uploadFileResponse, FileContentHandler contentMap, List<String> folderList) {
- validateManifest(uploadFileResponse, contentMap);
- validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME);
- validateNoExtraFiles(uploadFileResponse, contentMap);
- validateFolders(uploadFileResponse, folderList);
+ validateContent(uploadFileResponse, contentMap, folderList);
+ return Optional.ofNullable(contentMap);
+ }
+
+ private void validateContent(UploadFileResponse uploadFileResponse, FileContentHandler contentMap,
+ List<String> folderList) {
+ validateManifest(uploadFileResponse, contentMap);
+ validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_YAML_FILE_NAME);
+ validateNoExtraFiles(uploadFileResponse, contentMap);
+ validateFolders(uploadFileResponse, folderList);
+ }
+
+ private void validateManifest(UploadFileResponse uploadFileResponse,
+ FileContentHandler contentMap) {
+
+ if (!validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
+ return;
}
- private void validateManifest(UploadFileResponse uploadFileResponse, FileContentHandler contentMap) {
-
- if (!validateFileExist(uploadFileResponse, contentMap, MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)){
- return;
- }
-
- try (InputStream fileContent = contentMap.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
+ try (InputStream fileContent = contentMap.getFileContent(MAIN_SERVICE_TEMPLATE_MF_FILE_NAME)) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(fileContent);
- if (!onboardingManifest.isValid()) {
- onboardingManifest.getErrors().forEach(error -> uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, error)));
- }
+ OnboardingManifest onboardingManifest = new OnboardingManifest(fileContent);
+ if (!onboardingManifest.isValid()) {
+ onboardingManifest.getErrors().forEach(error -> uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, error)));
+ }
- } catch (IOException e) {
- // convert to runtime to keep the throws unchanged
- throw new RuntimeException("Failed to validate manifest", e);
- }
+ } catch (IOException e) {
+ // convert to runtime to keep the throws unchanged
+ throw new RuntimeException("Failed to validate manifest", e);
}
-
- private void validateNoExtraFiles(UploadFileResponse uploadFileResponse, FileContentHandler contentMap) {
- List<String> unwantedFiles = contentMap.getFileList().stream()
- .filter(this::filterFiles).collect(Collectors.toList());
- if (!unwantedFiles.isEmpty()) {
- unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile ->
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(),
- unwantedFile))));
- }
+ }
+
+ private void validateNoExtraFiles(UploadFileResponse uploadFileResponse,
+ FileContentHandler contentMap) {
+ List<String> unwantedFiles = contentMap.getFileList().stream()
+ .filter(this::filterFiles).collect(Collectors.toList());
+ if (!unwantedFiles.isEmpty()) {
+ unwantedFiles.stream().filter(this::filterFiles).forEach(unwantedFile ->
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage(),
+ unwantedFile))));
}
+ }
+
+ private void validateFolders(UploadFileResponse uploadFileResponse, List<String> folderList) {
+ List<String> filterResult =
+ folderList.stream().filter(this::filterFolders).collect(Collectors.toList());
+ if (!filterResult.isEmpty()) {
+ folderList.stream().filter(this::filterFolders).forEach(unwantedFolder ->
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(),
+ unwantedFolder))));
- private void validateFolders(UploadFileResponse uploadFileResponse, List<String> folderList) {
- List<String> filterResult = folderList.stream().filter(this::filterFolders).collect(Collectors.toList());
- if (!filterResult.isEmpty()) {
- folderList.stream().filter(this::filterFolders).forEach( unwantedFolder ->
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_DIRECTORIES_NOT_ALLOWED.getErrorMessage(),
- unwantedFolder))));
-
- }
- }
- private boolean filterFiles(String inFileName) {
- boolean valid = ELIGIBLE_FILES.stream().anyMatch(fileName -> fileName.equals(inFileName));
- return !valid && filterFolders(inFileName);
}
+ }
- private boolean filterFolders(String fileName) {
- return ELIGBLE_FOLDERS.stream().noneMatch(fileName::startsWith);
- }
+ private boolean filterFiles(String inFileName) {
+ boolean valid = ELIGIBLE_FILES.stream().anyMatch(fileName -> fileName.equals(inFileName));
+ return !valid && filterFolders(inFileName);
+ }
- private boolean validateFileExist(UploadFileResponse uploadFileResponse, FileContentHandler contentMap, String fileName) {
+ private boolean filterFolders(String fileName) {
+ return ELIGBLE_FOLDERS.stream().noneMatch(fileName::startsWith);
+ }
- boolean containsFile = contentMap.containsFile(fileName);
- if (!containsFile) {
- uploadFileResponse.addStructureError(
- SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
- getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName)));
- }
- return containsFile;
- }
+ private boolean validateFileExist(UploadFileResponse uploadFileResponse,
+ FileContentHandler contentMap, String fileName) {
- @Override
- protected boolean updateCandidateData(String vspId, String user, CandidateService candidateService,
- VspDetails vspDetails, UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, Optional<FileContentHandler> optionalContentMap) {
- try {
- candidateService.updateCandidateUploadData(new OrchestrationTemplateCandidateData(
- ByteBuffer.wrap(uploadedFileData), ""), vspDetails.getId());
- } catch (Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
- getHandlerType().toString()), exception);
- uploadFileResponse
- .addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return true;
- }
- return false;
+ boolean containsFile = contentMap.containsFile(fileName);
+ if (!containsFile) {
+ uploadFileResponse.addStructureError(
+ SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR,
+ getErrorWithParameters(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage(), fileName)));
}
-
-
- @Override
- protected OnboardingTypesEnum getHandlerType() {
- return OnboardingTypesEnum.CSAR;
+ return containsFile;
+ }
+
+ @Override
+ protected boolean updateCandidateData(VspDetails vspDetails, byte[] uploadedFileData,
+ FileContentHandler contentMap,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService,
+ UploadFileResponse uploadFileResponse) {
+ try {
+ candidateService.updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(),
+ new OrchestrationTemplateCandidateData(ByteBuffer.wrap(uploadedFileData), "", fileSuffix,
+ networkPackageName));
+ } catch (Exception exception) {
+ logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString()), exception);
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return true;
}
+ return false;
+ }
- @Override
- protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, CandidateService candidateService) {
- return super.isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService);
- }
+ @Override
+ protected OnboardingTypesEnum getHandlerType() {
+ return OnboardingTypesEnum.CSAR;
+ }
+
+ @Override
+ protected boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData,
+ CandidateService candidateService) {
+ return super.isInvalidRawZipData(uploadFileResponse, uploadedFileData, candidateService);
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
index 3f7d18de9f..5e006a29bd 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateFileHandler.java
@@ -3,10 +3,12 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.InputStream;
+
public interface OrchestrationTemplateFileHandler {
- UploadFileResponse upload(String vspId, Version version, InputStream fileToUpload, String user,
- CandidateService candidateService, VspDetails vspDetails);
+
+ UploadFileResponse upload(VspDetails vspDetails, InputStream fileToUpload,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
index 626d941911..343c7460d9 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationTemplateZipHandler.java
@@ -15,41 +15,47 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import java.util.Optional;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
+
public class OrchestrationTemplateZipHandler extends BaseOrchestrationTemplateHandler
- implements OrchestrationTemplateFileHandler {
+ implements OrchestrationTemplateFileHandler {
- @Override
- public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData) {
- return OrchestrationUtil.getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, uploadedFileData);
- }
+ @Override
+ public Optional<FileContentHandler> getFileContentMap(UploadFileResponse uploadFileResponse,
+ byte[] uploadedFileData) {
+ return OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse, uploadedFileData);
+ }
- @Override
- protected boolean updateCandidateData(String vspId, String user, CandidateService candidateService,
- VspDetails vspDetails, UploadFileResponse uploadFileResponse,
- byte[] uploadedFileData, Optional<FileContentHandler> optionalContentMap) {
- try {
- OrchestrationTemplateCandidateData candidateData =
- new CandidateEntityBuilder(candidateService)
- .buildCandidateEntityFromZip(vspDetails, uploadedFileData, optionalContentMap.get(),
- uploadFileResponse.getErrors(), user);
- candidateService.updateCandidateUploadData(candidateData, vspDetails.getId());
- } catch (Exception exception) {
- logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
- getHandlerType().toString()),exception);
- uploadFileResponse
- .addStructureError(
- SdcCommon.UPLOAD_FILE,
- new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return true;
- }
- return false;
- }
+ @Override
+ protected boolean updateCandidateData(VspDetails vspDetails, byte[] uploadedFileData,
+ FileContentHandler contentMap,
+ String fileSuffix, String networkPackageName,
+ CandidateService candidateService,
+ UploadFileResponse uploadFileResponse) {
+ try {
+ OrchestrationTemplateCandidateData candidateData =
+ new CandidateEntityBuilder(candidateService)
+ .buildCandidateEntityFromZip(vspDetails, uploadedFileData, contentMap,
+ uploadFileResponse.getErrors());
+ candidateData.setFileSuffix(fileSuffix);
+ candidateData.setFileName(networkPackageName);
- @Override
- protected OnboardingTypesEnum getHandlerType() {
- return OnboardingTypesEnum.ZIP;
+ candidateService
+ .updateCandidateUploadData(vspDetails.getId(), vspDetails.getVersion(), candidateData);
+ } catch (Exception exception) {
+ logger.error(getErrorWithParameters(Messages.FILE_CONTENT_MAP.getErrorMessage(),
+ getHandlerType().toString()), exception);
+ uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE,
+ new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
+ return true;
}
+ return false;
+ }
+
+ @Override
+ protected OnboardingTypesEnum getHandlerType() {
+ return OnboardingTypesEnum.ZIP;
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
index 99b311e473..3c3ab81e10 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUploadFactory.java
@@ -24,8 +24,8 @@ public class OrchestrationUploadFactory {
}
- public static final OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(String filePrefix) {
- String fileExtension = filePrefix.toLowerCase();
+ public static final OrchestrationTemplateFileHandler createOrchestrationTemplateFileHandler(String fileSuffix) {
+ String fileExtension = fileSuffix.toLowerCase();
ImplementationConfiguration orchestrationTemplateFileHandler = fileHanlders.get(fileExtension);
if(Objects.isNull(orchestrationTemplateFileHandler)){
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index 2ee7b263b9..e312e7c576 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -1,8 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
-import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.model.dao.ServiceModelDao;
@@ -35,14 +32,16 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
@@ -62,13 +61,13 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues.PROCESS_NAME;
+
public class OrchestrationUtil {
public static final String ORCHESTRATION_CONFIG_NAMESPACE = "orchestration";
public static final String ORCHESTRATION_IMPL_KEY = "orchestration_impl";
-
- private VendorSoftwareProductDao vendorSoftwareProductDao;
private NicDao nicDao;
private ComponentArtifactDao componentArtifactDao;
private ProcessDao processDao;
@@ -80,8 +79,7 @@ public class OrchestrationUtil {
private CompositionDataExtractor compositionDataExtractor;
public OrchestrationUtil() {
- this (VendorSoftwareProductDaoFactory.getInstance().createInterface(),
- NicDaoFactory.getInstance().createInterface(),
+ this(NicDaoFactory.getInstance().createInterface(),
MonitoringUploadDaoFactory.getInstance().createInterface(),
ProcessDaoFactory.getInstance().createInterface(),
OrchestrationTemplateDaoFactory.getInstance().createInterface(),
@@ -93,7 +91,6 @@ public class OrchestrationUtil {
}
public OrchestrationUtil(
- VendorSoftwareProductDao vendorSoftwareProductDao,
NicDao nicDao,
ComponentArtifactDao componentArtifactDao,
ProcessDao processDao,
@@ -103,7 +100,6 @@ public class OrchestrationUtil {
ComponentDependencyModelDao componentDependencyModelDao,
CompositionEntityDataManager compositionEntityDataManager,
CompositionDataExtractor compositionDataExtractor) {
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
this.nicDao = nicDao;
this.componentArtifactDao = componentArtifactDao;
this.processDao = processDao;
@@ -116,8 +112,7 @@ public class OrchestrationUtil {
}
public static Optional<FileContentHandler> getFileContentMap(OnboardingTypesEnum type,
- UploadFileResponse
- uploadFileResponse,
+ UploadFileResponse uploadFileResponse,
byte[] uploadedFileData) {
FileContentHandler contentMap = null;
try {
@@ -133,95 +128,63 @@ public class OrchestrationUtil {
return Optional.ofNullable(contentMap);
}
- public void backupComponentsQuestionnaireBeforeDelete(String vspId, Version activeVersion,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList,
- Map<String, Collection<ProcessEntity>>
- componentProcesses,
- Map<String, ProcessEntity> processArtifact) {
- //backup VSP processes
- backupProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID,
- componentProcesses, processArtifact);
- Collection<ComponentEntity> componentsCompositionAndQuestionnaire = vendorSoftwareProductDao
- .listComponentsCompositionAndQuestionnaire(vspId,
- activeVersion);
+ public void backupComponentsQuestionnaireBeforeDelete(String vspId, Version version,
+ Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>>
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>>
+ componentMibList,
+ Map<String, Collection<ProcessEntity>>
+ componentProcesses,
+ Map<String, ProcessEntity> processArtifact) {
+
+ Collection<ComponentEntity> componentsCompositionAndQuestionnaire =
+ componentDao.listCompositionAndQuestionnaire(vspId, version);
componentsCompositionAndQuestionnaire.forEach(componentEntity ->
- backupComponentQuestionnaire(vspId, activeVersion, componentEntity, componentsQustanniare,
+ backupComponentQuestionnaire(vspId, version, componentEntity, componentsQustanniare,
componentNicsQustanniare, componentMibList, componentProcesses, processArtifact));
}
- private void backupComponentQuestionnaire(String vspId, Version activeVersion,
- ComponentEntity componentEntity,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList,
- Map<String, Collection<ProcessEntity>>
- componentProcesses,
- Map<String, ProcessEntity> processArtifact) {
+ private void backupComponentQuestionnaire(
+ String vspId, Version version,
+ ComponentEntity componentEntity,
+ Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>> componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> componentProcesses,
+ Map<String, ProcessEntity> processArtifact) {
String componentName = componentEntity.getComponentCompositionData().getName();
- backupMibData(componentsQustanniare, componentMibList, componentName, componentEntity, vspId,
- activeVersion);
- backupComponentProcessData(componentNicsQustanniare, vspId, activeVersion, componentName,
- componentEntity, componentProcesses, processArtifact);
+ componentsQustanniare.put(componentName, componentEntity.getQuestionnaireData());
+ backupMibData(vspId, version, componentEntity, componentName, componentMibList);
+ backupProcess(vspId, version, componentEntity.getId(), componentName, componentProcesses,
+ processArtifact);
+ backupNicsQuestionnaire(vspId, version, componentEntity, componentName,
+ componentNicsQustanniare);
}
- private void backupMibData(Map<String, String> componentsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList,
- String componentName, ComponentEntity componentEntity,
- String vspId, Version activeVersion) {
- componentsQustanniare.put(componentName, componentEntity.getQuestionnaireData());
- //backup mib
+ private void backupMibData(String vspId, Version version, ComponentEntity componentEntity,
+ String componentName,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
Collection<ComponentMonitoringUploadEntity> componentMib =
componentArtifactDao.listArtifacts(new
- ComponentMonitoringUploadEntity(vspId, activeVersion, componentEntity.getId(), null));
+ ComponentMonitoringUploadEntity(vspId, version, componentEntity.getId(),
+ null));
if (CollectionUtils.isNotEmpty(componentMib)) {
componentMibList.put(componentName, componentMib);
}
}
- private void backupComponentProcessData(Map<String, Map<String, String>> componentNicsQustanniare,
- String vspId, Version activeVersion, String componentName,
- ComponentEntity componentEntity,
- Map<String, Collection<ProcessEntity>> componentProcesses,
- Map<String, ProcessEntity> processArtifact) {
- Collection<NicEntity>
- nics = nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
- //backup component processes
- backupProcess(vspId, activeVersion, componentEntity.getId(), componentName,
- componentProcesses, processArtifact);
- if (CollectionUtils.isNotEmpty(nics)) {
- Map<String, String> nicsQustanniare = new HashMap<>();
- nics.forEach(nicEntity -> {
- NicEntity nic = nicDao.get(new NicEntity(vspId, activeVersion, componentEntity.getId(),
- nicEntity.getId()));
- NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, activeVersion,
- componentEntity.getId(), nicEntity.getId());
-
- nicsQustanniare
- .put(nicEntity.getNicCompositionData().getName(),
- nicQuestionnaire.getQuestionnaireData());
- });
- componentNicsQustanniare.put(componentName, nicsQustanniare);
- }
- }
-
- private void backupProcess(String vspId, Version activeVersion, String componentId,
- String componentName, Map<String,
+ private void backupProcess(String vspId, Version version, String componentId,
+ String componentName, Map<String,
Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
- Collection<ProcessEntity> processList = vendorSoftwareProductDao.listProcesses(vspId,
- activeVersion, componentId);
+ Map<String, ProcessEntity> processArtifact) {
+ Collection<ProcessEntity> processList =
+ processDao.list(new ProcessEntity(vspId, version, componentId, null));
if (!processList.isEmpty()) {
processes.put(componentName, processList);
processList.forEach(process -> {
- ProcessEntity artifact =
- processDao.get(new ProcessEntity(vspId, activeVersion, componentId, process.getId()));
+ ProcessEntity artifact = processDao
+ .getArtifact(new ProcessEntity(vspId, version, componentId, process.getId()));
if (artifact.getArtifact() != null) {
processArtifact.put(process.getId(), artifact);
}
@@ -229,29 +192,45 @@ public class OrchestrationUtil {
}
}
- public void retainComponentQuestionnaireData(String vspId, Version activeVersion,
- Map<String, String> componentsQustanniare,
- Map<String, Map<String, String>>
- componentNicsQustanniare,
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
- Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
+ private void backupNicsQuestionnaire(String vspId, Version version,
+ ComponentEntity componentEntity,
+ String componentName,
+ Map<String, Map<String, String>> componentNicsQustanniare) {
+ Collection<NicEntity>
+ nics = nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
+ if (CollectionUtils.isNotEmpty(nics)) {
+ Map<String, String> nicsQuestionnaire = new HashMap<>();
+ nics.forEach(nicEntity -> {
+ NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId, version,
+ componentEntity.getId(), nicEntity.getId());
+
+ nicsQuestionnaire.put(nicEntity.getNicCompositionData().getName(),
+ nicQuestionnaire.getQuestionnaireData());
+ });
+ componentNicsQustanniare.put(componentName, nicsQuestionnaire);
+ }
+ }
+
+ public void retainComponentQuestionnaireData(String vspId, Version version,
+ Map<String, String> componentsQustanniare,
+ Map<String, Map<String, String>>
+ componentNicsQustanniare,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList,
+ Map<String, Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
//VSP processes
- restoreProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID, processes,
- processArtifact);
- Collection<ComponentEntity>
- components = vendorSoftwareProductDao.listComponents(vspId, activeVersion);
+ restoreProcess(vspId, version, null, null, processes, processArtifact);
+ Collection<ComponentEntity> components =
+ componentDao.list(new ComponentEntity(vspId, version, null));
components.forEach(componentEntity -> {
String componentName = componentEntity.getComponentCompositionData().getName();
if (componentsQustanniare.containsKey(componentName)) {
- //Restore component questionnaire
- componentDao.updateQuestionnaireData(vspId, activeVersion,
+ componentDao.updateQuestionnaireData(vspId, version,
componentEntity.getId(),
componentsQustanniare.get(componentEntity.getComponentCompositionData()
.getName()));
- //Restore component nic questionnaire
if (componentNicsQustanniare.containsKey(componentName)) {
- restoreComponentNicQuestionnaire(vspId, activeVersion, componentName, componentEntity,
+ restoreComponentNicQuestionnaire(vspId, version, componentName, componentEntity,
componentNicsQustanniare);
}
//MIB //todo add for VES_EVENTS
@@ -259,33 +238,30 @@ public class OrchestrationUtil {
restoreComponentMibData(componentName, componentEntity, componentMibList);
}
//VFC processes
- restoreProcess(vspId, activeVersion, componentEntity.getId(), componentName, processes,
+ restoreProcess(vspId, version, componentEntity.getId(), componentName, processes,
processArtifact);
}
});
}
- private void restoreComponentNicQuestionnaire(String vspId, Version activeVersion,
+ private void restoreComponentNicQuestionnaire(String vspId, Version version,
String componentName,
ComponentEntity componentEntity,
- Map<String, Map<String, String>>
- componentNicsQustanniare) {
+ Map<String, Map<String, String>> componentNicsQustanniare) {
Map<String, String> nicsQustanniare = componentNicsQustanniare.get(componentName);
Collection<NicEntity> nics =
- nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
+ nicDao.list(new NicEntity(vspId, version, componentEntity.getId(), null));
nics.forEach(nicEntity -> {
if (nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())) {
- nicDao.updateQuestionnaireData(vspId, activeVersion,
+ nicDao.updateQuestionnaireData(vspId, version,
componentEntity.getId(), nicEntity.getId(),
nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
}
});
}
- private void restoreComponentMibData(String componentName,
- ComponentEntity componentEntity,
- Map<String, Collection<ComponentMonitoringUploadEntity>>
- componentMibList) {
+ private void restoreComponentMibData(String componentName, ComponentEntity componentEntity,
+ Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList) {
Collection<ComponentMonitoringUploadEntity> mibList = componentMibList.get(componentName);
mibList.forEach(mib -> {
mib.setComponentId(componentEntity.getId());
@@ -293,54 +269,58 @@ public class OrchestrationUtil {
});
}
- private void restoreProcess(String vspId, Version activeVersion, String componentId,
- String componentName,
- Map<String, Collection<ProcessEntity>> processes,
- Map<String, ProcessEntity> processArtifact) {
+ private void restoreProcess(String vspId, Version version, String componentId,
+ String componentName,
+ Map<String, Collection<ProcessEntity>> processes,
+ Map<String, ProcessEntity> processArtifact) {
if (processes.containsKey(componentName)) {
Collection<ProcessEntity> processList = processes.get(componentName);
processList.forEach(process -> {
- //Reatin VFC process
- if (!GENERAL_COMPONENT_ID.equals(componentId)
- && processArtifact.containsKey(process.getId())) {
+ process.setComponentId(componentId);
+ UniqueValueUtil.createUniqueValue(PROCESS_NAME, vspId, version.getId(), componentId,
+ process.getName());
+ processDao.create(process);
+ if (processArtifact.containsKey(process.getId())) {
ProcessEntity artifact = processArtifact.get(process.getId());
- artifact.setComponentId(componentId);
- UniqueValueUtil.createUniqueValue(PROCESS_NAME, vspId, activeVersion.toString(),
- componentId, process.getName());
- vendorSoftwareProductDao.createProcess(artifact);
+ processDao.uploadArtifact(artifact);
}
});
}
}
public void deleteUploadDataAndContent(String vspId, Version version) {
- //fixme change this when more tables are zusammenized
- vendorSoftwareProductDao.deleteUploadData(vspId, version);
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface()
+ .delete(new VspDetails(vspId, version));
}
- public void saveUploadData(String vspId, Version activeVersion,
- InputStream uploadedFileData,
- FileContentHandler fileContentMap, HeatStructureTree tree) {
+ public void saveUploadData(VspDetails vspDetails,
+ OrchestrationTemplateCandidateData candidateData,
+ InputStream uploadedFileData,
+ FileContentHandler fileContentMap, HeatStructureTree tree) {
Map<String, Object> manifestAsMap =
fileContentMap.containsFile(SdcCommon.MANIFEST_NAME)
? (Map<String, Object>) JsonUtil.json2Object(fileContentMap.getFileContent(
SdcCommon.MANIFEST_NAME), Map.class)
: new HashMap<>();
- UploadData uploadData = new UploadData();
+ OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity();
+ uploadData.setFileSuffix(candidateData.getFileSuffix());
+ uploadData.setFileName(candidateData.getFileName());
uploadData.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(uploadedFileData)));
uploadData.setValidationDataStructure(new ValidationStructureList(tree));
uploadData.setPackageName(Objects.isNull(manifestAsMap.get("name")) ? null :
(String) manifestAsMap.get("name"));
uploadData.setPackageVersion(Objects.isNull(manifestAsMap.get("version")) ? null :
(String) manifestAsMap.get("version"));
- orchestrationTemplateDataDao.updateOrchestrationTemplateData(vspId, uploadData);
+ orchestrationTemplateDataDao.update(vspDetails.getId(), vspDetails.getVersion(), uploadData);
+
+ VspMergeDaoFactory.getInstance().createInterface()
+ .updateVspModelId(vspDetails.getId(), vspDetails.getVersion());
}
- public void saveServiceModel(String vspId,
- Version version,
- ToscaServiceModel serviceModelToExtract,
- ToscaServiceModel serviceModelToStore) {
+ public void saveServiceModel(String vspId, Version version,
+ ToscaServiceModel serviceModelToExtract,
+ ToscaServiceModel serviceModelToStore) {
if (serviceModelToExtract != null) {
serviceModelDao.storeServiceModel(vspId, version, serviceModelToStore);
//Extracting the compostion data from the output service model of the first phase of
@@ -358,15 +338,14 @@ public class OrchestrationUtil {
return heatTreeManager.getTree();
}
- public void updateVspComponentDependencies(String vspId, Version activeVersion,
- Map<String, String>
- vspComponentIdNameInfoBeforeProcess) {
- Map<String, String> updatedVspComponentNameIdInfo = getVspComponentNameIdInfo(vspId,
- activeVersion);
+ public void updateVspComponentDependencies(String vspId, Version version,
+ Map<String, String> vspComponentIdNameInfoBeforeProcess) {
+ Map<String, String> updatedVspComponentNameIdInfo = getVspComponentNameIdInfo(vspId, version);
if (MapUtils.isNotEmpty(updatedVspComponentNameIdInfo)) {
Set<String> updatedVspComponentNames = updatedVspComponentNameIdInfo.keySet();
Collection<ComponentDependencyModelEntity> componentDependencies =
- vendorSoftwareProductDao.listComponentDependencies(vspId, activeVersion);
+ componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId,
+ version, null));
if (CollectionUtils.isNotEmpty(componentDependencies)) {
updateComponentDependency(vspComponentIdNameInfoBeforeProcess, componentDependencies,
updatedVspComponentNames, updatedVspComponentNameIdInfo);
@@ -374,7 +353,6 @@ public class OrchestrationUtil {
}
}
-
private void updateComponentDependency(Map<String, String> vspComponentIdNameInfoBeforeProcess,
Collection<ComponentDependencyModelEntity>
componentDependencies,
@@ -398,14 +376,14 @@ public class OrchestrationUtil {
}
}
- public Map<String, String> getVspComponentIdNameInfo(String vspId, Version activeVersion) {
+ public Map<String, String> getVspComponentIdNameInfo(String vspId, Version version) {
Collection<ComponentEntity> updatedVspComponents =
- vendorSoftwareProductDao.listComponents(vspId, activeVersion);
+ componentDao.list(new ComponentEntity(vspId, version, null));
Map<String, String> vspComponentIdNameMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
vspComponentIdNameMap = updatedVspComponents.stream()
.filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
- .collect(Collectors.toMap(componentEntity -> componentEntity.getId(),
+ .collect(Collectors.toMap(ComponentEntity::getId,
componentEntity -> componentEntity.getComponentCompositionData().getName()));
}
@@ -413,15 +391,16 @@ public class OrchestrationUtil {
}
private Map<String, String> getVspComponentNameIdInfo(String vspId,
- Version activeVersion) {
+ Version version) {
Collection<ComponentEntity> updatedVspComponents =
- vendorSoftwareProductDao.listComponents(vspId, activeVersion);
+ componentDao.list(new ComponentEntity(vspId, version, null));
Map<String, String> vspComponentNameIdMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(updatedVspComponents)) {
vspComponentNameIdMap = updatedVspComponents.stream()
.filter(componentEntity -> componentEntity.getComponentCompositionData() != null)
- .collect(Collectors.toMap(componentEntity -> componentEntity
- .getComponentCompositionData().getName(), componentEntity -> componentEntity.getId()));
+ .collect(Collectors
+ .toMap(componentEntity -> componentEntity.getComponentCompositionData().getName(),
+ ComponentEntity::getId));
}
return vspComponentNameIdMap;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java
index 0d204ef2c0..cf04aadcfc 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/CSARConstants.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar;
import com.google.common.collect.ImmutableSet;
+
import static com.google.common.collect.ImmutableSet.of;
public class CSARConstants {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java
index d88d883e67..c0da130a9f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/csar/OnboardingManifest.java
@@ -7,12 +7,22 @@ import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters;
-import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.*;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.METADATA_MF_ATTRIBUTE;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
+import static org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.CSARConstants.SOURCE_MF_ATTRIBUTE;
public class OnboardingManifest {
private static final Logger logger = LoggerFactory.getLogger(OnboardingManifest.class);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
index 516d85c2a7..6200b287a1 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationProcessFactory.java
@@ -27,13 +27,13 @@ public class OrchestrationProcessFactory {
}
- public static Optional<OrchestrationTemplateProcessHandler> getInstance(String filePrefix) {
- if (filePrefix == null) {
+ public static Optional<OrchestrationTemplateProcessHandler> getInstance(String fileSuffix) {
+ if (fileSuffix == null) {
return Optional.empty();
}
- filePrefix = filePrefix.toLowerCase().trim();
- OnboardingTypesEnum onboardingTypesEnum = OnboardingTypesEnum.getOnboardingTypesEnum(filePrefix);
+ fileSuffix = fileSuffix.toLowerCase().trim();
+ OnboardingTypesEnum onboardingTypesEnum = OnboardingTypesEnum.getOnboardingTypesEnum(fileSuffix);
if (onboardingTypesEnum == null) {
return Optional.empty();
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index d217c31f65..b0e1e17f57 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -1,7 +1,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.converter.ToscaConverter;
import org.openecomp.core.impl.ToscaConverterImpl;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
@@ -26,7 +25,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationU
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
-import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -37,35 +35,35 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
-public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTemplateProcessHandler {
-
- private static final Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
- private CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface();
+public class OrchestrationTemplateProcessCsarHandler
+ implements OrchestrationTemplateProcessHandler {
+ private static final Logger LOGGER =
+ LoggerFactory.getLogger(OrchestrationTemplateProcessCsarHandler.class);
+ private CandidateService candidateService =
+ CandidateServiceFactory.getInstance().createInterface();
ToscaTreeManager toscaTreeManager = new ToscaTreeManager();
@Override
public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData,
- String user) {
- String vspId = vspDetails.getId();
- Version version = vspDetails.getVersion();
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CSAR_VALIDATION_STARTED + vspId);
- OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
+ OrchestrationTemplateCandidateData candidateData) {
+ LOGGER.audit(
+ AuditMessages.AUDIT_MSG + AuditMessages.CSAR_VALIDATION_STARTED + vspDetails.getId());
+
UploadFileResponse uploadFileResponse = new UploadFileResponse();
- Optional<FileContentHandler> fileContent =
- OrchestrationUtil
- .getFileContentMap(
- OnboardingTypesEnum.CSAR, uploadFileResponse, candidateData.getContentData().array());
+ Optional<FileContentHandler> fileContent = OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.CSAR, uploadFileResponse,
+ candidateData.getContentData().array());
- if(fileContent.isPresent()){
+ OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
+ if (fileContent.isPresent()) {
try {
FileContentHandler fileContentHandler = fileContent.get();
- processCsar(vspId, version, fileContentHandler, candidateData, response);
- } catch (CoreException e){
- logger.error(e.getMessage());
+ processCsar(vspDetails, fileContentHandler, candidateData, response);
+ } catch (CoreException e) {
+ LOGGER.error(e.getMessage());
response.addErrorMessageToMap(e.code().id(), e.code().message(),ErrorLevel.ERROR);
} catch (IOException ioe) {
- logger.error(ioe.getMessage());
+ LOGGER.error(ioe.getMessage());
ErrorCode errorCode = new GeneralErrorBuilder(ioe.getMessage()).build();
response.addErrorMessageToMap(errorCode.id(), errorCode.message(),ErrorLevel.ERROR);
}
@@ -77,13 +75,13 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
return response;
}
- private void processCsar(String vspId, Version version,
+ private void processCsar(VspDetails vspDetails,
FileContentHandler fileContentHandler,
OrchestrationTemplateCandidateData candidateData,
OrchestrationTemplateActionResponse response) throws IOException {
response.setFileNames(new ArrayList<>(fileContentHandler.getFileList()));
- Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler, response);
- if(!isValid(errors)){
+ Map<String, List<ErrorMessage>> errors = validateCsar(fileContentHandler);
+ if (!isValid(errors)) {
return;
}
@@ -95,32 +93,31 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
Map<String, ProcessEntity> processArtifact = new HashMap<>();
OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
- orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspId,
- version, componentsQuestionnaire,
+ orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspDetails.getId(),
+ vspDetails.getVersion(), componentsQuestionnaire,
componentNicsQuestionnaire, componentMibList, processes, processArtifact);
Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
- .fetchZipFileByteArrayInputStream(vspId, candidateData, null, OnboardingTypesEnum.CSAR, errors);
+ .fetchZipFileByteArrayInputStream(vspDetails.getId(), candidateData, null,
+ OnboardingTypesEnum.CSAR, errors);
- orchestrationUtil.deleteUploadDataAndContent(vspId, version);
- orchestrationUtil.saveUploadData(
- vspId, version, zipByteArrayInputStream.get(), fileContentHandler, tree);
+ orchestrationUtil.deleteUploadDataAndContent(vspDetails.getId(), vspDetails.getVersion());
+ orchestrationUtil.saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(),
+ fileContentHandler, tree);
ToscaServiceModel toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
- orchestrationUtil.saveServiceModel(vspId, version, toscaServiceModel, toscaServiceModel);
+ orchestrationUtil.saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel,
+ toscaServiceModel);
}
- private void addFiles(FileContentHandler fileContentHandler){
- for(Map.Entry<String, byte[]> fileEntry : fileContentHandler.getFiles().entrySet()){
+ private void addFiles(FileContentHandler fileContentHandler) {
+ for (Map.Entry<String, byte[]> fileEntry : fileContentHandler.getFiles().entrySet()) {
toscaTreeManager.addFile(fileEntry.getKey(), fileEntry.getValue());
}
}
- private Map<String, List<ErrorMessage>> validateCsar(FileContentHandler fileContentHandler,
- OrchestrationTemplateActionResponse response){
-
-
+ private Map<String, List<ErrorMessage>> validateCsar(FileContentHandler fileContentHandler) {
Map<String, List<ErrorMessage>> errors = new HashMap<>();
addFiles(fileContentHandler);
toscaTreeManager.createTree();
@@ -129,7 +126,7 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
return errors;
}
- private boolean isValid(Map<String, List<ErrorMessage>> errors){
+ private boolean isValid(Map<String, List<ErrorMessage>> errors) {
return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, errors));
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
index 8b513b4347..1db48a5cc7 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessHandler.java
@@ -6,7 +6,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
public interface OrchestrationTemplateProcessHandler {
+
OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData candidateData,
- String user);
+ OrchestrationTemplateCandidateData candidateData);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
index 85ac26223f..da5cb01c79 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
@@ -1,19 +1,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
-import static org.openecomp.sdc.logging.messages.AuditMessages.HEAT_VALIDATION_ERROR;
-
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.util.MessageContainerUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activityLog.ActivityLogManagerFactory;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
@@ -31,18 +24,13 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCan
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
import java.io.ByteArrayInputStream;
import java.util.Collection;
@@ -51,41 +39,29 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
+import static org.openecomp.sdc.logging.messages.AuditMessages.HEAT_VALIDATION_ERROR;
+
public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemplateProcessHandler {
- Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class);
+ private Logger logger = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class);
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private CandidateService candidateService =
CandidateServiceFactory.getInstance().createInterface();
- private ServiceModelDao serviceModelDao = ServiceModelDaoFactory.getInstance().createInterface();
- private CompositionEntityDataManager compositionEntityDataManager =
- CompositionEntityDataManagerFactory.getInstance().createInterface();
- private CompositionDataExtractor compositionDataExtractor =
- CompositionDataExtractorFactory.getInstance().createInterface();
- private ActivityLogManager activityLogManager =
- ActivityLogManagerFactory.getInstance().createInterface();
-
-
- public OrchestrationTemplateProcessZipHandler(){}
+ @Override
public OrchestrationTemplateActionResponse process(VspDetails vspDetails,
- OrchestrationTemplateCandidateData
- candidateData,
- String user) {
+ OrchestrationTemplateCandidateData candidateData) {
String vspId = vspDetails.getId();
Version version = vspDetails.getVersion();
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_STARTED
- + vspId);
+ logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_STARTED + vspId);
OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
UploadFileResponse uploadFileResponse = new UploadFileResponse();
- Optional<FileContentHandler> fileContent =
- OrchestrationUtil
- .getFileContentMap(
- OnboardingTypesEnum.ZIP, uploadFileResponse,
- candidateData.getContentData().array());
+ Optional<FileContentHandler> fileContent = OrchestrationUtil
+ .getFileContentMap(OnboardingTypesEnum.ZIP, uploadFileResponse,
+ candidateData.getContentData().array());
if (!fileContent.isPresent()) {
response.addStructureErrors(uploadFileResponse.getErrors());
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId,
HEAT_VALIDATION_ERROR));
return response;
}
@@ -100,7 +76,7 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR);
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId,
HEAT_VALIDATION_ERROR));
return response;
}
@@ -113,8 +89,8 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
.fetchZipFileByteArrayInputStream(
vspId, candidateData, manifest, OnboardingTypesEnum.ZIP, uploadErrors);
if (!zipByteArrayInputStream.isPresent()) {
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
- HEAT_VALIDATION_ERROR));
+ response.getErrors().values()
+ .forEach(errorList -> printAuditForErrors(errorList, vspId, HEAT_VALIDATION_ERROR));
return response;
}
@@ -129,18 +105,19 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
Map<String, String> vspComponentIdNameInfoBeforeProcess =
orchestrationUtil.getVspComponentIdNameInfo(vspId, version);
- orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspId,
- version, componentsQuestionnaire,
- componentNicsQuestionnaire, componentMibList, processes, processArtifact);
+ orchestrationUtil
+ .backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQuestionnaire,
+ componentNicsQuestionnaire, componentMibList, processes, processArtifact);
orchestrationUtil.deleteUploadDataAndContent(vspId, version);
- orchestrationUtil.saveUploadData(vspId, version, zipByteArrayInputStream.get(), fileContentMap,
- tree);
+ orchestrationUtil
+ .saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(), fileContentMap,
+ tree);
- response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList,vspId,
+ response.getErrors().values().forEach(errorList -> printAuditForErrors(errorList, vspId,
HEAT_VALIDATION_ERROR));
- if ( MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR,
- response.getErrors()))) {
+ if (MapUtils
+ .isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, response.getErrors()))) {
logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_VALIDATION_COMPLETED + vspId);
}
@@ -150,20 +127,17 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
- orchestrationUtil.saveServiceModel(vspId, version, translatorOutput
- .getNonUnifiedToscaServiceModel(), toscaServiceModel);
+ orchestrationUtil
+ .saveServiceModel(vspId, version, translatorOutput.getNonUnifiedToscaServiceModel(),
+ toscaServiceModel);
orchestrationUtil.retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire,
componentNicsQuestionnaire, componentMibList, processes, processArtifact);
orchestrationUtil.updateVspComponentDependencies(vspId, version,
vspComponentIdNameInfoBeforeProcess);
+
logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_COMPLETED + vspId);
uploadFileResponse.addStructureErrors(uploadErrors);
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vspId, String.valueOf(version.getMajor() + 1),
- ActivityType.UPLOAD_HEAT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
-
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
return response;
}
@@ -182,8 +156,8 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
errorList.forEach(errorMessage -> {
if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
- logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
- vspId));
+ logger.audit(
+ AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(), vspId));
}
});
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java
deleted file mode 100644
index 8cb367367c..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/FileDataStructureDto.java
+++ /dev/null
@@ -1,69 +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.vendorsoftwareproduct.types;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Avrahamg
- * @since November 07, 2016
- */
-public class FileDataStructureDto {
- private List<Module> modules = new ArrayList<>();
- private List<String> unassigned = new ArrayList<>();
- private List<String> artifacts = new ArrayList<>();
- private List<String> nested = new ArrayList<>();
-
- public List<Module> getModules() {
- return modules;
- }
-
- public void setModules(List<Module> modules) {
- this.modules = modules;
- }
-
- public List<String> getUnassigned() {
- return unassigned;
- }
-
- public void setUnassigned(List<String> unassigned) {
- this.unassigned = unassigned;
- }
-
- public List<String> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(List<String> artifacts) {
- this.artifacts = artifacts;
- }
-
- public List<String> getNested() {
- return nested;
- }
-
- public void setNested(List<String> nested) {
- this.nested = nested;
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java
deleted file mode 100644
index c30978266f..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/types/GetFileDataStructureResponseDTO.java
+++ /dev/null
@@ -1,69 +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.vendorsoftwareproduct.types;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.Module;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Avrahamg
- * @since November 07, 2016
- */
-public class GetFileDataStructureResponseDTO {
- private List<Module> modules = new ArrayList<>();
- private List<String> unassigned = new ArrayList<>();
- private List<String> artifacts = new ArrayList<>();
- private List<String> nested = new ArrayList<>();
-
- public List<Module> getModules() {
- return modules;
- }
-
- public void setModules(List<Module> modules) {
- this.modules = modules;
- }
-
- public List<String> getUnassigned() {
- return unassigned;
- }
-
- public void setUnassigned(List<String> unassigned) {
- this.unassigned = unassigned;
- }
-
- public List<String> getArtifacts() {
- return artifacts;
- }
-
- public void setArtifacts(List<String> artifacts) {
- this.artifacts = artifacts;
- }
-
- public List<String> getNested() {
- return nested;
- }
-
- public void setNested(List<String> nested) {
- this.nested = nested;
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
index ab7a70b6a7..3df06ba8eb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
@@ -1,33 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED;
-
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
public class ComputeTest {
/*private static final String USER1 = "componentsTestUser1";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
index 45ba4fb434..77c81111a5 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
@@ -1,33 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION;
-import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID;
-import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST;
-import static org.openecomp.sdc.versioning.errors.VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND;
-
-import org.openecomp.core.utilities.CommonMethods;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.VendorSoftwareProductManagerImpl;
-
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
public class DeploymentFlavorTest {
/*private static final String USER1 = "deploymentTestUser1";
private static final String USER2 = "deploymentTestUser2";
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
index 5dcb7f9b62..d78f4045b6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ImagesTest.java
@@ -21,50 +21,48 @@ import static org.mockito.Mockito.verify;
public class ImagesTest {
- private static String VSP_ID = "VSP_ID";
- private static String COMP_ID = "COMP_ID";
- private static String ID = "ID";
- private static String USER = "USER";
- public static final Version VERSION01 = new Version(0, 1);
+ private static String VSP_ID = "VSP_ID";
+ private static String COMP_ID = "COMP_ID";
+ private static String ID = "ID";
+ public static final Version VERSION01 = new Version("version_id");
- @Mock
- private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ @Mock
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
- @Mock
- private CompositionEntityDataManager compositionEntityDataManager;
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManager;
- @InjectMocks
- @Spy
- private ImageManagerImpl imageManager;
+ @InjectMocks
+ @Spy
+ private ImageManagerImpl imageManager;
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
- @Test
- public void createImage()
- {
- ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
- doReturn(true).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
+ @Test
+ public void createImage() {
+ ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
+ doReturn(true).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
- imageManager.createImage(imageEntity, USER);
- verify(compositionEntityDataManager).createImage(imageEntity);
- }
+ imageManager.createImage(imageEntity);
+ verify(compositionEntityDataManager).createImage(imageEntity);
+ }
- @Test
- public void createImageHeat()
- {
- ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
- doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
-
- try {
- imageManager.createImage(imageEntity, USER);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
+ @Test
+ public void createImageHeat() {
+ ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION01, COMP_ID, ID);
+ doReturn(false).when(vendorSoftwareProductInfoDao).isManual(anyObject(), anyObject());
+
+ try {
+ imageManager.createImage(imageEntity);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(),
+ VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
+ }
/*private static final String USER1 = "imageTestUser1";
private static final String USER2 = "imageTestUser2";
private static final Version VERSION01 = new Version(0, 1);
@@ -93,40 +91,40 @@ public class ImagesTest {
vsp1 = vendorSoftwareProductManager.createNewVsp(VSPCommon
.createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp1", "vendorName",
"vlm1Id", "icon", "category", "subCategory", "123", null,
- VSPCommon.OnboardingMethod.Manual.name()), USER1
+ VSPCommon.OnboardingMethod.Manual.name())1
);
vsp1Id = vsp1.getId();
VspDetails vsp2 = vendorSoftwareProductManager.createNewVsp(VSPCommon
.createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp2", "vendorName",
"vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon.OnboardingMethod.
- Manual.name()), USER1);
+ Manual.name())1);
vsp2Id = vsp2.getId();
VspDetails vsp3 = vendorSoftwareProductManager.createNewVsp(VSPCommon
.createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp3",
"vendorName",
"vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon
- .OnboardingMethod.HEAT.name()), USER1);
+ .OnboardingMethod.HEAT.name())1);
vsp3Id = vsp3.getId();
ComponentEntity comp = new ComponentEntity();
comp.setVspId(vsp2Id);
comp.setCompositionData(comp1);
- ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp, USER1);
+ ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp1);
comp1Id = createdComp.getId();
}
@Test
public void testListImagesNonExistingVspId_negative() {
- testList_negative("non existing vsp id", null, image1Id, USER1,
+ testList_negative("non existing vsp id", null, image1Id1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@Test
public void testListImagesNonExistingVfcId_negative() {
- testList_negative(vsp1Id, VERSION01, "444", USER1,
+ testList_negative(vsp1Id, VERSION01, "444"1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 444 does not exist for Vendor Software Product "
+ "with id "+vsp1Id+ " and version "+VERSION01);
@@ -137,20 +135,20 @@ public class ImagesTest {
createImageEntity("media-vsrx-vmdisk-15.1X49-D40.6.aki", "aki");
createImageEntity("riverbed-15.1X49-D40.6.vdi", "vdi");
final Collection<ImageEntity> imageEntities =
- vendorSoftwareProductManager.listImages(vsp2Id, VERSION01, comp1Id, USER1);
+ vendorSoftwareProductManager.listImages(vsp2Id, VERSION01, comp1Id1);
System.out.println("size::"+imageEntities.size());
}
@Test
public void testCreateNonExistingVspId_negative() {
- testCreate_negative(new ImageEntity("non existing vsp id", null, null, null), USER1,
+ testCreate_negative(new ImageEntity("non existing vsp id", null, null, null)1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist.");
}
@Test
public void testCreateNonExistingVfcId_negative() {
- testCreate_negative(new ImageEntity(vsp1Id, VERSION01, "222", null), USER1,
+ testCreate_negative(new ImageEntity(vsp1Id, VERSION01, "222", null)1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 222 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -158,8 +156,8 @@ public class ImagesTest {
@Test(dependsOnMethods = "testUpdateNonExistingImageId_negative")
public void testCreateOnAvailableVsp_negative() {
- vendorSoftwareProductManager.checkin(vsp1Id, USER1);
- testCreate_negative(new ImageEntity(vsp1Id, null, null, null), USER1,
+ vendorSoftwareProductManager.checkin(vsp1Id1);
+ testCreate_negative(new ImageEntity(vsp1Id, null, null, null)1,
VersioningErrorCodes.EDIT_ON_UNLOCKED_ENTITY,
"Can not edit versionable entity VendorSoftwareProduct with id "+vsp1Id+ " since it is not"
+ " checked out.");
@@ -167,8 +165,8 @@ public class ImagesTest {
@Test(dependsOnMethods = "testCreateOnAvailableVsp_negative")
public void testCreateOnVspOtherUser_negative() {
- vendorSoftwareProductManager.checkout(vsp1Id, USER1);
- testCreate_negative(new ImageEntity(vsp1Id, null, null, null), USER2,
+ vendorSoftwareProductManager.checkout(vsp1Id1);
+ testCreate_negative(new ImageEntity(vsp1Id, null, null, null)2,
VersioningErrorCodes.EDIT_ON_ENTITY_LOCKED_BY_OTHER_USER,
"Versionable entity VendorSoftwareProduct with id " +vsp1Id+
" can not be edited since it is locked by other user "+ USER1+ ".");
@@ -180,11 +178,11 @@ public class ImagesTest {
ComponentEntity comp = new ComponentEntity();
comp.setVspId(vsp1Id);
comp.setCompositionData(comp1);
- ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp, USER1);
+ ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(comp1);
String compId = createdComp.getId();
- vendorSoftwareProductManager.checkin(vsp1Id, USER1);
- vendorSoftwareProductManager.checkout(vsp1Id, USER1);
+ vendorSoftwareProductManager.checkin(vsp1Id1);
+ vendorSoftwareProductManager.checkout(vsp1Id1);
for(int i = 1; i<=3; i++) {
ImageEntity imageEntity = new ImageEntity();
@@ -197,17 +195,17 @@ public class ImagesTest {
//image.setFormat("aki");
//image.setMd5("233343DDDD");
imageEntity.setImageCompositionData(image);
- ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity, USER1);
+ ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity1);
}
Collection<ImageEntity> imageEntities =
- vendorSoftwareProductManager.listImages(vsp1Id, null, compId, USER1);
+ vendorSoftwareProductManager.listImages(vsp1Id, null, compId1);
Assert.assertEquals(imageEntities.size(), 3);
- vendorSoftwareProductManager.undoCheckout(vsp1Id, USER1);
+ vendorSoftwareProductManager.undoCheckout(vsp1Id1);
- imageEntities = vendorSoftwareProductManager.listImages(vsp1Id, null, compId, USER1);
+ imageEntities = vendorSoftwareProductManager.listImages(vsp1Id, null, compId1);
Assert.assertEquals(imageEntities.size(), 0);
}
@@ -217,7 +215,7 @@ public class ImagesTest {
final ErrorCode addImageNotSupportedHeatOnboardMethodErrorBuilder =
NotSupportedHeatOnboardMethodErrorBuilder
.getAddImageNotSupportedHeatOnboardMethodErrorBuilder();
- testCreate_negative(new ImageEntity(vsp3Id, null, null, null), USER1,
+ testCreate_negative(new ImageEntity(vsp3Id, null, null, null)1,
addImageNotSupportedHeatOnboardMethodErrorBuilder.id(),
addImageNotSupportedHeatOnboardMethodErrorBuilder.message()
);
@@ -252,19 +250,19 @@ public class ImagesTest {
@Test
public void testGet() {
ImageEntity createdImage = createImageEntity("read-riverbed-WX-IMG-9.2.0.qcow2", "qcow2");
- testGet(vsp2Id, VERSION01, comp1Id, createdImage.getId(), USER1, createdImage);
+ testGet(vsp2Id, VERSION01, comp1Id, createdImage.getId()1, createdImage);
}
@Test
public void testGetNonExistingVspId_negative() {
- testGet_negative("non existing vsp id", null, null, image1Id, USER1,
+ testGet_negative("non existing vsp id", null, null, image1Id1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@Test
public void testGetNonExistingVfcId_negative() {
- testGet_negative(vsp1Id, VERSION01, "111", null, USER1,
+ testGet_negative(vsp1Id, VERSION01, "111", null1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -274,7 +272,7 @@ public class ImagesTest {
public void testUpdateNonExistingVspId_negative() {
ImageEntity imageEntity = new ImageEntity("non existing vsp id", null, null, image1Id);
- testUpdate_negative(imageEntity, USER1,
+ testUpdate_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@@ -283,7 +281,7 @@ public class ImagesTest {
public void testUpdateNonExistingVfcId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp1Id, VERSION01, "111", null);
- testUpdate_negative(imageEntity, USER1,
+ testUpdate_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -293,7 +291,7 @@ public class ImagesTest {
public void testUpdateNonExistingImageId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp2Id, VERSION01, comp1Id, "222");
- testUpdate_negative(imageEntity, USER1,
+ testUpdate_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component Image with Id 222 does not exist for Vendor " +
"Software Product with id "+vsp2Id+ " and version "+VERSION01 );
@@ -308,7 +306,7 @@ public class ImagesTest {
//imageCompositionData.setVersion("10.0");
imageCompositionData.setDescription("updated image");
- vendorSoftwareProductManager.updateImage(imageEntity, USER1);
+ vendorSoftwareProductManager.updateImage(imageEntity1);
testGet(vsp2Id, VERSION01, comp1Id, imageEntity.getId(),USER1, imageEntity );
image2Id = imageEntity.getId();
@@ -318,7 +316,7 @@ public class ImagesTest {
public void testUpdateNegative_UniqueName() {
final CompositionEntityResponse<Image> image =
vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id,
- image2Id, USER1);
+ image2Id1);
final Image data = image.getData();
final Image imageCompositionData = data;
@@ -326,7 +324,7 @@ public class ImagesTest {
ImageEntity entity = new ImageEntity(vsp2Id, VERSION01, comp1Id, image2Id );
entity.setImageCompositionData(imageCompositionData);
- testUpdate_negative(entity, USER1, ImageErrorBuilder.getDuplicateImageNameErrorBuilder(
+ testUpdate_negative(entity1, ImageErrorBuilder.getDuplicateImageNameErrorBuilder(
"riverbed-WX-IMG-9.2.0.qcow2", comp1Id).id()
,ImageErrorBuilder.getDuplicateImageNameErrorBuilder("riverbed-WX-IMG-9.2.0.qcow2", comp1Id)
.message() );
@@ -335,13 +333,13 @@ public class ImagesTest {
@Test(dependsOnMethods = "testUpdateNegative_UniqueName")
public void testDeleteImage() {
CompositionEntityResponse<Image> image =
- vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id, image2Id, USER1);
+ vendorSoftwareProductManager.getImage(vsp2Id, VERSION01, comp1Id, image2Id1);
Assert.assertNotNull(image.getData());
- vendorSoftwareProductManager.deleteImage(vsp2Id, comp1Id, image2Id, USER1);
+ vendorSoftwareProductManager.deleteImage(vsp2Id, comp1Id, image2Id1);
- testGet_negative(vsp2Id, VERSION01, comp1Id, image2Id, USER1,
+ testGet_negative(vsp2Id, VERSION01, comp1Id, image2Id1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component Image with Id "+image2Id+ " does not exist for " +
"Vendor Software Product with id "+vsp2Id+ " and version "+VERSION01 );
@@ -352,7 +350,7 @@ public class ImagesTest {
public void testDeleteNonExistingVspId_negative() {
ImageEntity imageEntity = new ImageEntity("non existing vsp id", null, null, image1Id);
- testDelete_negative(imageEntity, USER1,
+ testDelete_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST,
"Versionable entity VendorSoftwareProduct with id non existing vsp id does not exist." );
}
@@ -361,7 +359,7 @@ public class ImagesTest {
public void testDeleteNonExistingVfcId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp1Id, VERSION01, "111", null);
- testDelete_negative(imageEntity, USER1,
+ testDelete_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component with Id 111 does not exist for Vendor Software Product "
+ "with id "+vsp1Id + " and version "+VERSION01);
@@ -371,7 +369,7 @@ public class ImagesTest {
public void testDeleteNonExistingImageId_negative() {
ImageEntity imageEntity = new ImageEntity(vsp2Id, VERSION01, comp1Id, "222");
- testDelete_negative(imageEntity, USER1,
+ testDelete_negative(imageEntity1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND,
"Vendor Software Product Component Image with Id 222 does not exist for Vendor " +
"Software Product with id "+vsp2Id+ " and version "+VERSION01 );
@@ -386,7 +384,7 @@ public class ImagesTest {
final QuestionnaireResponse imageQuestionnaire =
vendorSoftwareProductManager.getImageQuestionnaire(vsp2Id, VERSION01, comp1Id,
- imageEntity.getId(), USER1);
+ imageEntity.getId()1);
String imageDetails = imageQuestionnaire.getData();
Assert.assertEquals("vdi", JsonUtil.json2Object(imageDetails, ImageDetails.class).getFormat());
@@ -422,7 +420,7 @@ public class ImagesTest {
// image.setMd5("233343DDDD");
imageEntity.setImageCompositionData(image);
- ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity, USER1);
+ ImageEntity createdImage = vendorSoftwareProductManager.createImage(imageEntity1);
image1Id = createdImage.getId();
return createdImage;
}
@@ -430,7 +428,7 @@ public class ImagesTest {
private void testGet(String vspId, Version version, String componentId, String imageId, String
user, ImageEntity expected) {
CompositionEntityResponse<Image>
- response = vendorSoftwareProductManager.getImage(vspId, null, componentId, imageId, user);
+ response = vendorSoftwareProductManager.getImage(vspId, null, componentId, imageId);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(expected.getImageCompositionData().getFileName(), response.getData().
getFileName());
@@ -442,7 +440,7 @@ public class ImagesTest {
private void testCreate_negative(ImageEntity image, String user,
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.createImage(image, user);
+ vendorSoftwareProductManager.createImage(image);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -454,7 +452,7 @@ public class ImagesTest {
String user,
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.getImage(vspId, version, componentId, imageId, user);
+ vendorSoftwareProductManager.getImage(vspId, version, componentId, imageId);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -465,7 +463,7 @@ public class ImagesTest {
private void testList_negative(String vspId, Version version, String componentId, String user,
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.listImages(vspId, version, componentId, user);
+ vendorSoftwareProductManager.listImages(vspId, version, componentId);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -478,7 +476,7 @@ public class ImagesTest {
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.updateImage(imageEntity, user);
+ vendorSoftwareProductManager.updateImage(imageEntity);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
@@ -491,7 +489,7 @@ public class ImagesTest {
String expectedErrorCode, String expectedErrorMsg) {
try {
- vendorSoftwareProductManager.updateImage(imageEntity, user);
+ vendorSoftwareProductManager.updateImage(imageEntity);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java
index b544d13ec7..e8e0f2c92b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/QuestionnaireDataServiceTest.java
@@ -30,12 +30,10 @@ import org.mockito.MockitoAnnotations;
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.validation.util.MessageContainerUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerImpl;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactData;
import org.openecomp.sdc.vendorsoftwareproduct.questionnaire.QuestionnaireDataService;
@@ -54,16 +52,11 @@ import java.io.InputStream;
import java.util.List;
import java.util.Objects;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Matchers.eq;
-
public class QuestionnaireDataServiceTest {
public static final Version VERSION = new Version(0, 1);
private QuestionnaireDataService questionnaireDataService;// = new QuestionnaireDataServiceImpl();
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
private CandidateService candidateServiceMock;
@Mock
private HealingManager healingManagerMock;
@@ -73,8 +66,6 @@ public class QuestionnaireDataServiceTest {
private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
@Mock
private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private ActivityLogManager activityLogManagerMock;
@Captor
private ArgumentCaptor<ActivityLogEntity> activityLogEntityArg;
@@ -82,7 +73,7 @@ public class QuestionnaireDataServiceTest {
@InjectMocks
private OrchestrationTemplateCandidateManagerImpl candidateManager;
- private final UploadFileTest uploadFileTest = new UploadFileTest();
+ private UploadFileTest uploadFileTest = new UploadFileTest();
private static String vspId;
private static Version vspActiveVersion;
@@ -110,31 +101,27 @@ public class QuestionnaireDataServiceTest {
// TODO: 3/15/2017 fix and enable //@Test
public void testQuestionnaireDataAfterIllegalUpload() throws IOException {
-
try (InputStream zipInputStream = uploadFileTest.getZipInputStream("/missingYml")) {
- UploadFileResponse uploadFileResponse = candidateManager
- .upload(vspId, VERSION, zipInputStream, USER1, "zip", "missingYml");
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(vspId, VERSION, zipInputStream, "zip", "missingYml");
}
-
InformationArtifactData informationArtifactData = questionnaireDataService
.generateQuestionnaireDataForInformationArtifact(vspId, vspActiveVersion);
}
private InformationArtifactData uploadFileAndValidateInformationArtifactData(String filePath,
- int listSizeToCheck) throws IOException {
+ int listSizeToCheck)
+ throws IOException {
try (InputStream zipInputStream = uploadFileTest.getZipInputStream(filePath)) {
- UploadFileResponse uploadFileResponse = candidateManager
- .upload(vspId, VERSION,
- zipInputStream, USER1, "zip", "file");
-
- candidateManager.process(vspId, VERSION, USER1);
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(vspId, VERSION, zipInputStream, "zip", "file");
+ candidateManager.process(vspId, VERSION);
Assert.assertTrue(MapUtils.isEmpty(
MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, uploadFileResponse.getErrors())));
}
-
InformationArtifactData informationArtifactData = questionnaireDataService
.generateQuestionnaireDataForInformationArtifact(vspId, vspActiveVersion);
Assert.assertNotNull(informationArtifactData);
@@ -143,11 +130,6 @@ public class QuestionnaireDataServiceTest {
informationArtifactData.getComponentQuestionnaires();
Assert.assertEquals(componentQuestionnaireList.size(), listSizeToCheck);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(),eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION.getMajor()+1));
- Assert.assertTrue(activityLogEntity.isSuccess());
-
return informationArtifactData;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java
index c3f78b6cb0..a2cbaa7eb6 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentDependencyModelTest.java
@@ -6,136 +6,217 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ComponentManager;
-import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.when;
+
public class ComponentDependencyModelTest {
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+ private static final String VSP_ID = "vsp_id";
+ private static final Version VERSION = new Version("version_id");
+ private static final String COMP_DEP_ID = "comp_dep_id";
+
+ private static final String COMP_ID_1 = "comp_id_1";
+ private static final String COMP_ID_2 = "comp_id_2";
+ private static final String COMP_ID_3 = "comp_id_3";
+ private static final String COMP_ID_4 = "comp_id_4";
@Spy
@InjectMocks
private ComponentDependencyModelManagerImpl componentDependencyModelManager;
@Mock
- private VendorSoftwareProductManager vendorSoftwareProductManager;
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDao;
- @Mock
- private ComponentDao componentDao;
- @Mock
private ComponentManager componentManager;
+ @Mock
+ private ComponentDependencyModelDao componentDependencyModelDao;
- private static String vsp1Id;
- private static String sourceComp1Id;
- private static String sourceComp2Id;
- private static String sourceComp3Id;
- private static String sourceComp4Id;
- private static final String USER1 = "TestUser1";
- private static final String USER2 = "TestUser2";
- private static final Version VERSION01 = new Version(0, 1);
- private static String modelId = "model1";
-
-
- @BeforeClass
+ @BeforeMethod
private void init() {
MockitoAnnotations.initMocks(this);
}
- public static VspDetails createVspDetails(String id, Version version, String name, String desc,
- String vendorName, String vlm, String icon,
- String category, String subCategory,
- String licenseAgreement, List<String> featureGroups
- ) {
- VspDetails vspDetails = new VspDetails(id, version);
- vspDetails.setName(name);
- vspDetails.setDescription(desc);
- vspDetails.setIcon(icon);
- vspDetails.setCategory(category);
- vspDetails.setSubCategory(subCategory);
- vspDetails.setVendorName(vendorName);
- vspDetails.setVendorId(vlm);
- vspDetails.setVlmVersion(new Version(1, 0));
- vspDetails.setLicenseAgreement(licenseAgreement);
- vspDetails.setFeatureGroups(featureGroups);
- return vspDetails;
+ @Test
+ public void testListDependency() {
+ List<ComponentDependencyModelEntity> entities = new ArrayList<>();
+ entities.add(createModelEntity(COMP_ID_1, COMP_ID_2));
+ entities.add(createModelEntity(COMP_ID_3, COMP_ID_4));
+
+ Mockito.when(componentDependencyModelDao
+ .list(new ComponentDependencyModelEntity(VSP_ID, VERSION, null)))
+ .thenReturn(entities);
+
+ Collection<ComponentDependencyModelEntity> list =
+ componentDependencyModelManager.list(VSP_ID, VERSION);
+
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1))
+ .list(new ComponentDependencyModelEntity(VSP_ID, VERSION, null));
+
+ Assert.assertEquals(2, list.size());
+ }
+
+ @Test
+ public void testCreateDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+
+ componentDependencyModelManager.createComponentDependency(modelEntity, VSP_ID, VERSION);
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1)).create(modelEntity);
+ }
+
+ @Test
+ public void testCreateDependencyNegative_SameSourceTarget() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_1);
+ testCreateDependency_negative(modelEntity, VSP_ID, VERSION,
+ ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().message());
}
@Test
- public void testCreateNegative_NoSourceId() {
- List<ComponentDependencyModelEntity> entities = new ArrayList<ComponentDependencyModelEntity>();
- entities.add(createModelEntity(null, sourceComp2Id));
- testCreate_negative(entities, vsp1Id, VERSION01, USER1,
+ public void testCreateDependencyNegative_NoSourceId() {
+
+ ComponentDependencyModelEntity modelEntity = createModelEntity(null, COMP_ID_1);
+ testCreateDependency_negative(modelEntity, VSP_ID, VERSION,
ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
- entities.clear();
- entities.add(createModelEntity("", sourceComp2Id));
- testCreate_negative(entities, vsp1Id, VERSION01, USER1,
+
+ ComponentDependencyModelEntity modelEntity1 = createModelEntity("", COMP_ID_1);
+ testCreateDependency_negative(modelEntity1, VSP_ID, VERSION,
ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
}
@Test
- public void testCreateNegative_SameSourceTarget() {
- List<ComponentDependencyModelEntity> entities = new ArrayList<ComponentDependencyModelEntity>();
- entities.add(createModelEntity("sourceComp1Id", "sourceComp1Id"));
- testCreate_negative(entities, vsp1Id, VERSION01, USER1,
+ public void testUpdateDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ componentDependencyModelManager.update(modelEntity);
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1)).update(modelEntity);
+ }
+
+ @Test
+ public void testUpdateDependencyNegative_NoSourceId() {
+
+ ComponentDependencyModelEntity modelEntity = createModelEntity(null, COMP_ID_1);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ testUpdateDependency_negative(modelEntity,
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+
+ ComponentDependencyModelEntity modelEntity1 = createModelEntity("", COMP_ID_1);
+ modelEntity1.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity1);
+
+ testUpdateDependency_negative(modelEntity1,
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().id(),
+ ComponentDependencyModelErrorBuilder.getNoSourceComponentErrorBuilder().message());
+ }
+
+ @Test
+ public void testUpdateDependencyNegative_SameSourceTarget() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_1);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+ testUpdateDependency_negative(modelEntity,
ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().id(),
ComponentDependencyModelErrorBuilder.getSourceTargetComponentEqualErrorBuilder().message());
}
@Test
- public void testCreate() {
- List<ComponentDependencyModelEntity> entities = new ArrayList<ComponentDependencyModelEntity>();
- entities.add(createModelEntity("sourceComp1Id", "sourceComp2Id"));
- entities.add(createModelEntity("sourceComp3Id", "sourceComp4Id"));
-
- componentDependencyModelManager.createComponentDependencyModel(entities, vsp1Id, VERSION01,
- USER1);
- Mockito.verify(vendorSoftwareProductDao, Mockito.times(1)).createComponentDependencyModel
- (entities, vsp1Id,
- VERSION01);
+ public void testDeleteDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ componentDependencyModelManager.delete(VSP_ID, VERSION, COMP_DEP_ID);
+ Mockito.verify(componentDependencyModelDao, Mockito.times(1)).delete(modelEntity);
+ }
+
+ @Test
+ public void testDeleteInvalidDependency() {
+ ComponentDependencyModelEntity delModelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ delModelEntity.setId(COMP_DEP_ID);
+
+ try {
+ componentDependencyModelManager.delete(VSP_ID, VERSION, COMP_DEP_ID);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), "VERSIONABLE_SUB_ENTITY_NOT_FOUND");
+ Assert.assertEquals(exception.getMessage(),
+ String.format("Vendor Software Product Component Dependency Model with Id %s " +
+ "does not exist for Vendor Software Product with id %s and version %s",
+ COMP_DEP_ID, VSP_ID, VERSION.getId()));
+ }
+ }
+
+
+ @Test
+ public void testGetDependency() {
+ ComponentDependencyModelEntity modelEntity =
+ createModelEntity(COMP_ID_1, COMP_ID_2);
+ modelEntity.setId(COMP_DEP_ID);
+
+ when(componentDependencyModelDao.get(anyObject())).thenReturn(modelEntity);
+
+ ComponentDependencyModelEntity retrieved =
+ componentDependencyModelManager.get(VSP_ID, VERSION, COMP_DEP_ID);
+
+ Assert.assertEquals(retrieved.getSourceComponentId(), COMP_ID_1);
+
}
private ComponentDependencyModelEntity createModelEntity(String sourceId, String targetId) {
ComponentDependencyModelEntity entity =
- new ComponentDependencyModelEntity(vsp1Id, VERSION01, modelId);
+ new ComponentDependencyModelEntity(VSP_ID, VERSION, COMP_DEP_ID);
entity.setSourceComponentId(sourceId);
entity.setTargetComponentId(targetId);
entity.setRelation("dependsOn");
return entity;
}
- private Collection<ComponentDependencyModelEntity> getDependencyModel(String vspId,
- Version version,
- String user) {
- return componentDependencyModelManager.list(vspId, version, user);
+ private void testCreateDependency_negative(ComponentDependencyModelEntity entity, String vspId,
+ Version version, String expectedErrorCode,
+ String expectedErrorMsg) {
+ try {
+ componentDependencyModelManager.createComponentDependency(entity, vspId, version);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
+ }
}
- private void testCreate_negative(List<ComponentDependencyModelEntity> entities, String vspId,
- Version version, String user,
- String expectedErrorCode, String expectedErrorMsg) {
+ private void testUpdateDependency_negative(ComponentDependencyModelEntity entity,
+ String expectedErrorCode, String expectedErrorMsg) {
try {
- componentDependencyModelManager.createComponentDependencyModel(entities, vspId, version,
- user);
+ componentDependencyModelManager.update(entity);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
index ee8295cafc..c7aa81873b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComponentManagerImplTest.java
@@ -2,12 +2,9 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.NicManager;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
@@ -37,16 +34,13 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
public class ComponentManagerImplTest {
-
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
-
- private static final String COMP_NOT_EXIST_MSG =
- "Vendor Software Product Component with Id 1 does not exist for Vendor Software Product with id VSP_ID and version 0.1";
- private static final String USER = "componentsTestUser";
private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
- private static final String COMP1_ID = "1";
- private static final String COMP2_ID = "2";
+ private static final Version VERSION = new Version("version_id");
+ private static final String COMP1_ID = "comp1";
+ private static final String COMP2_ID = "comp2";
+ private static final String COMP_NOT_EXIST_MSG =
+ "Vendor Software Product Component with Id comp1 does not exist " +
+ "for Vendor Software Product with id VSP_ID and version version_id";
@Mock
private ComponentDao componentDaoMock;
@@ -67,20 +61,15 @@ public class ComponentManagerImplTest {
@Test
public void testListWhenNone() {
- Collection<ComponentEntity> components =
- componentManager.listComponents(VSP_ID, VERSION, USER);
+ Collection<ComponentEntity> components = componentManager.listComponents(VSP_ID, VERSION);
Assert.assertEquals(components.size(), 0);
}
@Test(expectedExceptions = CoreException.class,
- expectedExceptionsMessageRegExp = "Vendor Software Product Component with Id dummyComponentId " +
- "does not exist for Vendor Software Product with id dummyVsp and version 1.0")
+ expectedExceptionsMessageRegExp = COMP_NOT_EXIST_MSG)
public void validateExceptionWhenTryingToRetriveNotExistingComponentEntity() {
- Version version = Mockito.mock(Version.class);
- doReturn("1.0").when(version).toString();
doReturn(null).when(componentDaoMock).get(anyObject());
- componentManager.validateComponentExistence("dummyVsp", version, "dummyComponentId",
- "dummyUser");
+ componentManager.validateComponentExistence(VSP_ID, VERSION, COMP1_ID);
}
@Test
@@ -90,21 +79,20 @@ public class ComponentManagerImplTest {
createComponent(VSP_ID, VERSION, COMP2_ID)))
.when(componentDaoMock).list(anyObject());
- Collection<ComponentEntity> actual =
- componentManager.listComponents(VSP_ID, VERSION, USER);
+ Collection<ComponentEntity> actual = componentManager.listComponents(VSP_ID, VERSION);
Assert.assertEquals(actual.size(), 2);
}
@Test
public void testDeleteListOnUploadVsp_negative() {
- testDeleteList_negative(VSP_ID, VERSION, USER,
+ testDeleteList_negative(VSP_ID, VERSION,
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
-/* @Test
- public void testCreate() {
- COMP1_ID = testCreate(VSP_ID);
- }*/
+ /* @Test
+ public void testCreate() {
+ COMP1_ID = testCreate(VSP_ID);
+ }*/
@Test
public void testCreate() {
ComponentEntity expected = new ComponentEntity(VSP_ID, null, null);
@@ -113,12 +101,12 @@ public class ComponentManagerImplTest {
compData.setDescription("comp1 desc");
expected.setComponentCompositionData(compData);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
doReturn(expected).when(compositionEntityDataManagerMock).createComponent(anyObject());
- ComponentEntity created = componentManager.createComponent(expected, USER);
+ ComponentEntity created = componentManager.createComponent(expected);
Assert.assertNotNull(created);
//expected.setId(created.getId());
//expected.setVersion(VERSION);
@@ -137,15 +125,14 @@ public class ComponentManagerImplTest {
compData.setDescription("comp1 desc");
expected.setComponentCompositionData(compData);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
vspComponentList.add(expected);
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
try {
- ComponentEntity created = componentManager.createComponent(expected, USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ ComponentEntity created = componentManager.createComponent(expected);
+ } catch (CoreException exception) {
Assert.assertEquals("Creation of only one VFC per VSP allowed.", exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes.VSP_VFC_COUNT_EXCEED,
exception.code().id());
@@ -161,14 +148,14 @@ public class ComponentManagerImplTest {
expected.setComponentCompositionData(compData);
doReturn(expected).when(componentDaoMock).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
vspComponentList.add(expected);
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
- doReturn(new CompositionEntityValidationData(null,null)).when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(),anyObject(),anyObject());
+ doReturn(new CompositionEntityValidationData(null, null)).when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
- CompositionEntityValidationData created = componentManager.updateComponent(expected, USER);
+ CompositionEntityValidationData created = componentManager.updateComponent(expected);
Assert.assertNotNull(created);
}
@@ -182,20 +169,19 @@ public class ComponentManagerImplTest {
expected.setComponentCompositionData(compData);
doReturn(expected).when(componentDaoMock).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<ComponentEntity> vspComponentList = new ArrayList<>();
vspComponentList.add(expected);
- ComponentEntity expected2 = new ComponentEntity(VSP_ID+"2", null, COMP1_ID+"2");
+ ComponentEntity expected2 = new ComponentEntity(VSP_ID + "2", null, COMP1_ID + "2");
expected2.setComponentCompositionData(compData);
vspComponentList.add(expected2);
doReturn(vspComponentList).when(componentDaoMock).list(anyObject());
- doReturn(new CompositionEntityValidationData(null,null)).when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(),anyObject(),anyObject());
+ doReturn(new CompositionEntityValidationData(null, null)).when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
try {
- CompositionEntityValidationData created = componentManager.updateComponent(expected, USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ CompositionEntityValidationData created = componentManager.updateComponent(expected);
+ } catch (CoreException exception) {
Assert.assertEquals("VFC with specified name already present in given VSP.",
exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes.VSP_VFC_DUPLICATE_NAME,
@@ -220,7 +206,7 @@ public class ComponentManagerImplTest {
@Test
public void testCreateOnUploadVsp_negative() {
- testCreate_negative(new ComponentEntity(VSP_ID, VERSION, null), USER,
+ testCreate_negative(new ComponentEntity(VSP_ID, VERSION, null),
VendorSoftwareProductErrorCodes.VFC_ADD_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@@ -229,7 +215,7 @@ public class ComponentManagerImplTest {
String componentId = "non existing component id";
doReturn(null).when(componentDaoMock).get(anyObject());
- testUpdate_negative(VSP_ID, VERSION, componentId, USER,
+ testUpdate_negative(VSP_ID, VERSION, componentId,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -254,7 +240,7 @@ public class ComponentManagerImplTest {
CompositionEntityValidationData validationData =
- componentManager.updateComponent(component, USER);
+ componentManager.updateComponent(component);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(componentDaoMock).update(component);
}
@@ -277,7 +263,7 @@ public class ComponentManagerImplTest {
component.setComponentCompositionData(compData);
CompositionEntityValidationData validationData =
- componentManager.updateComponent(component, USER);
+ componentManager.updateComponent(component);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -289,7 +275,7 @@ public class ComponentManagerImplTest {
String componentId = "non existing component id";
doReturn(null).when(componentDaoMock).get(anyObject());
- testGet_negative(VSP_ID, VERSION, componentId, USER,
+ testGet_negative(VSP_ID, VERSION, componentId,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -300,7 +286,7 @@ public class ComponentManagerImplTest {
doReturn("schema string").when(componentManager).getComponentCompositionSchema(anyObject());
- testGet(VSP_ID, VERSION, COMP1_ID, USER, expected);
+ testGet(VSP_ID, VERSION, COMP1_ID, expected);
}
@@ -329,14 +315,14 @@ public class ComponentManagerImplTest {
@Test
public void testDeleteOnUploadVsp_negative() {
- testDelete_negative(VSP_ID, VERSION, COMP1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, COMP1_ID,
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
@Test(expectedExceptions = CoreException.class,
expectedExceptionsMessageRegExp = COMP_NOT_EXIST_MSG)
public void testGetNonExistingComponentQuestionnaire() throws Exception {
- componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID, USER);
+ componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID);
}
@Test
@@ -347,7 +333,7 @@ public class ComponentManagerImplTest {
doReturn(schema).when(componentManager).getComponentQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID, USER);
+ componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), null);
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -372,13 +358,13 @@ public class ComponentManagerImplTest {
nicEntity2.setNicCompositionData(nic2);
doReturn(Arrays.asList(nicEntity1, nicEntity2))
- .when(nicManagerMock).listNics(VSP_ID, VERSION, COMP1_ID, USER);
+ .when(nicManagerMock).listNics(VSP_ID, VERSION, COMP1_ID);
String schema = "schema string";
doReturn(schema).when(componentManager).getComponentQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID, USER);
+ componentManager.getQuestionnaire(VSP_ID, VERSION, COMP1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), component.getQuestionnaireData());
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -389,7 +375,7 @@ public class ComponentManagerImplTest {
expectedExceptionsMessageRegExp = COMP_NOT_EXIST_MSG)
public void testUpdateNonExistingComponentQuestionnaire() throws Exception {
doReturn(null).when(componentDaoMock).get(anyObject());
- componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data", USER);
+ componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data");
}
@Test
@@ -397,7 +383,7 @@ public class ComponentManagerImplTest {
ComponentEntity component = createComponent(VSP_ID, VERSION, COMP1_ID);
doReturn(component).when(componentDaoMock).get(anyObject());
- componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data", USER);
+ componentManager.updateQuestionnaire(VSP_ID, VERSION, COMP1_ID, "questionnaire data");
verify(componentDaoMock)
.updateQuestionnaireData(VSP_ID, VERSION, COMP1_ID, "questionnaire data");
@@ -417,79 +403,72 @@ public class ComponentManagerImplTest {
Assert.assertEquals(actual.size(), 0);
}*/
- private void testGet(String vspId, Version version, String componentId, String user,
+ private void testGet(String vspId, Version version, String componentId,
ComponentEntity expected) {
CompositionEntityResponse<ComponentData>
- response = componentManager.getComponent(vspId, version, componentId, user);
+ response = componentManager.getComponent(vspId, version, componentId);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(response.getData(), expected.getComponentCompositionData());
Assert.assertNotNull(response.getSchema());
}
- private void testCreate_negative(ComponentEntity component, String user,
+ private void testCreate_negative(ComponentEntity component,
String expectedErrorCode) {
try {
- componentManager.createComponent(component, user);
+ componentManager.createComponent(component);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testGet_negative(String vspId, Version version, String componentId, String user,
+ private void testGet_negative(String vspId, Version version, String componentId,
String expectedErrorCode) {
try {
- componentManager.getComponent(vspId, version, componentId, user);
+ componentManager.getComponent(vspId, version, componentId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testUpdate_negative(String vspId, Version version, String componentId, String user,
+ private void testUpdate_negative(String vspId, Version version, String componentId,
String expectedErrorCode) {
try {
- componentManager
- .updateComponent(new ComponentEntity(vspId, version, componentId), user);
+ componentManager.updateComponent(new ComponentEntity(vspId, version, componentId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testList_negative(String vspId, Version version, String user,
+ private void testList_negative(String vspId, Version version,
String expectedErrorCode) {
try {
- componentManager.listComponents(vspId, version, user);
+ componentManager.listComponents(vspId, version);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testDeleteList_negative(String vspId, Version version, String user,
+ private void testDeleteList_negative(String vspId, Version version,
String expectedErrorCode) {
try {
- componentManager.deleteComponents(vspId, version, user);
+ componentManager.deleteComponents(vspId, version);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testDelete_negative(String vspId, Version version, String componentId, String user,
+ private void testDelete_negative(String vspId, Version version, String componentId,
String expectedErrorCode) {
try {
- componentManager.deleteComponent(vspId, version, componentId, user);
+ componentManager.deleteComponent(vspId, version, componentId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
index eda5693cce..9058a73632 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ComputeManagerImplTest.java
@@ -1,378 +1,348 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.NetworkManager;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ListComputeResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
-public class ComputeManagerImplTest {
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+public class ComputeManagerImplTest {
- private static final String COMPUTE_NOT_EXIST_MSG =
- "Vendor Software Product COMPUTE with Id compute1 does not exist for Vendor Software Product with " +
- "id VSP_ID and version 0.1";
+ private static final String COMPUTE_NOT_EXIST_MSG =
+ "Vendor Software Product COMPUTE with Id compute1 does not exist for Vendor Software Product with " +
+ "id VSP_ID and version version_id";
- private static final String USER = "computeTestUser";
- private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
- private static final String COMPONENT_ID = "COMPONENT_ID";
- private static final String COMPUTE1_ID = "compute1";
- private static final String COMPUTE2_ID = "compute2";
+ private static final String VSP_ID = "VSP_ID";
+ private static final Version VERSION = new Version("version_id");
+ private static final String COMPONENT_ID = "COMPONENT_ID";
+ private static final String COMPUTE1_ID = "compute1";
+ private static final String COMPUTE2_ID = "compute2";
@Mock
private ComputeDao computeDao;
-
@Mock
private CompositionEntityDataManager compositionEntityDataManagerMock;
-
- @Mock
- private NetworkManager networkManagerMock;
-
@Mock
private VendorSoftwareProductInfoDao vspInfoDao;
-
- @Mock
- private ComputeEntity computeEntity;
-
- @Mock
- private ListComputeResponse listComputeResponse;
-
- @Mock
- private DeploymentFlavorEntity deploymentFlavorEntity;
-
@Mock
private DeploymentFlavorDao deploymentFlavorDao;
-
- @Mock
- private ComponentComputeAssociation componentComputeAssociation;
-
- @Mock
- DeploymentFlavor deploymentFlavor;
-
@InjectMocks
@Spy
private ComputeManagerImpl computeManager;
@BeforeMethod
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
+ MockitoAnnotations.initMocks(this);
}
- @Test
+ @Test
public void testListWhenNone() {
- Collection<ListComputeResponse> computes = computeManager.listCompute(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Collection<ListComputeResponse> computes =
+ computeManager.listComputes(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(computes.size(), 0);
}
@Test
- public void testList(){
- doReturn(Arrays.asList(
+ public void testList() {
+ doReturn(Arrays.asList(
createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID),
createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE2_ID)))
- .when(computeDao).list(anyObject());
-
+ .when(computeDao).list(anyObject());
- Collection<ListComputeResponse> computes = computeManager.listCompute(VSP_ID, VERSION, COMPONENT_ID, USER);
- Assert.assertEquals(computes.size(), 2);
- for (ListComputeResponse compute : computes) {
- Assert.assertEquals(compute.getComputeEntity().getComputeCompositionData().getName(),
- COMPUTE1_ID.equals(compute.getComputeEntity().getId())
- ? "compute1name"
- : "compute2name");
- };
- }
- @Test
- public void testCreateOnNotManualCompute_negative() {
-
- testCreate_negative(new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
- VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testCreateManualCompute() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- computeManager.createCompute(expected, USER);
- verify(compositionEntityDataManagerMock).createCompute(expected);
- verify(compositionEntityDataManagerMock).createCompute(expected);
- }
-
- @Test
- public void testCreateManualComputeWithDuplicateName() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- ComputeEntity expectedDiffName = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- expectedDiffName.setId(COMPUTE1_ID + "Name");
- ComputeData computeData = expectedDiffName.getComputeCompositionData();
- computeData.setName(COMPUTE1_ID + "Name");
- expectedDiffName.setComputeCompositionData(computeData);
- List<ComputeEntity> vfcImageList = new ArrayList<ComputeEntity>();
- vfcImageList.add(expectedDiffName);
- doReturn(vfcImageList).when(computeDao).list(anyObject());
-
- try {
- computeManager.createCompute(expected, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_COMPUTE_NAME_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testUpdateNonExistingComputeId_negative() {
-
- testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ Collection<ListComputeResponse> computes =
+ computeManager.listComputes(VSP_ID, VERSION, COMPONENT_ID);
+ Assert.assertEquals(computes.size(), 2);
+ for (ListComputeResponse compute : computes) {
+ Assert.assertEquals(compute.getComputeEntity().getComputeCompositionData().getName(),
+ COMPUTE1_ID.equals(compute.getComputeEntity().getId())
+ ? "compute1name"
+ : "compute2name");
}
+ }
- @Test
- public void testUpdateCompute() {
- doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
- .when(computeDao).get(anyObject());
-
- doReturn(new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
-
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- ComputeData computeData = new ComputeData();
- computeData.setName(COMPUTE1_ID + "name");
- computeData.setDescription(COMPUTE1_ID + "desc updated");
- computeEntity.setComputeCompositionData(computeData);
-
- CompositionEntityValidationData validationData =
- computeManager.updateCompute(computeEntity, USER);
- Assert.assertTrue(validationData == null || validationData.getErrors() == null);
- verify(computeDao).update(computeEntity);
- }
+ @Test
+ public void testCreateOnNotManualCompute_negative() {
+ testCreate_negative(new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, null),
+ VendorSoftwareProductErrorCodes.ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ }
- @Test
- public void testIllegalComputeUpdate() {
- doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
- .when(computeDao).get(anyObject());
+ @Test
+ public void testCreateManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doNothing().when(computeManager)
+ .validateUniqueName(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
+ doNothing().when(computeManager)
+ .createUniqueName(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
+ String questionnaireSchema = "{}";
+ doReturn(questionnaireSchema).when(computeManager).getComputeQuestionnaireSchema(anyObject());
+
+ computeManager.createCompute(expected);
+ verify(computeDao).create(expected);
+ }
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ @Test(expectedExceptions = CoreException.class)
+ public void testCreateManualComputeWithDuplicateName() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- CompositionEntityValidationData toBeReturned =
- new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID);
- toBeReturned.setErrors(Arrays.asList("error1", "error2"));
- doReturn(toBeReturned)
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
+ doThrow(new CoreException(
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
+ .when(computeManager).validateUniqueName(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- ComputeData computeData = new ComputeData();
- computeData.setName(COMPUTE1_ID + "_name_updated");
- computeData.setDescription(COMPUTE1_ID + " desc updated");
- computeEntity.setComputeCompositionData(computeData);
+ computeManager.createCompute(expected);
+ }
- CompositionEntityValidationData validationData = computeManager.updateCompute(computeEntity, USER);
- Assert.assertNotNull(validationData);
- Assert.assertEquals(validationData.getErrors().size(), 2);
+ @Test
+ public void testUpdateNonExistingComputeId_negative() {
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
- verify(computeDao, never()).update(computeEntity);
- }
+ @Test
+ public void testUpdateCompute() {
+ ComputeEntity retrieved = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(retrieved).when(computeDao).get(anyObject());
+
+ doReturn(new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID))
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + "name");
+ computeData.setDescription(COMPUTE1_ID + "desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ doNothing().when(computeManager)
+ .updateUniqueName(VSP_ID, VERSION, COMPONENT_ID, retrieved.getComputeCompositionData().getName(),
+ computeData.getName());
+
+ CompositionEntityValidationData validationData =
+ computeManager.updateCompute(computeEntity);
+ Assert.assertTrue(validationData == null || validationData.getErrors() == null);
+ verify(computeDao).update(computeEntity);
+ }
- @Test
- public void testUpdateHEATComputeName() throws Exception {
- doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
- .when(computeDao).get(anyObject());
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- ComputeData computeData = new ComputeData();
- computeData.setName(COMPUTE1_ID + " name updated");
- computeData.setDescription(COMPUTE1_ID + " desc updated");
- computeEntity.setComputeCompositionData(computeData);
-
- try {
- computeManager.updateCompute(computeEntity, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED);
- }
+ @Test
+ public void testIllegalComputeUpdate() {
+ doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
+ .when(computeDao).get(anyObject());
+
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+
+ CompositionEntityValidationData toBeReturned =
+ new CompositionEntityValidationData(CompositionEntityType.compute, COMPUTE1_ID);
+ toBeReturned.setErrors(Arrays.asList("error1", "error2"));
+ doReturn(toBeReturned)
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
+
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + "_name_updated");
+ computeData.setDescription(COMPUTE1_ID + " desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ CompositionEntityValidationData validationData =
+ computeManager.updateCompute(computeEntity);
+ Assert.assertNotNull(validationData);
+ Assert.assertEquals(validationData.getErrors().size(), 2);
+
+ verify(computeDao, never()).update(computeEntity);
+ }
+ @Test
+ public void testUpdateHEATComputeName() throws Exception {
+ doReturn(createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID))
+ .when(computeDao).get(anyObject());
+ ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(COMPUTE1_ID + " name updated");
+ computeData.setDescription(COMPUTE1_ID + " desc updated");
+ computeEntity.setComputeCompositionData(computeData);
+
+ try {
+ computeManager.updateCompute(computeEntity);
+ } catch (CoreException ex) {
+ Assert
+ .assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_COMPUTE_NOT_ALLOWED);
}
+ }
- @Test
- public void testUpdateManualComputeQuestionnaire() throws Exception {
- String json = "{\"md5\" :\"FFDSD33SS\"}";
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- doReturn(new ComputeEntity(null,null,null,null)).when(computeDao).get(anyObject());
+ @Test
+ public void testUpdateManualComputeQuestionnaire() throws Exception {
+ String json = "{\"md5\" :\"FFDSD33SS\"}";
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doReturn(new ComputeEntity(null, null, null, null)).when(computeDao).get(anyObject());
+
+ computeManager
+ .updateComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json);
+ verify(computeDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json);
+ }
- computeManager.updateComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json, USER);
- verify(computeDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, json);
- }
+ @Test
+ public void testGetNonExistingComputeId_negative() {
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing compute id",
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ }
- @Test
- public void testGetNonExistingComputeId_negative() {
- testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing compute id", USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
+ @Test
+ public void testGet() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ String compositionSchema = "schema string";
+ doReturn(compositionSchema).when(computeManager).getComputeCompositionSchema(anyObject());
+
+ CompositionEntityResponse<ComputeData> response =
+ computeManager.getCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ Assert.assertEquals(response.getId(), expected.getId());
+ Assert
+ .assertEquals(response.getData().getName(), expected.getComputeCompositionData().getName());
+ Assert.assertEquals(response.getData().getDescription(), expected.getComputeCompositionData().
+ getDescription());
+ Assert.assertEquals(response.getSchema(), compositionSchema);
+ }
- @Test
- public void testGet() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(expected).when(computeDao).get(anyObject());
- String compositionSchema = "schema string";
- doReturn(compositionSchema).when(computeManager).getComputeCompositionSchema(anyObject());
-
- CompositionEntityResponse<ComputeData> response =
- computeManager.getCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
- Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData().getName(), expected.getComputeCompositionData().getName());
- Assert.assertEquals(response.getData().getDescription(), expected.getComputeCompositionData().
- getDescription());
- Assert.assertEquals(response.getSchema(), compositionSchema);
- }
+ @Test
+ public void testGetQuestionnaire() throws Exception {
+ ComputeEntity compute = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ compute.setQuestionnaireData("{}");
+ doReturn(compute).when(computeDao)
+ .getQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- @Test
- public void testGetQuestionnaire() throws Exception {
- ComputeEntity compute = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- compute.setQuestionnaireData("{}");
- doReturn(compute).when(computeDao).getQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ String schema = "schema string";
- String schema = "schema string";
+ doReturn(schema).when(computeManager).getComputeQuestionnaireSchema(anyObject());
+ QuestionnaireResponse questionnaire =
+ computeManager.getComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(schema).when(computeManager).getComputeQuestionnaireSchema(anyObject());
+ Assert.assertNotNull(questionnaire);
+ Assert.assertEquals(questionnaire.getData(), compute.getQuestionnaireData());
+ Assert.assertEquals(questionnaire.getSchema(), schema);
+ Assert.assertNull(questionnaire.getErrorMessage());
+ }
- QuestionnaireResponse questionnaire =
- computeManager.getComputeQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
+ @Test
+ public void testDeleteOnNotManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID,
+ VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ }
- Assert.assertNotNull(questionnaire);
- Assert.assertEquals(questionnaire.getData(), compute.getQuestionnaireData());
- Assert.assertEquals(questionnaire.getSchema(), schema);
- Assert.assertNull(questionnaire.getErrorMessage());
- }
+ @Test
+ public void testDeleteOnManualCompute() {
+ ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ doReturn(expected).when(computeDao).get(anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
+ doNothing().when(computeManager).deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID,
+ expected.getComputeCompositionData().getName());
+
+ computeManager.deleteCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
+ verify(computeDao).delete(anyObject());
+ }
- @Test
- public void testDeleteOnNotManualCompute() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(expected).when(computeDao).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
- VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
- }
+ @Test
+ public void testDeleteOnNotExistCompute() {
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID,
+ VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ }
- @Test
- public void testDeleteOnManualCompute() {
- ComputeEntity expected = createCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID);
- doReturn(expected).when(computeDao).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- computeManager.deleteCompute(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER);
- verify(computeDao).delete(anyObject());
- }
- @Test
- public void testDeleteOnNotExistCompute() {
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, COMPUTE1_ID, USER,
- VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
+ private void testDelete_negative(String vspId, Version version, String componentId,
+ String computeId,
+ String expectedErrorCode) {
+ try {
+ computeManager.deleteCompute(vspId, version, componentId, computeId);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
+ }
-
- private void testDelete_negative(String vspId, Version version, String componentId, String computeId,
- String user,
- String expectedErrorCode) {
- try {
- computeManager.deleteCompute(vspId, version, componentId, computeId, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
+ private void testGet_negative(String vspId, Version version, String componentId, String computeId,
+ String expectedErrorCode) {
+ try {
+ computeManager.getCompute(vspId, version, componentId, computeId);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
-
- private void testGet_negative(String vspId, Version version, String componentId, String computeId,
- String user, String expectedErrorCode) {
- try {
- computeManager.getCompute(vspId, version, componentId, computeId, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
}
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
- try {
- computeManager.listCompute(vspId, version, componentId, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
+ private void testList_negative(String vspId, Version version, String componentId,
+ String expectedErrorCode, String expectedErrorMsg) {
+ try {
+ computeManager.listComputes(vspId, version, componentId);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
+ Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
}
+ }
-
- private void testUpdate_negative(String vspId, Version version, String componentId, String computeId,
- String user, String expectedErrorCode) {
- try {
- computeManager.updateCompute(new ComputeEntity(vspId, version, componentId, computeId), user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
+ private void testUpdate_negative(String vspId, Version version, String componentId,
+ String computeId, String expectedErrorCode) {
+ try {
+ computeManager.updateCompute(new ComputeEntity(vspId, version, componentId, computeId));
+ Assert.fail();
+ } catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testCreate_negative(ComputeEntity computeEntity1, String user, String expectedErrorCode) {
- try {
- computeManager.createCompute(computeEntity1, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
+ private void testCreate_negative(ComputeEntity computeEntity1, String expectedErrorCode) {
+ try {
+ computeManager.createCompute(computeEntity1);
+ Assert.fail();
+ } catch (CoreException exception) {
+ Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
+ }
- static ComputeEntity createCompute(String vspId, Version version, String compId, String computeId){
- ComputeEntity computeEntity1 = new ComputeEntity(vspId, version, compId, computeId);
- ComputeData computeData = new ComputeData();
- computeData.setName(computeId+"name");
- computeData.setDescription(computeId+"desc");
- computeEntity1.setComputeCompositionData(computeData);
- return computeEntity1;
+ private static ComputeEntity createCompute(String vspId, Version version, String compId,
+ String computeId) {
+ ComputeEntity computeEntity1 = new ComputeEntity(vspId, version, compId, computeId);
+ ComputeData computeData = new ComputeData();
+ computeData.setName(computeId + "name");
+ computeData.setDescription(computeId + "desc");
+ computeEntity1.setComputeCompositionData(computeData);
+ return computeEntity1;
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java
deleted file mode 100644
index 598b97b34e..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeplomentFlavorManagerImplTest.java
+++ /dev/null
@@ -1,463 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.impl;
-
-
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.Spy;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
-import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.errors.VersioningErrorCodes;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-public class DeplomentFlavorManagerImplTest {
- private static final String USER = "depFlavorTestUser";
- private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
- private static final String COMPONENT_ID = "COMPONENT_ID";
- private static final String DF1_ID = "df1";
- private static final String DF2_ID = "df2";
-
- @Mock
- private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private VendorSoftwareProductInfoDao vspInfoDao;
- @Mock
- DeploymentFlavorDao deploymentFlavorDaoMock;
- @Mock
- ComponentDao componentDaoMock;
- @Mock
- ComputeDao computeDaoMock;
- @InjectMocks
- @Spy
- private DeploymentFlavorManagerImpl deploymentFlavorManager;
-
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testListWhenNone() {
- final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
- Assert.assertEquals(deploymentFlavorEntities.size(), 0);
- }
-
- @Test
- public void testCreateOnNotManual_negative() {
-
- testCreate_negative(new DeploymentFlavorEntity(VSP_ID, VERSION, null), USER,
- VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testCreateManualDepFlavor() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- verify(compositionEntityDataManagerMock).createDeploymentFlavor(expected);
- }
-
- @Test
- public void testCreateManualDepFlavorWithDuplicateName() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- DeploymentFlavorEntity expectedDiffName = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
- deploymentFlavor.setModel(DF1_ID + "Name");
- expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
- List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
- list.add(expectedDiffName);
- doReturn(list).when(deploymentFlavorDaoMock).list(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithIncorrectNameFormat() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- DeploymentFlavorEntity expectedDiffName = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
- deploymentFlavor.setModel(DF1_ID + "Name/*");
- expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
- List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
- list.add(expectedDiffName);
- doReturn(list).when(deploymentFlavorDaoMock).list(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expectedDiffName, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED,
- ex.code().id());
- }
- }
- @Test
- public void testCreateManualDepFlavorWithFGNotInVSP() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- deploymentFlavor.setFeatureGroupId("fg3");
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- List<String> featureGrps = new ArrayList<String>();
- featureGrps.add("fg1");
- featureGrps.add("fg2");
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- vspDetails.setFeatureGroups(featureGrps);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP,
- ex.code().id());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithNullCompInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- ComponentComputeAssociation association = new ComponentComputeAssociation();
- association.setComponentId(null);
- association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
- list.add(association);
- deploymentFlavor.setComponentComputeAssociations(list);
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION,
- ex.code().id());
- Assert.assertEquals("Invalid request,for valid association please provide ComponentId for Compute Flavor",
- ex.getMessage());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithInvalidComputeInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- ComponentComputeAssociation association = new ComponentComputeAssociation();
- association.setComponentId(COMPONENT_ID);
- association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
- list.add(association);
- deploymentFlavor.setComponentComputeAssociations(list);
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
- doReturn(component).when(componentDaoMock).get(anyObject());
-
- doReturn(null).when(computeDaoMock).get(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID,
- ex.code().id());
- }
- }
-
- @Test
- public void testCreateManualDepFlavorWithDuplicateVfcAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- final DeploymentFlavor deploymentFlavor =
- JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
- ComponentComputeAssociation association = new ComponentComputeAssociation();
- association.setComponentId(COMPONENT_ID);
- association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
- list.add(association);
- list.add(association);
- deploymentFlavor.setComponentComputeAssociations(list);
- expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
-
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
- doReturn(component).when(componentDaoMock).get(anyObject());
-
- ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, "CF1");
- doReturn(computeEntity).when(computeDaoMock).get(anyObject());
-
- try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testList() {
-
- doReturn(Arrays.asList(
- createDeploymentFlavor(VSP_ID, VERSION, DF1_ID),
- createDeploymentFlavor(VSP_ID, VERSION, DF2_ID)))
- .when(deploymentFlavorDaoMock).list(anyObject());
-
-
- final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
- Assert.assertEquals(deploymentFlavorEntities.size(), 2);
- for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
- Assert.assertEquals(deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel()
- , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID+"name" : DF2_ID+"name" );
- }
- }
-
- @Test
- public void testUpdateHeatDepFlavor() {
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
- VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testUpdateNonExistingManualDepFlavorId_negative() {
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testManualUpdateDepFlavor() {
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- doReturn(createDeploymentFlavor(VSP_ID, VERSION, DF1_ID))
- .when(deploymentFlavorDaoMock).get(anyObject());
-
- doReturn(new CompositionEntityValidationData(CompositionEntityType.image, DF1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(DF1_ID + "_name");
- deploymentFlavor.setDescription(DF1_ID + " desc updated");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
-
- CompositionEntityValidationData validationData =
- deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
- Assert.assertTrue(validationData == null || validationData.getErrors() == null);
- verify(deploymentFlavorDaoMock).update(deploymentFlavorEntity);
- }
-
- @Test
- public void testManualUpdateDepFlavorIncorrectNameFormat() {
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
-
- doReturn(createDeploymentFlavor(VSP_ID, VERSION, DF1_ID))
- .when(deploymentFlavorDaoMock).get(anyObject());
-
- doReturn(new CompositionEntityValidationData(CompositionEntityType.image, DF1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(DF1_ID + "_name/*");
- deploymentFlavor.setDescription(DF1_ID + " desc updated");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
-
- try {
- deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
- Assert.fail();
- }
- catch (CoreException ex) {
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DEPLOYMENT_FLAVOR_NAME_FORMAT_NOT_ALLOWED,
- ex.code().id());
- }
- }
-
- @Test
- public void testGetNonExistingDepFlavorId_negative() {
- testGet_negative(VSP_ID, VERSION, "non existing image id", USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testGet() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
-
- VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
- doReturn(vspDetails).when(vspInfoDao).get(anyObject());
-
- CompositionEntityResponse<DeploymentFlavor> response =
- deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
- Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
- getModel());
- Assert.assertEquals(response.getData().getDescription(), expected.getDeploymentFlavorCompositionData().
- getDescription());
- }
-
- @Test
- public void testDeleteDepFlavorOnHEAT() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
- VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
-
- @Test
- public void testDeleteOnNotExistImage() {
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testDeleteOnManualImage() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
- doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
- doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- deploymentFlavorManager.deleteDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
- verify(deploymentFlavorDaoMock).delete(anyObject());
- }
-
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
- try {
- deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
- }
-
- private void testCreate_negative(DeploymentFlavorEntity deploymentFlavorEntity, String user, String
- expectedErrorCode) {
- try {
- deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- private void testDelete_negative(String vspId, Version version, String deploymentFlavorId,
- String user,
- String expectedErrorCode) {
- try {
- deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
-
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel(deploymentFlavorId + "name");
- deploymentFlavor.setDescription(deploymentFlavorId + " desc");
-
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- return deploymentFlavorEntity;
- }
-
- private void testUpdate_negative(String vspId, Version version, String
- deploymentFlavorId, String user, String expectedErrorCode) {
- try {
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("Name");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- deploymentFlavorManager
- .updateDeploymentFlavor(deploymentFlavorEntity, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- private void testGet_negative(String vspId, Version version, String deploymentFlavorId,
- String user, String expectedErrorCode) {
- try {
- deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
index 82715d3fe6..6a5e7fa70c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/DeploymentFlavorManagerImplTest.java
@@ -1,18 +1,12 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
@@ -23,7 +17,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
-import org.openecomp.sdc.vendorsoftwareproduct.types.CompositionEntityResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
@@ -39,13 +32,13 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-public class DeploymentFlavorManagerImplTest {
-
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
- private static final String USER = "depFlavorTestUser";
+public class DeploymentFlavorManagerImplTest {
private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String COMPONENT_ID = "COMPONENT_ID";
private static final String DF1_ID = "df1";
private static final String DF2_ID = "df2";
@@ -55,11 +48,11 @@ public class DeploymentFlavorManagerImplTest {
@Mock
private VendorSoftwareProductInfoDao vspInfoDao;
@Mock
- DeploymentFlavorDao deploymentFlavorDaoMock;
+ private DeploymentFlavorDao deploymentFlavorDaoMock;
@Mock
- ComponentDao componentDaoMock;
+ private ComponentDao componentDaoMock;
@Mock
- ComputeDao computeDaoMock;
+ private ComputeDao computeDaoMock;
@InjectMocks
@Spy
private DeploymentFlavorManagerImpl deploymentFlavorManager;
@@ -72,26 +65,26 @@ public class DeploymentFlavorManagerImplTest {
@Test
public void testListWhenNone() {
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
+ deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION);
Assert.assertEquals(deploymentFlavorEntities.size(), 0);
}
@Test
public void testCreateOnNotManual_negative() {
- testCreate_negative(new DeploymentFlavorEntity(VSP_ID, VERSION, null), USER,
+ testCreate_negative(new DeploymentFlavorEntity(VSP_ID, VERSION, null),
VendorSoftwareProductErrorCodes.CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testCreateManualDepFlavor() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
verify(compositionEntityDataManagerMock).createDeploymentFlavor(expected);
}
@@ -104,17 +97,16 @@ public class DeploymentFlavorManagerImplTest {
DeploymentFlavor deploymentFlavor = expectedDiffName.getDeploymentFlavorCompositionData();
deploymentFlavor.setModel(DF1_ID + "Name");
expectedDiffName.setDeploymentFlavorCompositionData(deploymentFlavor);
- List<DeploymentFlavorEntity> list = new ArrayList<DeploymentFlavorEntity>();
+ List<DeploymentFlavorEntity> list = new ArrayList<>();
list.add(expectedDiffName);
doReturn(list).when(deploymentFlavorDaoMock).list(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED,
+ } catch (CoreException ex) {
+ Assert.assertEquals(
+ VendorSoftwareProductErrorCodes.DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED,
ex.code().id());
}
}
@@ -129,7 +121,7 @@ public class DeploymentFlavorManagerImplTest {
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- List<String> featureGrps = new ArrayList<String>();
+ List<String> featureGrps = new ArrayList<>();
featureGrps.add("fg1");
featureGrps.add("fg2");
@@ -139,11 +131,9 @@ public class DeploymentFlavorManagerImplTest {
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.FEATURE_GROUP_NOT_EXIST_FOR_VSP,
ex.code().id());
}
@@ -151,13 +141,13 @@ public class DeploymentFlavorManagerImplTest {
@Test
public void testCreateManualDepFlavorWithNullCompInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
final DeploymentFlavor deploymentFlavor =
JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
ComponentComputeAssociation association = new ComponentComputeAssociation();
association.setComponentId(null);
association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ List<ComponentComputeAssociation> list = new ArrayList<>();
list.add(association);
deploymentFlavor.setComponentComputeAssociations(list);
expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
@@ -168,26 +158,25 @@ public class DeploymentFlavorManagerImplTest {
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPONENT_COMPUTE_ASSOCIATION,
ex.code().id());
- Assert.assertEquals("Invalid request,for valid association please provide ComponentId for Compute Flavor",
+ Assert.assertEquals(
+ "Invalid request,for valid association please provide ComponentId for Compute Flavor",
ex.getMessage());
}
}
@Test
public void testCreateManualDepFlavorWithInvalidComputeInAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
final DeploymentFlavor deploymentFlavor =
JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
ComponentComputeAssociation association = new ComponentComputeAssociation();
association.setComponentId(COMPONENT_ID);
association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ List<ComponentComputeAssociation> list = new ArrayList<>();
list.add(association);
deploymentFlavor.setComponentComputeAssociations(list);
expected.setCompositionData(JsonUtil.object2Json(deploymentFlavor));
@@ -197,16 +186,14 @@ public class DeploymentFlavorManagerImplTest {
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
+ ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, null);
doReturn(component).when(componentDaoMock).get(anyObject());
doReturn(null).when(computeDaoMock).get(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ deploymentFlavorManager.createDeploymentFlavor(expected);
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.INVALID_COMPUTE_FLAVOR_ID,
ex.code().id());
}
@@ -214,13 +201,13 @@ public class DeploymentFlavorManagerImplTest {
@Test
public void testCreateManualDepFlavorWithDuplicateVfcAssociation() {
- DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
final DeploymentFlavor deploymentFlavor =
JsonUtil.json2Object(expected.getCompositionData(), DeploymentFlavor.class);
ComponentComputeAssociation association = new ComponentComputeAssociation();
association.setComponentId(COMPONENT_ID);
association.setComputeFlavorId("CF1");
- List<ComponentComputeAssociation> list = new ArrayList<ComponentComputeAssociation>();
+ List<ComponentComputeAssociation> list = new ArrayList<>();
list.add(association);
list.add(association);
deploymentFlavor.setComponentComputeAssociations(list);
@@ -231,18 +218,17 @@ public class DeploymentFlavorManagerImplTest {
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, USER);
+ ComponentEntity component = new ComponentEntity(VSP_ID, VERSION, null);
doReturn(component).when(componentDaoMock).get(anyObject());
ComputeEntity computeEntity = new ComputeEntity(VSP_ID, VERSION, COMPONENT_ID, "CF1");
doReturn(computeEntity).when(computeDaoMock).get(anyObject());
try {
- deploymentFlavorManager.createDeploymentFlavor(expected, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED,
+ deploymentFlavorManager.createDeploymentFlavor(expected);
+ } catch (CoreException ex) {
+ Assert.assertEquals(
+ VendorSoftwareProductErrorCodes.SAME_VFC_ASSOCIATION_MORE_THAN_ONCE_NOT_ALLOWED,
ex.code().id());
}
}
@@ -251,30 +237,30 @@ public class DeploymentFlavorManagerImplTest {
public void testList() {
doReturn(Arrays.asList(
- createDeploymentFlavor(VSP_ID, VERSION, DF1_ID),
- createDeploymentFlavor(VSP_ID, VERSION, DF2_ID)))
+ createDeploymentFlavor(VSP_ID, VERSION, DF1_ID),
+ createDeploymentFlavor(VSP_ID, VERSION, DF2_ID)))
.when(deploymentFlavorDaoMock).list(anyObject());
final Collection<DeploymentFlavorEntity> deploymentFlavorEntities =
- deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION, USER);
+ deploymentFlavorManager.listDeploymentFlavors(VSP_ID, VERSION);
Assert.assertEquals(deploymentFlavorEntities.size(), 2);
for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
Assert.assertEquals(deploymentFlavorEntity.getDeploymentFlavorCompositionData().getModel()
- , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID+"name" : DF2_ID+"name" );
+ , DF1_ID.equals(deploymentFlavorEntity.getId()) ? DF1_ID + "name" : DF2_ID + "name");
}
}
@Test
public void testUpdateHeatDepFlavor() {
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testUpdate_negative(VSP_ID, VERSION, DF1_ID,
VendorSoftwareProductErrorCodes.EDIT_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testUpdateNonExistingManualDepFlavorId_negative() {
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- testUpdate_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testUpdate_negative(VSP_ID, VERSION, DF1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -292,21 +278,22 @@ public class DeploymentFlavorManagerImplTest {
VspDetails vspDetails = new VspDetails(VSP_ID, VERSION);
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(VSP_ID, VERSION, DF1_ID);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel(DF1_ID + "_name");
deploymentFlavor.setDescription(DF1_ID + " desc updated");
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
CompositionEntityValidationData validationData =
- deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity, USER);
+ deploymentFlavorManager.updateDeploymentFlavor(deploymentFlavorEntity);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(deploymentFlavorDaoMock).update(deploymentFlavorEntity);
}
@Test
public void testGetNonExistingDepFlavorId_negative() {
- testGet_negative(VSP_ID, VERSION, "non existing image id", USER,
+ testGet_negative(VSP_ID, VERSION, "non existing image id",
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -320,25 +307,27 @@ public class DeploymentFlavorManagerImplTest {
doReturn(vspDetails).when(vspInfoDao).get(anyObject());
CompositionEntityResponse<DeploymentFlavor> response =
- deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
+ deploymentFlavorManager.getDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
- getModel());
- Assert.assertEquals(response.getData().getDescription(), expected.getDeploymentFlavorCompositionData().
- getDescription());
+ Assert
+ .assertEquals(response.getData().getModel(), expected.getDeploymentFlavorCompositionData().
+ getModel());
+ Assert.assertEquals(response.getData().getDescription(),
+ expected.getDeploymentFlavorCompositionData().
+ getDescription());
}
*/
@Test
public void testDeleteDepFlavorOnHEAT() {
DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, DF1_ID,
VendorSoftwareProductErrorCodes.DELETE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testDeleteOnNotExistImage() {
- testDelete_negative(VSP_ID, VERSION, DF1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, DF1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -347,48 +336,35 @@ public class DeploymentFlavorManagerImplTest {
DeploymentFlavorEntity expected = createDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
doReturn(expected).when(deploymentFlavorDaoMock).get(anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- deploymentFlavorManager.deleteDeploymentFlavor(VSP_ID, VERSION, DF1_ID, USER);
+ deploymentFlavorManager.deleteDeploymentFlavor(VSP_ID, VERSION, DF1_ID);
verify(deploymentFlavorDaoMock).delete(anyObject());
}
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
- try {
- deploymentFlavorManager.listDeploymentFlavors(vspId, version, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
- }
-
- private void testCreate_negative(DeploymentFlavorEntity deploymentFlavorEntity, String user, String
- expectedErrorCode) {
+ private void testCreate_negative(DeploymentFlavorEntity deploymentFlavorEntity,
+ String expectedErrorCode) {
try {
- deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity, user);
+ deploymentFlavorManager.createDeploymentFlavor(deploymentFlavorEntity);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testDelete_negative(String vspId, Version version, String deploymentFlavorId,
- String user,
String expectedErrorCode) {
try {
- deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId, user);
+ deploymentFlavorManager.deleteDeploymentFlavor(vspId, version, deploymentFlavorId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version, String deploymentFlavorId) {
+ private static DeploymentFlavorEntity createDeploymentFlavor(String vspId, Version version,
+ String deploymentFlavorId) {
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel(deploymentFlavorId + "name");
deploymentFlavor.setDescription(deploymentFlavorId + " desc");
@@ -397,29 +373,28 @@ public class DeploymentFlavorManagerImplTest {
return deploymentFlavorEntity;
}
- private void testUpdate_negative(String vspId, Version version, String
- deploymentFlavorId, String user, String expectedErrorCode) {
+ private void testUpdate_negative(String vspId, Version version, String deploymentFlavorId,
+ String expectedErrorCode) {
try {
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
+ DeploymentFlavorEntity deploymentFlavorEntity =
+ new DeploymentFlavorEntity(vspId, version, deploymentFlavorId);
DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
deploymentFlavor.setModel("Name");
deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
deploymentFlavorManager
- .updateDeploymentFlavor(deploymentFlavorEntity, user);
+ .updateDeploymentFlavor(new DeploymentFlavorEntity(vspId, version, deploymentFlavorId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testGet_negative(String vspId, Version version, String deploymentFlavorId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId, user);
+ deploymentFlavorManager.getDeploymentFlavor(vspId, version, deploymentFlavorId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
index 9f932b9fdf..d9b4188f5e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ImageManagerImplTest.java
@@ -1,18 +1,11 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
@@ -29,21 +22,20 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.List;
-public class ImageManagerImplTest {
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
- private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
+public class ImageManagerImplTest {
private static final String IMAGE_NOT_EXIST_MSG =
- "Vendor Software Product Image with Id image1 does not exist for Vendor Software Product with" +
- " " +
- "id VSP_ID and version 0.1";
+ "Vendor Software Product Image with Id image1 does not exist for Vendor Software Product with" +
+ " id VSP_ID and version 0.1";
- private static final String USER = "imageTestUser";
private static final String VSP_ID = "VSP_ID";
private static final Version VERSION = new Version(0, 1);
private static final String COMPONENT_ID = "COMPONENT_ID";
@@ -68,7 +60,7 @@ public class ImageManagerImplTest {
@Test
public void testListWhenNone() {
final Collection<ImageEntity> imageEntities =
- imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER);
+ imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(imageEntities.size(), 0);
}
@@ -76,32 +68,32 @@ public class ImageManagerImplTest {
public void testList() {
doReturn(Arrays.asList(
- createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID),
- createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE2_ID)))
- .when(imageDao).list(anyObject());
+ createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID),
+ createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE2_ID)))
+ .when(imageDao).list(anyObject());
final Collection<ImageEntity> images =
- imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID, USER);
+ imageManager.listImages(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(images.size(), 2);
for (ImageEntity image : images) {
Assert.assertEquals(image.getImageCompositionData().getFileName(),
- IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID+"_name" : IMAGE2_ID+"_name" );
+ IMAGE1_ID.equals(image.getId()) ? IMAGE1_ID + "_name" : IMAGE2_ID + "_name");
}
}
@Test
public void testCreateOnNotManualImage_negative() {
- testCreate_negative(new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
- VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
+ testCreate_negative(new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, null),
+ VendorSoftwareProductErrorCodes.ADD_IMAGE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@Test
public void testCreateManualImage() {
ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- imageManager.createImage(expected, USER);
+ imageManager.createImage(expected);
verify(compositionEntityDataManagerMock).createImage(expected);
verify(compositionEntityDataManagerMock).createImage(expected);
}
@@ -115,14 +107,13 @@ public class ImageManagerImplTest {
Image image = expectedDiffName.getImageCompositionData();
image.setFileName(IMAGE1_ID + "_Name");
expectedDiffName.setImageCompositionData(image);
- List<ImageEntity> vfcImageList = new ArrayList<ImageEntity>();
+ List<ImageEntity> vfcImageList = new ArrayList<>();
vfcImageList.add(expectedDiffName);
doReturn(vfcImageList).when(imageDao).list(anyObject());
try {
- imageManager.createImage(expected, USER);
+ imageManager.createImage(expected);
Assert.fail();
- }
- catch (CoreException ex) {
+ } catch (CoreException ex) {
Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_NAME_NOT_ALLOWED,
ex.code().id());
}
@@ -130,18 +121,18 @@ public class ImageManagerImplTest {
@Test
public void testUpdateNonExistingImageId_negative() {
- testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test
public void testUpdateImage() {
doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
- .when(imageDao).get(anyObject());
+ .when(imageDao).get(anyObject());
doReturn(new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID))
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
@@ -150,7 +141,7 @@ public class ImageManagerImplTest {
imageEntity.setImageCompositionData(imageData);
CompositionEntityValidationData validationData =
- imageManager.updateImage(imageEntity, USER);
+ imageManager.updateImage(imageEntity);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(imageDao).update(imageEntity);
}
@@ -158,16 +149,16 @@ public class ImageManagerImplTest {
@Test
public void testIllegalImageUpdate() {
doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
- .when(imageDao).get(anyObject());
+ .when(imageDao).get(anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
CompositionEntityValidationData toBeReturned =
- new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID);
+ new CompositionEntityValidationData(CompositionEntityType.image, IMAGE1_ID);
toBeReturned.setErrors(Arrays.asList("error1", "error2"));
doReturn(toBeReturned)
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
@@ -175,7 +166,7 @@ public class ImageManagerImplTest {
imageData.setDescription(IMAGE1_ID + " desc updated");
imageEntity.setImageCompositionData(imageData);
- CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity, USER);
+ CompositionEntityValidationData validationData = imageManager.updateImage(imageEntity);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -185,7 +176,7 @@ public class ImageManagerImplTest {
@Test
public void testUpdateHEATImageFileName() throws Exception {
doReturn(createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID))
- .when(imageDao).get(anyObject());
+ .when(imageDao).get(anyObject());
ImageEntity imageEntity = new ImageEntity(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Image imageData = new Image();
imageData.setFileName(IMAGE1_ID + " name updated");
@@ -193,10 +184,8 @@ public class ImageManagerImplTest {
imageEntity.setImageCompositionData(imageData);
try {
- imageManager.updateImage(imageEntity, USER);
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ imageManager.updateImage(imageEntity);
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED);
}
@@ -204,8 +193,8 @@ public class ImageManagerImplTest {
@Test
public void testGetNonExistingImageId_negative() {
- testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing image id", USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing image id",
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test
@@ -216,12 +205,12 @@ public class ImageManagerImplTest {
doReturn(compositionSchema).when(imageManager).getImageCompositionSchema(anyObject());
CompositionEntityResponse<Image> response =
- imageManager.getImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ imageManager.getImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(response.getData().getFileName(), expected.getImageCompositionData().
- getFileName());
+ getFileName());
Assert.assertEquals(response.getData().getDescription(), expected.getImageCompositionData().
- getDescription());
+ getDescription());
Assert.assertEquals(response.getSchema(), compositionSchema);
}
@@ -229,14 +218,14 @@ public class ImageManagerImplTest {
public void testDeleteOnNotManualImage() {
ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
doReturn(expected).when(imageDao).get(anyObject());
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
- VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED);
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID,
+ VendorSoftwareProductErrorCodes.DELETE_IMAGE_NOT_ALLOWED);
}
@Test
public void testDeleteOnNotExistImage() {
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID,
+ VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test
@@ -244,7 +233,7 @@ public class ImageManagerImplTest {
ImageEntity expected = createImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
doReturn(expected).when(imageDao).get(anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
- imageManager.deleteImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ imageManager.deleteImage(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
verify(imageDao).delete(anyObject());
}
@@ -258,7 +247,7 @@ public class ImageManagerImplTest {
doReturn(schema).when(imageManager).getImageQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- imageManager.getImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, USER);
+ imageManager.getImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), image.getQuestionnaireData());
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -270,7 +259,8 @@ public class ImageManagerImplTest {
String json = "{\"md5\" :\"FFDSD33SS\"}";
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
doReturn(new ImageEntity()).when(imageDao).get(anyObject());
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json, USER);
+
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json);
verify(imageDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json);
}
@@ -291,10 +281,9 @@ public class ImageManagerImplTest {
doReturn(imageEntities).when(imageDao).list(anyObject());
doReturn(imageEntities.get(0)).when(imageDao).getQuestionnaireData(anyObject(), anyObject(), anyObject(), anyObject());
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json, USER);
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, json);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), VendorSoftwareProductErrorCodes.DUPLICATE_IMAGE_VERSION_NOT_ALLOWED);
}
@@ -316,12 +305,9 @@ public class ImageManagerImplTest {
String updJson = "{\"format\" :\"aki\"}";
try {
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson,
- USER);
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson);
Assert.fail();
- }
- catch(CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.UPDATE_IMAGE_NOT_ALLOWED);
}
}
@@ -337,51 +323,34 @@ public class ImageManagerImplTest {
String updJson = "{\"format\" :\"a22\"}";
try {
- imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson,
- USER);
+ imageManager.updateImageQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, IMAGE1_ID, updJson);
Assert.fail();
- }
- catch(CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
Assert.assertEquals(ex.code().id(), VendorSoftwareProductErrorCodes.VFC_IMAGE_INVALID_FORMAT);
}
}
- private void testList_negative(String vspId, Version version, String componentId, String user,
- String expectedErrorCode, String expectedErrorMsg) {
- try {
- imageManager.listImages(vspId, version, componentId, user);
- Assert.fail();
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- Assert.assertEquals(exception.getMessage(), expectedErrorMsg);
- }
- }
-
- private void testCreate_negative(ImageEntity image, String user, String expectedErrorCode) {
+ private void testCreate_negative(ImageEntity image, String expectedErrorCode) {
try {
- imageManager.createImage(image, user);
+ imageManager.createImage(image);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testDelete_negative(String vspId, Version version, String componentId, String nicId,
- String user,
String expectedErrorCode) {
try {
- imageManager.deleteImage(vspId, version, componentId, nicId, user);
+ imageManager.deleteImage(vspId, version, componentId, nicId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- static ImageEntity createImage(String vspId, Version version, String compId, String imageId) {
+ private static ImageEntity createImage(String vspId, Version version, String compId,
+ String imageId) {
ImageEntity imageEntity = new ImageEntity(vspId, version, compId, imageId);
Image imageData = new Image();
imageData.setFileName(imageId + "_name");
@@ -390,21 +359,20 @@ public class ImageManagerImplTest {
return imageEntity;
}
- private void testUpdate_negative(String vspId, Version version, String componentId, String
- imageId, String user, String expectedErrorCode) {
+ private void testUpdate_negative(String vspId, Version version, String componentId,
+ String imageId, String expectedErrorCode) {
try {
- imageManager.updateImage(new ImageEntity(vspId, version, componentId, imageId), user);
+ imageManager.updateImage(new ImageEntity(vspId, version, componentId, imageId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testGet_negative(String vspId, Version version, String componentId, String imageId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- imageManager.getImage(vspId, version, componentId, imageId, user);
+ imageManager.getImage(vspId, version, componentId, imageId);
Assert.fail();
} catch (CoreException exception) {
Assert.assertEquals(exception.code().id(), expectedErrorCode);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
index ecfe0e6372..2360dc7398 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ManualVspToscaManagerImplTest.java
@@ -1,57 +1,10 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.doThrow;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.ALLOWED_FLAVORS_PROPERTY;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.IMAGES_PROPERTY;
-import static org.openecomp.sdc.generator.util.GeneratorConstants.PORT_NODE_TEMPLATE_ID_SUFFIX;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.BINDING_REQUIREMENT_ID;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.COUNT_PROPERTY_NAME;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME;
-import static org.openecomp.sdc.tosca.services.ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME;
-import static org.openecomp.sdc.translator.services.heattotosca.Constants.GLOBAL_SUBSTITUTION_TYPES_TEMPLATE_NAME;
-
-import org.junit.Assert;
-import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.openecomp.sdc.generator.core.utils.GeneratorUtils;
-import org.openecomp.sdc.generator.datatypes.tosca.ComputeFlavor;
-import org.openecomp.sdc.generator.datatypes.tosca.DeploymentFlavorModel;
-import org.openecomp.sdc.generator.datatypes.tosca.LicenseFlavor;
-import org.openecomp.sdc.generator.datatypes.tosca.MultiFlavorVfcImage;
-import org.openecomp.sdc.generator.datatypes.tosca.VendorInfo;
-import org.openecomp.sdc.generator.datatypes.tosca.VspModelInfo;
-import org.openecomp.sdc.generator.util.GeneratorConstants;
-import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType;
-import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
-import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType;
-import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate;
-import org.openecomp.sdc.tosca.datatypes.model.NodeType;
-import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.PropertyType;
-import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
-import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition;
-import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping;
-import org.openecomp.sdc.tosca.services.ToscaConstants;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
-import org.openecomp.sdc.tosca.services.impl.ToscaAnalyzerServiceImpl;
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.vendorsoftwareproduct.services.ManualVspDataCollectionService;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
public class ManualVspToscaManagerImplTest {
@@ -96,36 +49,27 @@ public class ManualVspToscaManagerImplTest {
private ManualVspDataCollectionService manualVspDataCollectionServiceMock;
/*
- private static List<String> supportedCapabilities = new ArrayList<>();
- private static List<String> supportedRequirements = new ArrayList<>();
-
- static {
- //TODO : Read from configuration
- supportedCapabilities.addAll(Arrays.asList("host", "os", "endpoint", "scalable"));
- supportedRequirements.addAll(Arrays.asList("link"));
- }
-
@Test
public void testGatherVspInformationInvalidVsp() {
MockitoAnnotations.initMocks(this);
VspModelInfo expectedVspData = new VspModelInfo();
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getReleaseVendor(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getReleaseVendor(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getAllowedFlavors(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getAllowedFlavors(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getVspComponentImages(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentImages(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getVspComponents(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponents(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
doThrow(new RuntimeException())
.when(manualVspDataCollectionServiceMock)
- .getVspComponentNics(INVALID_VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentNics(INVALID_VSP_ID, Version.valueOf(VSP_VERSION));
VspModelInfo vspModelInfo = manualVspToscaManagerMock.gatherVspInformation(INVALID_VSP_ID,
- Version.valueOf(VSP_VERSION), USER);
+ Version.valueOf(VSP_VERSION));
Assert.assertEquals(expectedVspData, vspModelInfo);
}
@@ -138,17 +82,17 @@ public class ManualVspToscaManagerImplTest {
Map<String, String> componentData = getComponentData();
Map<String, List<MultiFlavorVfcImage>> vfcImageData = getVfcImageData();
doReturn(Optional.of(RELEASE_VENDOR)).when(manualVspDataCollectionServiceMock)
- .getReleaseVendor(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getReleaseVendor(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(deploymentFlavorData).when(manualVspDataCollectionServiceMock)
- .getAllowedFlavors(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getAllowedFlavors(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(vfcImageData).when(manualVspDataCollectionServiceMock)
- .getVspComponentImages(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentImages(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(componentData).when(manualVspDataCollectionServiceMock)
- .getVspComponents(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponents(VSP_ID, Version.valueOf(VSP_VERSION));
doReturn(componentNics).when(manualVspDataCollectionServiceMock)
- .getVspComponentNics(VSP_ID, Version.valueOf(VSP_VERSION), USER);
+ .getVspComponentNics(VSP_ID, Version.valueOf(VSP_VERSION));
VspModelInfo vspModelInfo = manualVspToscaManagerMock.gatherVspInformation(VSP_ID,
- Version.valueOf(VSP_VERSION), USER);
+ Version.valueOf(VSP_VERSION));
VspModelInfo expectedVspData = new VspModelInfo();
expectedVspData.setReleaseVendor(RELEASE_VENDOR);
@@ -449,9 +393,9 @@ public class ManualVspToscaManagerImplTest {
private void validateSubstitutionCapabilities(Map<String, List<String>> capabilities,
String componentName) {
- List<String> SupportedCapabilities = supportedCapabilities;
- Assert.assertEquals(SupportedCapabilities.size(), capabilities.size());
- for (String capability : SupportedCapabilities) {
+ List<String> supportedCapabilities = GeneratorUtils.supportedCapabilities;
+ Assert.assertEquals(supportedCapabilities.size(), capabilities.size());
+ for (String capability : supportedCapabilities) {
String expectedCapabilityId = capability + "_" + componentName;
Assert.assertEquals(true, capabilities.containsKey(expectedCapabilityId));
List<String> expectedCapabilityValue = new ArrayList<>(2);
@@ -464,10 +408,10 @@ public class ManualVspToscaManagerImplTest {
private void validateSubstitutionRequirements(Map<String, List<String>> requirements,
List<Nic> nics) {
- List<String> SupportedRequirements = supportedRequirements;
+ List<String> supportedRequirements = GeneratorUtils.supportedRequirements;
for(Nic nic : nics) {
String nicNodeTemplateId = nic.getName() + PORT_NODE_TEMPLATE_ID_SUFFIX;
- for (String requirement : SupportedRequirements) {
+ for (String requirement : supportedRequirements) {
String expectedRequirementId = requirement + "_" + nicNodeTemplateId;
Assert.assertEquals(true, requirements.containsKey(expectedRequirementId));
List<String> expectedRequirementValue = new ArrayList<>(2);
@@ -508,11 +452,11 @@ public class ManualVspToscaManagerImplTest {
List<Map<String, RequirementDefinition>> requirements =
deploymentFlavorNodeType.getRequirements();
- List<String> SupportedRequirements = supportedRequirements;
+ List<String> supportedRequirements = GeneratorUtils.supportedRequirements;
for (Nic nic : nics) {
boolean found = false;
String nicNodeTemplateId = nic.getName() + PORT_NODE_TEMPLATE_ID_SUFFIX;
- for (String requirementId : SupportedRequirements) {
+ for (String requirementId : supportedRequirements) {
String expectedRequirementId = requirementId + "_" + nicNodeTemplateId;
for (Map<String, RequirementDefinition> requirement : requirements) {
if (requirement.containsKey(expectedRequirementId)) {
@@ -525,8 +469,8 @@ public class ManualVspToscaManagerImplTest {
}
Map<String, CapabilityDefinition> capabilities = deploymentFlavorNodeType.getCapabilities();
- List<String> SupportedCapabilities = supportedCapabilities;
- for (String capabilityId : SupportedCapabilities) {
+ List<String> supportedCapabilities = GeneratorUtils.supportedCapabilities;
+ for (String capabilityId : supportedCapabilities) {
String expectedCapabilityId = capabilityId + "_" + componentName;
Assert.assertEquals (true, capabilities.containsKey(expectedCapabilityId));
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
index 966e1f20bf..5e735ff74e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/MonitoringUploadsManagerImplTest.java
@@ -28,10 +28,9 @@ import static org.mockito.Mockito.verify;
public class MonitoringUploadsManagerImplTest {
- private static final String USER1 = "ComponentsUploadTestUser";
private static final String COMPONENT_ID = "COMPONENT_ID";
private static final String VSP_ID = "vspId";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String TRAP_FILE_NAME = "MMSC.zip";
private static final String POLL_FILE_NAME = "MNS OAM FW.zip";
private static final String VES_FILE_NAME = "vesTest-yml_only.zip";
@@ -54,22 +53,19 @@ public class MonitoringUploadsManagerImplTest {
@Test(expectedExceptions = CoreException.class)
public void testUploadEmptyZip() {
processFile(ZIP_DIR + EMPTY_ZIP_FILE_NAME, inputStream ->
- monitoringUploadsManager.upload(inputStream, EMPTY_ZIP_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.SNMP_TRAP, USER1));
+ monitoringUploadsManager
+ .upload(inputStream, EMPTY_ZIP_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
+ MonitoringUploadType.SNMP_TRAP));
}
- @Test
+ @Test(expectedExceptions = CoreException.class, expectedExceptionsMessageRegExp =
+ "Monitoring file uploaded for vendor software product with Id vspId and version version_id " +
+ "is invalid: Invalid zip file")
public void testUploadInvalidZip() {
-
- try {
- processFile("/notZipFile", inputStream ->
+ processFile("/notZipFile", inputStream ->
monitoringUploadsManager
.upload(inputStream, NOT_ZIP_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.VES_EVENTS, USER1));
- Assert.fail();
- } catch (Exception exception) {
- Assert.assertEquals(exception.getMessage(), "Invalid zip file");
- }
+ MonitoringUploadType.VES_EVENTS));
}
@Test
@@ -78,7 +74,7 @@ public class MonitoringUploadsManagerImplTest {
try {
processFile(ZIP_DIR + ZIP_WITH_FOLDERS_FILE_NAME, inputStream -> monitoringUploadsManager
.upload(inputStream, ZIP_WITH_FOLDERS_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.SNMP_TRAP, USER1));
+ MonitoringUploadType.SNMP_TRAP));
Assert.fail();
} catch (Exception exception) {
Assert.assertEquals(exception.getMessage(), "Zip file should not contain folders");
@@ -91,7 +87,7 @@ public class MonitoringUploadsManagerImplTest {
try {
processFile(ZIP_DIR + INVALID_VES_FILE_NAME, inputStream -> monitoringUploadsManager
.upload(inputStream, INVALID_VES_FILE_NAME, VSP_ID, VERSION, COMPONENT_ID,
- MonitoringUploadType.VES_EVENTS, USER1));
+ MonitoringUploadType.VES_EVENTS));
Assert.fail();
} catch (Exception exception) {
Assert.assertEquals(exception.getMessage(),
@@ -122,18 +118,18 @@ public class MonitoringUploadsManagerImplTest {
.when(componentArtifactDaoMock).list(anyObject());
MonitoringUploadStatus monitoringUploadStatus =
- monitoringUploadsManager.listFilenames(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ monitoringUploadsManager.listFilenames(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(monitoringUploadStatus.getSnmpTrap(), TRAP_FILE_NAME);
Assert.assertEquals(monitoringUploadStatus.getSnmpPoll(), POLL_FILE_NAME);
Assert.assertEquals(monitoringUploadStatus.getVesEvent(), VES_FILE_NAME);
}
- @Test (expectedExceptions = CoreException.class)
+ @Test(expectedExceptions = CoreException.class)
public void testDeleteComponentMibWhenNone() {
doReturn(Optional.empty()).when(componentArtifactDaoMock).getByType(any());
monitoringUploadsManager
- .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL, USER1);
+ .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL);
verify(componentArtifactDaoMock, never()).delete(anyObject());
}
@@ -146,7 +142,7 @@ public class MonitoringUploadsManagerImplTest {
(componentArtifactDaoMock).getByType(anyObject());
monitoringUploadsManager
- .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL, USER1);
+ .delete(VSP_ID, VERSION, COMPONENT_ID, MonitoringUploadType.SNMP_POLL);
verify(componentArtifactDaoMock).delete(anyObject());
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
index ebdbc6af7d..54687dc80d 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NetworkManagerImplTest.java
@@ -53,10 +53,8 @@ public class NetworkManagerImplTest {
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
- private static final String USER1 = "networksTestUser1";
- private static final String USER2 = "networksTestUser2";
private static final String VSP_ID = "vsp";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String NETWORK1_ID = "network1";
private static final String NETWORK2_ID = "network2";
@@ -85,7 +83,7 @@ public class NetworkManagerImplTest {
@Test
public void testListWhenNone() {
Collection<NetworkEntity> networks =
- networkManager.listNetworks(VSP_ID, null, USER1);
+ networkManager.listNetworks(VSP_ID, null);
Assert.assertEquals(networks.size(), 0);
}
@@ -96,7 +94,7 @@ public class NetworkManagerImplTest {
createNetwork(VSP_ID, VERSION, NETWORK2_ID)))
.when(networkDaoMock).list(anyObject());
- Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, VERSION, USER1);
+ Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, VERSION);
Assert.assertEquals(actual.size(), 2);
}
@@ -113,7 +111,7 @@ public class NetworkManagerImplTest {
expected.setNetworkCompositionData(networkData);
- NetworkEntity created = networkManager.createNetwork(expected, USER1);
+ NetworkEntity created = networkManager.createNetwork(expected);
Assert.assertNotNull(created);
expected.setId(created.getId());
expected.setVersion(VERSION01);
@@ -131,12 +129,12 @@ public class NetworkManagerImplTest {
networkData.setName("network1 name");
networkData.setDhcp(true);
network.setNetworkCompositionData(networkData);
- testCreate_negative(network, USER1, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
+ testCreate_negative(network, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
}*/
@Test
public void testCreateOnUploadVsp_negative() {
- testCreate_negative(new NetworkEntity(VSP_ID, VERSION, null), USER1,
+ testCreate_negative(new NetworkEntity(VSP_ID, VERSION, null),
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
@@ -148,7 +146,7 @@ public class NetworkManagerImplTest {
@Test
public void testUpdateNonExistingNetworkId_negative() {
- testUpdate_negative(VSP_ID, VERSION, NETWORK1_ID, USER1,
+ testUpdate_negative(VSP_ID, VERSION, NETWORK1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -171,7 +169,7 @@ public class NetworkManagerImplTest {
networkEntity.setNetworkCompositionData(networkData);
CompositionEntityValidationData validationData =
- networkManager.updateNetwork(networkEntity, USER1);
+ networkManager.updateNetwork(networkEntity);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -180,7 +178,7 @@ public class NetworkManagerImplTest {
@Test
public void testGetNonExistingNetworkId_negative() {
- testGet_negative(VSP_ID, VERSION, NETWORK1_ID, USER1,
+ testGet_negative(VSP_ID, VERSION, NETWORK1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -192,7 +190,7 @@ public class NetworkManagerImplTest {
doReturn("schema string").when(networkManager).getCompositionSchema(anyObject());
CompositionEntityResponse<Network> response =
- networkManager.getNetwork(VSP_ID, VERSION, NETWORK1_ID, USER1);
+ networkManager.getNetwork(VSP_ID, VERSION, NETWORK1_ID);
Assert.assertEquals(response.getId(), network.getId());
Assert.assertEquals(response.getData(), network.getNetworkCompositionData());
Assert.assertNotNull(response.getSchema());
@@ -206,13 +204,13 @@ public class NetworkManagerImplTest {
@Test(dependsOnMethods = "testList")
public void testDeleteNonExistingNetworkId_negative() {
- testDelete_negative(VSP_ID, "non existing network id", USER1, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, "non existing network id", VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}*/
/*
@Test(dependsOnMethods = "testList")
public void testDelete() {
- networkManager.deleteNetwork(VSP_ID, NETWORK1_ID, USER1);
+ networkManager.deleteNetwork(VSP_ID, NETWORK1_ID);
NetworkEntity actual = networkDaoMock.getNetwork(VSP_ID, VERSION01, NETWORK1_ID);
Assert.assertNull(actual);
}
@@ -224,70 +222,69 @@ public class NetworkManagerImplTest {
NetworkEntity network3 = new NetworkEntity(VSP_ID, null, null);
network3.setName("network3 name");
network3.setDescription("network3 desc");
- networkManager.createNetwork(network3, USER1);
+ networkManager.createNetwork(network3);
- networkManager.deleteNetworks(VSP_ID, USER1);
+ networkManager.deleteNetworks(VSP_ID);
- Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, null, USER1);
+ Collection<NetworkEntity> actual = networkManager.listNetworks(VSP_ID, null);
Assert.assertEquals(actual.size(), 0);
}*/
@Test(dependsOnMethods = "testList")
public void testDeleteOnUploadVsp_negative() {
- testDelete_negative(VSP_ID, VERSION, NETWORK1_ID, USER1,
+ testDelete_negative(VSP_ID, VERSION, NETWORK1_ID,
VendorSoftwareProductErrorCodes.VSP_COMPOSITION_EDIT_NOT_ALLOWED);
}
- private void testCreate_negative(NetworkEntity network, String user, String expectedErrorCode) {
+ private void testCreate_negative(NetworkEntity network, String expectedErrorCode) {
try {
- networkManager.createNetwork(network, user);
+ networkManager.createNetwork(network);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testGet_negative(String vspId, Version version, String networkId, String user,
+ private void testGet_negative(String vspId, Version version, String networkId,
String expectedErrorCode) {
try {
- networkManager.getNetwork(vspId, version, networkId, user);
+ networkManager.getNetwork(vspId, version, networkId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testUpdate_negative(String vspId, Version version, String networkId, String user,
+ private void testUpdate_negative(String vspId, Version version, String networkId,
String expectedErrorCode) {
try {
- networkManager.updateNetwork(new NetworkEntity(vspId, version, networkId), user);
+ networkManager.updateNetwork(new NetworkEntity(vspId, version, networkId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testList_negative(String vspId, Version version, String user,
- String expectedErrorCode) {
+ private void testList_negative(String vspId, Version version, String expectedErrorCode) {
try {
- networkManager.listNetworks(vspId, version, user);
+ networkManager.listNetworks(vspId, version);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
- private void testDelete_negative(String vspId, Version version, String networkId, String user,
+ private void testDelete_negative(String vspId, Version version, String networkId,
String expectedErrorCode) {
try {
- networkManager.deleteNetwork(vspId, version, networkId, user);
+ networkManager.deleteNetwork(vspId, version, networkId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
index ba04e91c63..959b501c19 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/NicManagerImplTest.java
@@ -1,10 +1,5 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -35,17 +30,21 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
public class NicManagerImplTest {
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
private static final String NIC_NOT_EXIST_MSG =
"Vendor Software Product NIC with Id nic1 does not exist for Vendor Software Product with " +
- "id VSP_ID and version 0.1";
+ "id VSP_ID and version version_id";
- private static final String USER = "nicTestUser";
private static final String VSP_ID = "VSP_ID";
- private static final Version VERSION = new Version(0, 1);
+ private static final Version VERSION = new Version("version_id");
private static final String COMPONENT_ID = "COMPONENT_ID";
private static final String NIC1_ID = "nic1";
private static final String NIC2_ID = "nic2";
@@ -71,7 +70,7 @@ public class NicManagerImplTest {
@Test
public void testListWhenNone() {
- Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(nics.size(), 0);
}
@@ -85,9 +84,9 @@ public class NicManagerImplTest {
NetworkEntity network1 = NetworkManagerImplTest.createNetwork(VSP_ID, VERSION, NETWORK1_ID);
NetworkEntity network2 = NetworkManagerImplTest.createNetwork(VSP_ID, VERSION, NETWORK2_ID);
doReturn(Arrays.asList(network1, network2))
- .when(networkManagerMock).listNetworks(VSP_ID, VERSION, USER);
+ .when(networkManagerMock).listNetworks(VSP_ID, VERSION);
- Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID, USER);
+ Collection<NicEntity> nics = nicManager.listNics(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(nics.size(), 2);
for (NicEntity nic : nics) {
Assert.assertEquals(nic.getNicCompositionData().getNetworkName(),
@@ -103,12 +102,12 @@ public class NicManagerImplTest {
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.Internal);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
doReturn(nicEntities).when(nicDao).list(anyObject());
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
- NicEntity created = nicManager.createNic(nicEntity,USER);
+ NicEntity created = nicManager.createNic(nicEntity);
Assert.assertNotNull(created);
}
@@ -118,7 +117,7 @@ public class NicManagerImplTest {
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.Internal);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
NicEntity nicEntityDiffName = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
@@ -130,11 +129,11 @@ public class NicManagerImplTest {
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
- exception.code().id());
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
+ Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
+ exception.code().id());
}
}
@@ -144,7 +143,7 @@ public class NicManagerImplTest {
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.Internal);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
NicEntity nicEntityDiffName = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
@@ -156,11 +155,11 @@ public class NicManagerImplTest {
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
- Assert.assertEquals("Invalid request, NIC with name "+ nic.getName() +
- " already exist for component with ID "+ nicEntity.getComponentId() +".",
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
+ Assert.assertEquals("Invalid request, NIC with name " + nic.getName() +
+ " already exist for component with ID " + nicEntity.getComponentId() + ".",
exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes.DUPLICATE_NIC_NAME_NOT_ALLOWED,
exception.code().id());
@@ -173,19 +172,20 @@ public class NicManagerImplTest {
Nic nic = nicEntity.getNicCompositionData();
nic.setNetworkType(NetworkType.External);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
doReturn(nicEntities).when(nicDao).list(anyObject());
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
Assert.assertEquals("Invalid request,NetworkId not allowed for External Networks",
exception.code().message());
- Assert.assertEquals(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK,
- exception.code().id());
+ Assert
+ .assertEquals(VendorSoftwareProductErrorCodes.NETWORKID_NOT_ALLOWED_FOR_EXTERNAL_NETWORK,
+ exception.code().id());
}
}
@@ -196,29 +196,29 @@ public class NicManagerImplTest {
nic.setNetworkType(NetworkType.Internal);
nic.setNetworkDescription(NIC1_ID);
nicEntity.setNicCompositionData(nic);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
Collection<NicEntity> nicEntities = new ArrayList<>();
doReturn(nicEntities).when(nicDao).list(anyObject());
doReturn(nicEntity).when(compositionEntityDataManagerMock).createNic(anyObject());
try {
- NicEntity created = nicManager.createNic(nicEntity,USER);
- } catch (CoreException exception) {
- log.debug("",exception);
+ NicEntity created = nicManager.createNic(nicEntity);
+ } catch (CoreException exception) {
+ log.debug("", exception);
Assert.assertEquals("Invalid request, Network Description not allowed for Internal Networks",
exception.code().message());
Assert.assertEquals(VendorSoftwareProductErrorCodes
- .NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK,exception.code().id());
+ .NETWORK_DESCRIPTION_NOT_ALLOWED_FOR_INTERNAL_NETWORK, exception.code().id());
}
}
@Test
public void testDeleteNic() {
NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
- doReturn(true).when(vspInfoDao).isManual(anyObject(),anyObject());
+ doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
doReturn(nicEntity).when(nicDao).get(anyObject());
- nicManager.deleteNic(VSP_ID,new Version(0,1),COMPONENT_ID,NIC1_ID,USER);
+ nicManager.deleteNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
}
@@ -227,9 +227,12 @@ public class NicManagerImplTest {
NicEntity nicEntity = createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID);
doReturn(nicEntity).when(nicDao).get(anyObject());
+ doReturn("{}").when(nicManager).getNicCompositionSchema(anyObject());
- nicManager.updateNicQuestionnaire(VSP_ID,new Version(0,1),COMPONENT_ID,NIC1_ID,"Ques",USER);
+ nicManager
+ .updateNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "Ques");
+ verify(nicDao).updateQuestionnaireData(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "Ques");
}
// @Test(dependsOnMethods = "testListWhenNone")
@@ -243,7 +246,7 @@ public class NicManagerImplTest {
Nic nicData = new Nic();
nicData.setName("nic1 name");
nic.setNicCompositionData(nicData);
- testCreate_negative(nic, USER, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
+ testCreate_negative(nic, UniqueValueUtil.UNIQUE_VALUE_VIOLATION);
}*/
// @Test(dependsOnMethods = {"testCreate"})
@@ -254,7 +257,7 @@ public class NicManagerImplTest {
// compData12.setDescription("comp12 desc");
// component12.setComponentCompositionData(compData12);
//
-// String component12Id = nicManager.createComponent(component12, USER).getId();
+// String component12Id = nicManager.createComponent(component12).getId();
// testCreate(VSP_ID, component12Id, NETWORK1_ID, NETWORK1_ID.getNetworkCompositionData().getName());
// }
@@ -266,7 +269,7 @@ public class NicManagerImplTest {
@Test
public void testCreateOnUploadVsp_negative() {
- testCreate_negative(new NicEntity(VSP_ID, VERSION, COMPONENT_ID, null), USER,
+ testCreate_negative(new NicEntity(VSP_ID, VERSION, COMPONENT_ID, null),
VendorSoftwareProductErrorCodes.ADD_NIC_NOT_ALLOWED_IN_HEAT_ONBOARDING);
}
@@ -274,7 +277,7 @@ public class NicManagerImplTest {
public void testUpdateNonExistingNicId_negative() {
doReturn(null).when(nicDao).get(anyObject());
- testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER,
+ testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -295,7 +298,7 @@ public class NicManagerImplTest {
nicEntity.setNicCompositionData(nicData);
CompositionEntityValidationData validationData =
- nicManager.updateNic(nicEntity, USER);
+ nicManager.updateNic(nicEntity);
Assert.assertTrue(validationData == null || validationData.getErrors() == null);
verify(nicDao).update(nicEntity);
}
@@ -319,7 +322,7 @@ public class NicManagerImplTest {
nicData.setNetworkId(NETWORK1_ID);
nicEntity.setNicCompositionData(nicData);
- CompositionEntityValidationData validationData = nicManager.updateNic(nicEntity, USER);
+ CompositionEntityValidationData validationData = nicManager.updateNic(nicEntity);
Assert.assertNotNull(validationData);
Assert.assertEquals(validationData.getErrors().size(), 2);
@@ -329,14 +332,14 @@ public class NicManagerImplTest {
@Test
public void testUpdateIncorrectNameFormat() {
doReturn(createNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, NETWORK1_ID))
- .when(nicDao).get(anyObject());
+ .when(nicDao).get(anyObject());
CompositionEntityValidationData toBeReturned =
- new CompositionEntityValidationData(CompositionEntityType.nic, NIC1_ID);
+ new CompositionEntityValidationData(CompositionEntityType.nic, NIC1_ID);
toBeReturned.setErrors(Arrays.asList("error1", "error2"));
doReturn(toBeReturned)
- .when(compositionEntityDataManagerMock)
- .validateEntity(anyObject(), anyObject(), anyObject());
+ .when(compositionEntityDataManagerMock)
+ .validateEntity(anyObject(), anyObject(), anyObject());
doReturn(true).when(vspInfoDao).isManual(anyObject(), anyObject());
NicEntity nicEntity = new NicEntity(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
@@ -347,20 +350,19 @@ public class NicManagerImplTest {
nicEntity.setNicCompositionData(nicData);
try {
- nicManager.updateNic(nicEntity, USER);
+ nicManager.updateNic(nicEntity);
Assert.fail();
- }
- catch (CoreException ex) {
- log.debug("",ex);
+ } catch (CoreException ex) {
+ log.debug("", ex);
Assert.assertEquals(VendorSoftwareProductErrorCodes.NIC_NAME_FORMAT_NOT_ALLOWED,
- ex.code().id());
+ ex.code().id());
}
}
@Test
public void testGetNonExistingNicId_negative() {
- testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing nic id", USER,
+ testGet_negative(VSP_ID, VERSION, COMPONENT_ID, "non existing nic id",
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@@ -373,7 +375,7 @@ public class NicManagerImplTest {
doReturn(compositionSchema).when(nicManager).getNicCompositionSchema(anyObject());
CompositionEntityResponse<Nic> response =
- nicManager.getNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.getNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
Assert.assertEquals(response.getId(), expected.getId());
Assert.assertEquals(response.getData(), expected.getNicCompositionData());
Assert.assertEquals(response.getSchema(), compositionSchema);
@@ -387,32 +389,32 @@ public class NicManagerImplTest {
@Test
public void testDeleteNonExistingNicId_negative() {
- testDelete_negative(VSP_ID, COMPONENT_ID, "non existing nic id", USER, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, COMPONENT_ID, "non existing nic id", VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}
@Test(dependsOnMethods = "testList")
public void testDeleteNonExistingComponentId_negative() {
- testDelete_negative(VSP_ID, "non existing component id", NIC1_ID, USER, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
+ testDelete_negative(VSP_ID, "non existing component id", NIC1_ID, VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
}*/
/*
@Test(dependsOnMethods = "testList")
public void testDelete() {
- nicManager.deleteNic(VSP_ID, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.deleteNic(VSP_ID, COMPONENT_ID, NIC1_ID);
NicEntity actual = vendorSoftwareProductDao.getNic(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
Assert.assertNull(actual);
}*/
@Test
public void testDeleteOnUploadVsp_negative() {
- testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER,
+ testDelete_negative(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID,
VendorSoftwareProductErrorCodes.DELETE_NIC_NOT_ALLOWED);
}
@Test(expectedExceptions = CoreException.class,
expectedExceptionsMessageRegExp = NIC_NOT_EXIST_MSG)
public void testGetNonExistingNicQuestionnaire() throws Exception {
- nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
}
@Test
@@ -425,7 +427,7 @@ public class NicManagerImplTest {
doReturn(schema).when(nicManager).getNicQuestionnaireSchema(anyObject());
QuestionnaireResponse questionnaire =
- nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, USER);
+ nicManager.getNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID);
Assert.assertNotNull(questionnaire);
Assert.assertEquals(questionnaire.getData(), nic.getQuestionnaireData());
Assert.assertEquals(questionnaire.getSchema(), schema);
@@ -437,7 +439,7 @@ public class NicManagerImplTest {
public void testUpdateNonExistingNicQuestionnaire() throws Exception {
doReturn(null).when(nicDao).get(anyObject());
nicManager
- .updateNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "questionnaire data", USER);
+ .updateNicQuestionnaire(VSP_ID, VERSION, COMPONENT_ID, NIC1_ID, "questionnaire data");
}
@Test
@@ -445,46 +447,45 @@ public class NicManagerImplTest {
}
- private void testCreate_negative(NicEntity nic, String user, String expectedErrorCode) {
+ private void testCreate_negative(NicEntity nic, String expectedErrorCode) {
try {
- nicManager.createNic(nic, user);
+ nicManager.createNic(nic);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testGet_negative(String vspId, Version version, String componentId, String nicId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- nicManager.getNic(vspId, version, componentId, nicId, user);
+ nicManager.getNic(vspId, version, componentId, nicId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testUpdate_negative(String vspId, Version version, String componentId, String nicId,
- String user, String expectedErrorCode) {
+ String expectedErrorCode) {
try {
- nicManager.updateNic(new NicEntity(vspId, version, componentId, nicId), user);
+ nicManager.updateNic(new NicEntity(vspId, version, componentId, nicId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
private void testDelete_negative(String vspId, Version version, String componentId, String nicId,
- String user,
String expectedErrorCode) {
try {
- nicManager.deleteNic(vspId, version, componentId, nicId, user);
+ nicManager.deleteNic(vspId, version, componentId, nicId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
index d1cba65182..26ec917546 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImplTest.java
@@ -1,18 +1,14 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
@@ -37,10 +33,13 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Optional;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+
public class OrchestrationTemplateCandidateManagerImplTest {
- private static final String USER1 = "vspTestUser1";
private static final String VSP_ID = "vspId";
- private static final Version VERSION01 = new Version(0, 1);
+ private static final Version VERSION01 = new Version("versionId");
private static final String COMPONENT_ORIG_ID_1 = "Component_Pd_Server_Id_Orig";
private static final String COMPONENT_ORIG_ID_2 = "Component_Sm_Server_Id_Orig";
@@ -58,8 +57,6 @@ public class OrchestrationTemplateCandidateManagerImplTest {
private static final String COMPONENT_NAME_4 = "ps_server";
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
private VendorSoftwareProductInfoDao vspInfoDaoMock;
@Mock
private CandidateService candidateServiceMock;
@@ -67,6 +64,8 @@ public class OrchestrationTemplateCandidateManagerImplTest {
private OrchestrationTemplateDao orchestrationTemplateDaoMock;
@Mock
private ComponentDependencyModelDao componentDependencyModelDaoMock;
+ @Mock
+ private ComponentDao componentDaoMock;
@InjectMocks
private OrchestrationTemplateCandidateManagerImpl candidateManager;
@@ -100,7 +99,7 @@ public class OrchestrationTemplateCandidateManagerImplTest {
doReturn(new VspDetails(VSP_ID, VERSION01))
.when(vspInfoDaoMock).get(anyObject());
doReturn(null)
- .when(orchestrationTemplateDaoMock).getValidationData(anyObject(), anyObject());
+ .when(orchestrationTemplateDaoMock).getInfo(anyObject(), anyObject());
doReturn("{}").when(candidateServiceMock).createManifest(anyObject(), anyObject());
doReturn(Optional.empty()).when(candidateServiceMock)
@@ -109,7 +108,7 @@ public class OrchestrationTemplateCandidateManagerImplTest {
OrchestrationTemplateActionResponse response =
- candidateManager.process(VSP_ID, VERSION01, USER1);
+ candidateManager.process(VSP_ID, VERSION01);
Assert.assertNotNull(response);
}
@@ -118,12 +117,11 @@ public class OrchestrationTemplateCandidateManagerImplTest {
public void testUpdateVspComponentDependenciesHeatReuploadMoreComponents() {
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
- doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ doReturn(existingComponentsDependencies).when(componentDependencyModelDaoMock)
+ .list(anyObject());
Collection<ComponentEntity> componentListWithMoreComponentsInHeat =
getComponentListWithMoreComponentsInHeat();
- doReturn(componentListWithMoreComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithMoreComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
componentIdNameInfoBeforeProcess);
@@ -136,14 +134,14 @@ public class OrchestrationTemplateCandidateManagerImplTest {
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ when(componentDependencyModelDaoMock).list(anyObject());
Collection<ComponentEntity> componentListWithLessComponentsInHeat =
getComponentListWithLessComponentsInHeat();
- doReturn(componentListWithLessComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithLessComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
- orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
- componentIdNameInfoBeforeProcess);
+ orchestrationUtil
+ .updateVspComponentDependencies(anyObject(), anyObject(),
+ componentIdNameInfoBeforeProcess);
Mockito.verify(componentDependencyModelDaoMock, Mockito.times(1)).update(anyObject());
Mockito.verify(componentDependencyModelDaoMock, Mockito.times(1)).delete(anyObject());
}
@@ -152,12 +150,11 @@ public class OrchestrationTemplateCandidateManagerImplTest {
public void testUpdateVspComponentDependenciesHeatReuploadSameComponents() {
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
- doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ doReturn(existingComponentsDependencies).when(componentDependencyModelDaoMock)
+ .list(anyObject());
Collection<ComponentEntity> componentListWithSameComponentsInHeat =
getComponentListWithSameComponentsInHeat();
- doReturn(componentListWithSameComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithSameComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
componentIdNameInfoBeforeProcess);
@@ -169,12 +166,11 @@ public class OrchestrationTemplateCandidateManagerImplTest {
public void testUpdateVspComponentDependenciesHeatReuploadNoComponents() {
Collection<ComponentDependencyModelEntity> existingComponentsDependencies =
getExistingComponentDependencies();
- doReturn(existingComponentsDependencies).
- when(vendorSoftwareProductDaoMock).listComponentDependencies(anyObject(), anyObject());
+ doReturn(existingComponentsDependencies).when(componentDependencyModelDaoMock)
+ .list(anyObject());
Collection<ComponentEntity> componentListWithMoreComponentsInHeat =
new ArrayList<>();
- doReturn(componentListWithMoreComponentsInHeat).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(componentListWithMoreComponentsInHeat).when(componentDaoMock).list(anyObject());
Map<String, String> componentIdNameInfoBeforeProcess = getVspInitComponentIdNameInfo();
orchestrationUtil.updateVspComponentDependencies(anyObject(), anyObject(),
componentIdNameInfoBeforeProcess);
@@ -193,8 +189,7 @@ public class OrchestrationTemplateCandidateManagerImplTest {
@Test
public void testVspComponentIdNameInfo() {
Collection<ComponentEntity> initialVspComponents = getInitialVspComponents();
- doReturn(initialVspComponents).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(initialVspComponents).when(componentDaoMock).list(anyObject());
Map<String, String> vspComponentIdNameInfo =
orchestrationUtil.getVspComponentIdNameInfo(anyObject(), anyObject());
Assert.assertEquals(vspComponentIdNameInfo.size(), 3);
@@ -210,8 +205,7 @@ public class OrchestrationTemplateCandidateManagerImplTest {
componentEntity.setId(COMPONENT_ORIG_ID_4);
initialVspComponents.add(componentEntity);
- doReturn(initialVspComponents).when(vendorSoftwareProductDaoMock)
- .listComponents(anyObject(), anyObject());
+ doReturn(initialVspComponents).when(componentDaoMock).list(anyObject());
Map<String, String> vspComponentIdNameInfo =
orchestrationUtil.getVspComponentIdNameInfo(anyObject(), anyObject());
Assert.assertEquals(vspComponentIdNameInfo.size(), 3);
@@ -250,7 +244,7 @@ public class OrchestrationTemplateCandidateManagerImplTest {
private Collection<ComponentEntity> getComponentListWithLessComponentsInHeat() {
Collection<ComponentEntity> vspComponents = getInitialVspComponents();
- for (Iterator<ComponentEntity> iterator = vspComponents.iterator(); iterator.hasNext();) {
+ for (Iterator<ComponentEntity> iterator = vspComponents.iterator(); iterator.hasNext(); ) {
ComponentEntity componentEntity = iterator.next();
if (componentEntity.getComponentCompositionData().getName().equals(COMPONENT_NAME_1)) {
iterator.remove();
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
index c2a207d6d9..bc3727381b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateProcessCsarHandlerTest.java
@@ -6,14 +6,12 @@ import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
import org.openecomp.core.factory.impl.AbstractFactoryBase;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.CandidateServiceFactoryMock;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.NoSqlDbFactoryMock;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.PackageInfoDaoFactoryImplMock;
-import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.VendorSoftwareProductDaoFactoryMock;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process.OrchestrationTemplateProcessCsarHandler;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -21,27 +19,31 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.nio.ByteBuffer;
import static org.junit.Assert.assertFalse;
-public class OrchestrationTemplateProcessCsarHandlerTest {
-
-
- @Before
- public void insertMocks(){
- EnrichmentManagerFactory.getInstance();
- AbstractFactoryBase.registerFactory(NoSqlDbFactory.class, NoSqlDbFactoryMock.class);
- AbstractFactoryBase.registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
- AbstractFactoryBase.registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
- AbstractFactoryBase.registerFactory(VendorSoftwareProductDaoFactory.class, VendorSoftwareProductDaoFactoryMock.class);
- AbstractFactoryBase.registerFactory(CandidateServiceFactory.class, CandidateServiceFactoryMock.class);
- }
+public class OrchestrationTemplateProcessCsarHandlerTest {
- @Test
- public void validateErrorHandling(){
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = new OrchestrationTemplateCandidateData(ByteBuffer.wrap("".getBytes()),"");
- OrchestrationTemplateProcessCsarHandler handler = new OrchestrationTemplateProcessCsarHandler();
- OrchestrationTemplateActionResponse response = handler.process(vspDetails, orchestrationTemplateCandidateData, "007");
- assertFalse(response.getErrors().isEmpty());
- }
+ @Before
+ public void insertMocks() {
+ EnrichmentManagerFactory.getInstance();
+ AbstractFactoryBase.registerFactory(NoSqlDbFactory.class, NoSqlDbFactoryMock.class);
+ AbstractFactoryBase
+ .registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
+ AbstractFactoryBase
+ .registerFactory(PackageInfoDaoFactory.class, PackageInfoDaoFactoryImplMock.class);
+ AbstractFactoryBase
+ .registerFactory(CandidateServiceFactory.class, CandidateServiceFactoryMock.class);
+ }
+
+
+ @Test
+ public void validateErrorHandling() {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ OrchestrationTemplateCandidateData orchestrationTemplateCandidateData =
+ new OrchestrationTemplateCandidateData(ByteBuffer.wrap("".getBytes()), "", "zip", "file");
+ OrchestrationTemplateProcessCsarHandler handler = new OrchestrationTemplateProcessCsarHandler();
+ OrchestrationTemplateActionResponse response =
+ handler.process(vspDetails, orchestrationTemplateCandidateData);
+ assertFalse(response.getErrors().isEmpty());
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java
index 478bdfbbba..b925ab9270 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/ProcessManagerImplTest.java
@@ -1,19 +1,18 @@
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Captor;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessType;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -28,12 +27,13 @@ import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Collection;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
-import static org.mockito.Matchers.eq;
public class ProcessManagerImplTest {
@@ -48,9 +48,7 @@ public class ProcessManagerImplTest {
private static final String ARTIFACT_NAME = "artifact.sh";
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
- private ActivityLogManager activityLogManagerMock;
+ private ProcessDao processDaoMock;
@InjectMocks
@Spy
@@ -66,7 +64,7 @@ public class ProcessManagerImplTest {
@Test
public void testListWhenNone() {
Collection<ProcessEntity> processes =
- processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(processes.size(), 0);
}
@@ -75,17 +73,17 @@ public class ProcessManagerImplTest {
doReturn(Arrays.asList(
createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID),
createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS2_ID)))
- .when(vendorSoftwareProductDaoMock).listProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ .when(processDaoMock).list(any(ProcessEntity.class));
Collection<ProcessEntity> actual =
- processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ processManager.listProcesses(VSP_ID, VERSION, COMPONENT_ID);
Assert.assertEquals(actual.size(), 2);
}
@Test
public void testDeleteListWhenNone() {
- processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
- verify(vendorSoftwareProductDaoMock, never()).deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ verify(processDaoMock, never()).delete(any(ProcessEntity.class));
}
@Test
@@ -93,15 +91,15 @@ public class ProcessManagerImplTest {
ProcessEntity process1 = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
ProcessEntity process2 = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS2_ID);
doReturn(Arrays.asList(process1, process2))
- .when(vendorSoftwareProductDaoMock).listProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ .when(processDaoMock).list(any(ProcessEntity.class));
doNothing().when(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, process1.getName());
doNothing().when(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, process2.getName());
- processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID, USER1);
+ processManager.deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
- verify(vendorSoftwareProductDaoMock).deleteProcesses(VSP_ID, VERSION, COMPONENT_ID);
+ verify(processDaoMock).deleteAll(eq(new ProcessEntity(VSP_ID, VERSION, COMPONENT_ID, null)));
verify(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, process1.getName());
verify(processManager)
@@ -118,7 +116,7 @@ public class ProcessManagerImplTest {
doNothing().when(processManager)
.createUniqueName(VSP_ID, VERSION, COMPONENT_ID, processToCreate.getName());
- ProcessEntity process = processManager.createProcess(processToCreate, USER1);
+ ProcessEntity process = processManager.createProcess(processToCreate);
Assert.assertNotNull(process);
process.setId(process.getId());
@@ -134,13 +132,12 @@ public class ProcessManagerImplTest {
new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
.when(processManager).validateUniqueName(VSP_ID, VERSION, COMPONENT_ID, process.getName());
- processManager.createProcess(process, USER1);
+ processManager.createProcess(process);
}
@Test
public void testUpdateNonExistingProcessId_negative() {
- doReturn(null).when(vendorSoftwareProductDaoMock)
- .getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(null).when(processDaoMock).get(any(ProcessEntity.class));
testUpdate_negative(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1,
VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
@@ -149,8 +146,7 @@ public class ProcessManagerImplTest {
@Test(expectedExceptions = CoreException.class)
public void testUpdateWithExistingName_negative() {
ProcessEntity existingProcess = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(existingProcess).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(existingProcess).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity processToUpdate = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
doThrow(new CoreException(
@@ -159,22 +155,21 @@ public class ProcessManagerImplTest {
.updateUniqueName(VSP_ID, VERSION, COMPONENT_ID, existingProcess.getName(),
processToUpdate.getName());
- processManager.updateProcess(processToUpdate, USER1);
+ processManager.updateProcess(processToUpdate);
}
@Test
public void testUpdate() {
ProcessEntity existingProcess = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(existingProcess).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(existingProcess).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity processToUpdate = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
doNothing().when(processManager)
.updateUniqueName(VSP_ID, VERSION, COMPONENT_ID, existingProcess.getName(),
processToUpdate.getName());
- processManager.updateProcess(processToUpdate, USER1);
- verify(vendorSoftwareProductDaoMock).updateProcess(processToUpdate);
+ processManager.updateProcess(processToUpdate);
+ verify(processDaoMock).update(processToUpdate);
}
@@ -187,10 +182,9 @@ public class ProcessManagerImplTest {
@Test
public void testGet() {
ProcessEntity process = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(process).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(process).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity actual =
- processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
Assert.assertEquals(actual, process);
Assert.assertNull(actual.getArtifactName());
}
@@ -199,29 +193,28 @@ public class ProcessManagerImplTest {
public void testGetAfterUploadArtifact() {
ProcessEntity process = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
process.setArtifactName(ARTIFACT_NAME);
- doReturn(process).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(process).when(processDaoMock).get(any(ProcessEntity.class));
ProcessEntity actual =
- processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
Assert.assertEquals(actual, process);
Assert.assertEquals(actual.getArtifactName(), ARTIFACT_NAME);
}
@Test(expectedExceptions = CoreException.class)
public void testDeleteNonExistingProcessId_negative() {
- processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
}
@Test
public void testDelete() {
ProcessEntity processToDelete = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(processToDelete).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(processToDelete).when(processDaoMock)
+ .get(any(ProcessEntity.class));
doNothing().when(processManager).deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID,
processToDelete.getName());
- processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
- verify(vendorSoftwareProductDaoMock).deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ processManager.deleteProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ verify(processDaoMock).delete(any(ProcessEntity.class));
verify(processManager)
.deleteUniqueValue(VSP_ID, VERSION, COMPONENT_ID, processToDelete.getName());
}
@@ -235,21 +228,13 @@ public class ProcessManagerImplTest {
@Test
public void testUploadArtifact() {
ProcessEntity process = createProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
- doReturn(process).when
- (vendorSoftwareProductDaoMock).getProcess(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(process).when(processDaoMock).get(any(ProcessEntity.class));
byte[] artifactBytes = "bla bla".getBytes();
processManager
.uploadProcessArtifact(new ByteArrayInputStream(artifactBytes), ARTIFACT_NAME,
- VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
- verify(vendorSoftwareProductDaoMock)
- .uploadProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, artifactBytes,
- ARTIFACT_NAME);
-
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION.getMajor()+1));
- Assert.assertTrue(activityLogEntity.isSuccess());
+ VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ verify(processDaoMock).uploadArtifact(any(ProcessEntity.class));
}
@Test
@@ -269,11 +254,11 @@ public class ProcessManagerImplTest {
ProcessEntity processArtifact =
new ProcessEntity(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
processArtifact.setArtifact(ByteBuffer.wrap("bla bla".getBytes()));
- doReturn(processArtifact).when(vendorSoftwareProductDaoMock)
- .getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(processArtifact).when(processDaoMock)
+ .getArtifact(any(ProcessEntity.class));
File actual =
- processManager.getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
+ processManager.getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
Assert.assertNotNull(actual);
}
@@ -294,12 +279,12 @@ public class ProcessManagerImplTest {
ProcessEntity processArtifact =
new ProcessEntity(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
processArtifact.setArtifact(ByteBuffer.wrap("bla bla".getBytes()));
- doReturn(processArtifact).when(vendorSoftwareProductDaoMock)
- .getProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ doReturn(processArtifact).when(processDaoMock)
+ .getArtifact(any(ProcessEntity.class));
- processManager.deleteProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID, USER1);
- verify(vendorSoftwareProductDaoMock)
- .deleteProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ processManager.deleteProcessArtifact(VSP_ID, VERSION, COMPONENT_ID, PROCESS1_ID);
+ verify(processDaoMock)
+ .deleteArtifact(any(ProcessEntity.class));
}
@@ -315,10 +300,10 @@ public class ProcessManagerImplTest {
private void testGet_negative(String vspId, Version version, String componentId, String processId,
String user, String expectedErrorCode) {
try {
- processManager.getProcess(vspId, version, componentId, processId, user);
+ processManager.getProcess(vspId, version, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -328,10 +313,10 @@ public class ProcessManagerImplTest {
String expectedErrorCode) {
try {
processManager
- .updateProcess(new ProcessEntity(vspId, version, componentId, processId), user);
+ .updateProcess(new ProcessEntity(vspId, version, componentId, processId));
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -339,10 +324,10 @@ public class ProcessManagerImplTest {
private void testGetFile_negative(String vspId, Version version, String componentId,
String processId, String user, String expectedErrorCode) {
try {
- processManager.getProcessArtifact(vspId, version, componentId, processId, user);
+ processManager.getProcessArtifact(vspId, version, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -353,10 +338,10 @@ public class ProcessManagerImplTest {
try {
processManager
.uploadProcessArtifact(new ByteArrayInputStream("bla bla".getBytes()), "artifact.sh",
- vspId, version, componentId, processId, user);
+ vspId, version, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.error("",exception);
+ log.error("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
@@ -364,10 +349,10 @@ public class ProcessManagerImplTest {
private void testDeleteArtifact_negative(String vspId, String componentId, String processId,
String user, String expectedErrorCode) {
try {
- processManager.deleteProcessArtifact(vspId, VERSION, componentId, processId, user);
+ processManager.deleteProcessArtifact(vspId, VERSION, componentId, processId);
Assert.fail();
} catch (CoreException exception) {
- log.debug("",exception);
+ log.debug("", exception);
Assert.assertEquals(exception.code().id(), expectedErrorCode);
}
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
index 5199dfd365..7721817c3b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
@@ -33,15 +33,12 @@ import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.file.FileUtils;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.healing.api.HealingManager;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
@@ -53,18 +50,16 @@ import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.EnrichmentManagerFactoryImpl;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.versioning.VersioningManager;
import org.openecomp.sdc.versioning.dao.types.Version;
@@ -94,7 +89,6 @@ import java.util.zip.ZipInputStream;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
@@ -103,13 +97,10 @@ import static org.mockito.Mockito.verify;
public class VendorSoftwareProductManagerImplTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(VendorSoftwareProductManagerImplTest.class);
-
private static final String INVALID_VERSION_MSG = "Invalid requested version.";
- private static final String VSP_ID = "vspId";
- private static final String VERSION_ID = "versionId";
+ private static String VSP_ID = "vspId";
+ private static String VERSION_ID = "versionId";
public static final Version VERSION01 = new Version(0, 1);
private static final Version VERSION10 = new Version(1, 0);
private static final String USER1 = "vspTestUser1";
@@ -121,8 +112,6 @@ public class VendorSoftwareProductManagerImplTest {
@Mock
private VersioningManager versioningManagerMock;
@Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock; // todo get rid of
- @Mock
private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
@Mock
private VendorLicenseFacade vendorLicenseFacadeMock;
@@ -139,8 +128,6 @@ public class VendorSoftwareProductManagerImplTest {
@Mock
private InformationArtifactGenerator informationArtifactGeneratorMock;
@Mock
- private ActivityLogManager activityLogManagerMock;
- @Mock
private PackageInfoDao packageInfoDao;
@Mock
private VendorSoftwareProductInfoDao vspInfoDaoMock;
@@ -164,14 +151,14 @@ public class VendorSoftwareProductManagerImplTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
-
+/*
@Test
public void testListWhenNone() {
doReturn(new HashMap<>()).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(null, USER1);
+ vendorSoftwareProductManager.listVsps(null);
Assert.assertEquals(vsps.size(), 0);
}
@@ -190,16 +177,16 @@ public class VendorSoftwareProductManagerImplTest {
vspsTobeReturned.put(vsp2id, versionInfo2);
doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
VspDetails vsp1 = new VspDetails(vsp1id, VERSION01);
vsp1.setWritetimeMicroSeconds(8L);
doReturn(vsp1).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(null, USER1);
+ vendorSoftwareProductManager.listVsps(null);
Assert.assertEquals(vsps.size(), 2);
}
@@ -218,11 +205,11 @@ public class VendorSoftwareProductManagerImplTest {
vspsTobeReturned.put(vsp2id, versionInfo2);
doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1);
+ vendorSoftwareProductManager.listVsps(VersionStatus.Certified.name());
Assert.assertEquals(vsps.size(), 0);
}
@@ -242,53 +229,36 @@ public class VendorSoftwareProductManagerImplTest {
vspsTobeReturned.put(vsp2id, versionInfo2);
doReturn(vspsTobeReturned).when(versioningManagerMock).listEntitiesVersionInfo
- (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
- VersionableEntityAction.Read);
+ (VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, USER1,
+ VersionableEntityAction.Read);
VspDetails vsp2 = new VspDetails(vsp2id, VERSION10);
vsp2.setWritetimeMicroSeconds(8L);
doReturn(vsp2).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
List<VersionedVendorSoftwareProductInfo> vsps =
- vendorSoftwareProductManager.listVsps(VersionStatus.Final.name(), USER1);
+ vendorSoftwareProductManager.listVsps(VersionStatus.Certified.name());
Assert.assertEquals(vsps.size(), 1);
- }
+ }*/
- @Test(expectedExceptions = CoreException.class)
- public void testCreateWithExistingName_negative() {
- doThrow(new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
- .when(vendorSoftwareProductManager).validateUniqueName("Vsp1");
- VspDetails expectedVsp =
- createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "123", null);
-
- vendorSoftwareProductManager.createVsp(expectedVsp, USER1);
- }
@Test
public void testCreate() {
- doNothing().when(vendorSoftwareProductManager).validateUniqueName("Vsp1");
- doNothing().when(vendorSoftwareProductManager).createUniqueName("Vsp1");
- doReturn(VERSION01).when(versioningManagerMock).create(anyObject(), anyObject(), anyObject());
+ //doReturn(VERSION01).when(versioningManagerMock).create(anyObject(), anyObject(), anyObject());
doReturn("{}")
- .when(vendorSoftwareProductManager).getVspQuestionnaireSchema(anyObject());
+ .when(vendorSoftwareProductManager).getVspQuestionnaireSchema(anyObject());
VspDetails vspToCreate =
- createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "123", null);
+ createVspDetails(null, null, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "123", null);
- VspDetails vsp = vendorSoftwareProductManager.createVsp(vspToCreate, USER1);
+ VspDetails vsp = vendorSoftwareProductManager.createVsp(vspToCreate);
Assert.assertNotNull(vsp);
vspToCreate.setId(vsp.getId());
vspToCreate.setVersion(VERSION01);
assertVspsEquals(vsp, vspToCreate);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
}
@Test(expectedExceptions = CoreException.class)
@@ -296,23 +266,23 @@ public class VendorSoftwareProductManagerImplTest {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Write);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Write);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-existingVsp", "vendorName", "vlm1Id",
- "icon", "category", "subCategory", "123", null);
+ createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-existingVsp", "vendorName", "vlm1Id",
+ "icon", "category", "subCategory", "123", null);
VspDetails updatedVsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1_updated", "Test-existingVsp", "vendorName",
- "vlm1Id", "icon", "category", "subCategory", "123", null);
+ createVspDetails(VSP_ID, VERSION01, "Vsp1_updated", "Test-existingVsp", "vendorName",
+ "vlm1Id", "icon", "category", "subCategory", "123", null);
doReturn(existingVsp).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
doThrow(new CoreException(
- new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
- .when(vendorSoftwareProductManager)
- .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
+ new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).build()))
+ .when(vendorSoftwareProductManager)
+ .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
- vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
+ vendorSoftwareProductManager.updateVsp(updatedVsp);
}
@Test
@@ -320,23 +290,23 @@ public class VendorSoftwareProductManagerImplTest {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Write);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Write);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", null);
VspDetails updatedVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
- "category_updated",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
+ "category_updated",
+ "subCategory", "456", null);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
doNothing().when(vendorSoftwareProductManager)
- .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
+ .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
- vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
+ vendorSoftwareProductManager.updateVsp(updatedVsp);
verify(vspInfoDaoMock).update(updatedVsp);
}
@@ -346,40 +316,41 @@ public class VendorSoftwareProductManagerImplTest {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Write);
- List<String> fgs = new ArrayList<>();
- fgs.add("fg1"); fgs.add("fg2");
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Write);
+ List<String> fgs = new ArrayList<String>();
+ fgs.add("fg1");
+ fgs.add("fg2");
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", fgs);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", fgs);
- List<String> updFgs = new ArrayList<>();
- updFgs.add("fg2");
+ List<String> updFgs = new ArrayList<String>();
+ //updFgs.add("fg2");
VspDetails updatedVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
- "category_updated",
- "subCategory", "456", updFgs);
+ createVspDetails(VSP_ID, VERSION01, "VSP1_updated", null, "vendorName", "vlm1Id", "icon",
+ "category_updated",
+ "subCategory", "456", updFgs);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock)
- .get(any(VspDetails.class));
+ .get(any(VspDetails.class));
doNothing().when(vendorSoftwareProductManager)
- .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
+ .updateUniqueName(existingVsp.getName(), updatedVsp.getName());
- DeploymentFlavorEntity dfEntity = new DeploymentFlavorEntity(VSP_ID,VERSION01,"DF_ID");
+ DeploymentFlavorEntity dfEntity = new DeploymentFlavorEntity(VSP_ID, VERSION01, "DF_ID");
DeploymentFlavor flavor = new DeploymentFlavor();
flavor.setFeatureGroupId("fg1");
dfEntity.setDeploymentFlavorCompositionData(flavor);
- List<DeploymentFlavorEntity> dfList = new ArrayList<>();
+ List<DeploymentFlavorEntity> dfList = new ArrayList<DeploymentFlavorEntity>();
dfList.add(dfEntity);
doReturn(dfList).when(deploymentFlavorDaoMock).list(anyObject());
- vendorSoftwareProductManager.updateVsp(updatedVsp, USER1);
+ vendorSoftwareProductManager.updateVsp(updatedVsp);
- verify(vendorSoftwareProductDaoMock).updateDeploymentFlavor(dfEntity);
+ verify(deploymentFlavorDaoMock).update(dfEntity);
Assert.assertNull(dfEntity.getDeploymentFlavorCompositionData().getFeatureGroupId());
@@ -389,7 +360,7 @@ public class VendorSoftwareProductManagerImplTest {
public void testGetNonExistingVersion_negative() {
Version notExistversion = new Version(43, 8);
doReturn(null).when(vspInfoDaoMock).get(any(VspDetails.class));
- vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion, USER1);
+ vendorSoftwareProductManager.getVsp(VSP_ID, notExistversion);
}
@Test
@@ -399,18 +370,18 @@ public class VendorSoftwareProductManagerImplTest {
versionInfo.setStatus(VersionStatus.Locked);
versionInfo.setLockingUser(USER1);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Read);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", null);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp).when(vspInfoDaoMock).get(any(VspDetails.class));
VspDetails actualVsp =
- vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1);
+ vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01);
assertVspsEquals(actualVsp, existingVsp);
}
@@ -423,84 +394,26 @@ public class VendorSoftwareProductManagerImplTest {
versionInfo.setStatus(VersionStatus.Locked);
versionInfo.setLockingUser(USER2);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Read);
VspDetails existingVsp =
- createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
- "category",
- "subCategory", "456", null);
+ createVspDetails(VSP_ID, VERSION01, "VSP1", null, "vendorName", "vlm1Id", "icon",
+ "category",
+ "subCategory", "456", null);
existingVsp.setWritetimeMicroSeconds(8L);
doReturn(existingVsp)
- .when(vspInfoDaoMock).get(any(VspDetails.class));
+ .when(vspInfoDaoMock).get(any(VspDetails.class));
VspDetails actualVsp =
- vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01, USER1);
+ vendorSoftwareProductManager.getVsp(VSP_ID, VERSION01);
VspDetails expectedVsp =
- vspInfoDaoMock
- .get(new VspDetails(VSP_ID, VERSION01));
+ vspInfoDaoMock
+ .get(new VspDetails(VSP_ID, VERSION01));
assertVspsEquals(actualVsp, expectedVsp);
}
- @Test
- public void testCheckin() {
- doReturn(VERSION01).when(versioningManagerMock)
- .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
- Version version = vendorSoftwareProductManager.checkin(VSP_ID, USER1);
-
- Assert.assertEquals(version, VERSION01);
- verify(versioningManagerMock)
- .checkin(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
- @Test
- public void testCheckout() {
- doReturn(VERSION01).when(versioningManagerMock)
- .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1);
- Version version = vendorSoftwareProductManager.checkout(VSP_ID, USER1);
-
- Assert.assertEquals(version, VERSION01);
- verify(versioningManagerMock)
- .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1);
-
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
-
- @Test
- public void testUndoCheckout() {
- Version existingVersion = new Version(0, 2);
- VersionInfo versionInfo = new VersionInfo();
- versionInfo.setActiveVersion(existingVersion);
- doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- VSP_ID, USER1, VersionableEntityAction.Read);
-
- doReturn(VERSION01).when(versioningManagerMock).undoCheckout(VendorSoftwareProductConstants
- .VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1);
-
- VspDetails vsp = new VspDetails(VSP_ID, existingVersion);
- vsp.setName("ExistingName");
- doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
- doNothing().when(vendorSoftwareProductManager).updateUniqueName(vsp.getName(), vsp.getName());
-
- Version undoCheckoutVersion = vendorSoftwareProductManager.undoCheckout(VSP_ID, USER1);
-
- Assert.assertEquals(undoCheckoutVersion, VERSION01);
- }
-
/*
@Test
public void testSubmitWithMissingData() throws IOException {
@@ -551,35 +464,33 @@ public class VendorSoftwareProductManagerImplTest {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- VSP_ID, USER1, VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
+ VSP_ID, USER1, VersionableEntityAction.Read);
VspDetails vsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "licenseAgreementId",
- Collections.singletonList("featureGroupId"));
+ createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "licenseAgreementId",
+ Collections.singletonList("featureGroupId"));
doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
- UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01);
+ OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity(VSP_ID, VERSION01);
uploadData.setContentData(
- ByteBuffer.wrap(getBytes("/emptyComposition")));
+ ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition"))));
doReturn(uploadData).when(orchestrationTemplateDataDaoMock)
- .getOrchestrationTemplate(anyObject(), anyObject());
+ .get(anyObject(), anyObject());
doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(),
- "MainServiceTemplate.yaml"))
- .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
+ "MainServiceTemplate.yaml"))
+ .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
- ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
+ ValidationResponse validationResponse =
+ vendorSoftwareProductManager.validate(VSP_ID, VERSION01);
Assert.assertNotNull(validationResponse);
Assert.assertFalse(validationResponse.isValid());
Assert.assertNull(validationResponse.getVspErrors());
- Assert.assertEquals(validationResponse.getLicensingDataErrors(), 1);
+ Assert.assertEquals(validationResponse.getLicensingDataErrors().size(), 1);
verify(versioningManagerMock, never())
- .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
-
- //TODO - check..
- verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1));
+ .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
+ USER1, null);
}
// TODO: 3/15/2017 fix and enable
@@ -589,40 +500,32 @@ public class VendorSoftwareProductManagerImplTest {
EnrichmentManagerFactory.getInstance();
AbstractFactoryBase
- .registerFactory(EnrichmentManagerFactory.class, EnrichmentManagerFactoryImpl.class);
+ .registerFactory(EnrichmentManagerFactory.class, EnrichmentManagerFactoryImpl.class);
VspDetails vsp =
- createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
- "category", "subCategory", "123", Collections.singletonList("fg1"));
+ createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "123", Collections.singletonList("fg1"));
doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
- UploadDataEntity uploadData = new UploadDataEntity(VSP_ID, VERSION01);
+ OrchestrationTemplateEntity uploadData = new OrchestrationTemplateEntity(VSP_ID, VERSION01);
uploadData.setContentData(
- ByteBuffer.wrap(getBytes("/emptyComposition")));
+ ByteBuffer.wrap(FileUtils.toByteArray(getFileInputStream("/emptyComposition"))));
doReturn(uploadData).when(orchestrationTemplateDataDaoMock)
- .getOrchestrationTemplate(anyObject(), anyObject());
+ .get(anyObject(), anyObject());
doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(),
- "MainServiceTemplate.yaml"))
- .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
+ "MainServiceTemplate.yaml"))
+ .when(serviceModelDaoMock).getServiceModel(VSP_ID, VERSION01);
- ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
+ ValidationResponse validationResponse =
+ vendorSoftwareProductManager.validate(VSP_ID, VERSION01);
Assert.assertTrue(validationResponse.isValid());
-/* Assert.assertEquals(vsp2.getVersionInfo().getActiveVersion(), VERSION10);
- Assert.assertEquals(vsp2.getVersionInfo().getStatus(), VersionStatus.Final);
+/* Assert.assertEquals(vsp2.getVersionInfo().getVersion(), VERSION10);
+ Assert.assertEquals(vsp2.getVersionInfo().getStatus(), VersionStatus.Certified);
Assert.assertNull(vsp2.getVersionInfo().getLockingUser());*/
verify(versioningManagerMock)
- .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
- USER1, null);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
- ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor()));
- Assert.assertTrue(activityLogEntity.isSuccess());
- }
-
- @Test(expectedExceptions = CoreException.class)
- public void testCreatePackageOnNonFinalVersion_negative() throws IOException {
- vendorSoftwareProductManager.createPackage(VSP_ID, VERSION01, USER1);
+ .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
+ USER1, null);
}
@Test
@@ -632,11 +535,11 @@ public class VendorSoftwareProductManagerImplTest {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION10);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- VersionableEntityAction.Read);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ VersionableEntityAction.Read);
doReturn(new ToscaServiceModel(new FileContentHandler(), new HashMap<>(), "")).when
- (enrichedServiceModelDaoMock).getServiceModel(VSP_ID, VERSION10);
+ (enrichedServiceModelDaoMock).getServiceModel(VSP_ID, VERSION10);
VspDetails vsp = new VspDetails(VSP_ID, VERSION10);
vsp.setVendorId("vendorId");
@@ -645,20 +548,20 @@ public class VendorSoftwareProductManagerImplTest {
doReturn(vsp).when(vspInfoDaoMock).get(any(VspDetails.class));
doReturn(new FileContentHandler()).when(licenseArtifactsServiceMock)
- .createLicenseArtifacts(VSP_ID, vsp.getVendorId(), VERSION10, vsp.getFeatureGroups(),
- USER1);
+ .createLicenseArtifacts(VSP_ID, vsp.getVendorId(), VERSION10, vsp.getFeatureGroups()
+ );
- PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(VSP_ID, VERSION10, USER1);
+ PackageInfo packageInfo = vendorSoftwareProductManager.createPackage(VSP_ID, VERSION10);
Assert.assertNotNull(packageInfo.getVspId());
}
// TODO: 3/15/2017 fix and enable
//@Test(dependsOnMethods = {"testListFinals"})
public void testUploadFileMissingFile() throws IOException {
+ try (InputStream zis = getFileInputStream("/vspmanager/zips/missingYml.zip")) {
- try (InputStream zis = this.getClass().getResourceAsStream("/vspmanager/zips/missingYml.zip")) {
UploadFileResponse uploadFileResponse =
- candidateManager.upload(VSP_ID, VERSION01, zis, USER1, "zip", "missingYml");
+ candidateManager.upload(VSP_ID, VERSION01, zis, "zip", "file");
Assert.assertEquals(uploadFileResponse.getErrors().size(), 0);
}
@@ -667,38 +570,130 @@ public class VendorSoftwareProductManagerImplTest {
// TODO: 3/15/2017 fix and enable
//@Test(dependsOnMethods = {"testUploadFileMissingFile"})
public void testUploadNotZipFile() throws IOException {
-
URL url = this.getClass().getResource("/notZipFile");
- try (InputStream inputStream = url.openStream()) {
- candidateManager
- .upload(VSP_ID, VERSION01,
- inputStream, USER1, "zip", "notZipFile");
- candidateManager.process(VSP_ID, VERSION01, USER1);
+ try {
+ candidateManager.upload(VSP_ID, VERSION01, url.openStream(), "zip", "file");
+ candidateManager.process(VSP_ID, VERSION01);
} catch (Exception ce) {
Assert.assertEquals(ce.getMessage(), Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
}
+ }
+/*
+ @Test
+ public void testEnrichModelInSubmit() {
+ UniqueValueUtil
+ .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
+ "VSP_syb");
+ VspDetails vspDetails = vendorSoftwareProductManager.createVsp(
+ createVspDetails(null, null, "VSP_syb", "Test-vsp_syb", "vendorName", "vlm1Id", "icon",
+ "category", "subCategory", "456", null), USER1);
+ String id = vspDetails.getId();
+
+ //upload file
+ InputStream zis = getFileInputStream("/vspmanager/zips/fullComposition.zip");
+ candidateManager.upload(id, VERSION01, zis, USER1);
+ OrchestrationTemplateActionResponse uploadFileResponse =
+ candidateManager.process(id, VERSION01, USER1);
+
+ //check in
+ vendorSoftwareProductManager.checkin(id, USER1);
+ //submit
+ try {
+ ValidationResponse result = vendorSoftwareProductManager.submit(id, USER1);
+ } catch (IOException exception) {
+ Assert.fail();
+ }
+ VersionedVendorSoftwareProductInfo details =
+ vendorSoftwareProductManager.getVsp(id, null, USER1);
+ Collection<ComponentEntity> components =vendorSoftwareProductManager
+ .listComponents(id, details.getVersionInfo().getVersion(), USER1);
+
+ ToscaServiceModel model =
+ (ToscaServiceModel) EnrichedServiceModelDaoFactory.getInstance().createInterface()
+ .getServiceModel(id, details.getVersionInfo().getVersion());
+
+ Map<String, CapabilityDefinition> capabilities = new HashMap<>();
+ for (ComponentEntity component : components) {
+ model.getServiceTemplates().
+ entrySet().
+ stream().
+ filter(entryValue -> entryValue.getValue() != null &&
+ entryValue.getValue().getNode_types() != null &&
+ entryValue.getValue().
+ getNode_types().
+ containsKey(component.getComponentCompositionData().getName())).
+ forEach(entryValue -> entryValue.getValue().getNode_types().
+ values().
+ stream().
+ filter(type -> MapUtils.isNotEmpty(type.getCapabilities())).
+ forEach(type -> type.getCapabilities().
+ entrySet().
+ forEach(entry -> addCapability(entryValue.getKey(), capabilities, entry.getKey(),
+ entry.getValue()))));
+
+ }
+
+ Assert.assertNotNull(capabilities);
+ }
+
+ @Test(dependsOnMethods = {"testCreatePackage"})
+ public void testEnrichedFilesDeletedOnNewUpload() throws IOException {
+ Version activeVersion;
+
+ createPackageFromUpload(VSP_ID, USER1, "/fullComposition");
+ activeVersion = vendorSoftwareProductManager.getVsp(VSP_ID, null, USER1).getVersionInfo()
+ .getVersion();
+
+ List<ServiceArtifact> firstExternalArtifacts = enrichedServiceModelDaoMock
+ .getExternalArtifacts(VSP_ID, activeVersion);
+ ToscaServiceModel firstServiceModel = enrichedServiceModelDaoMock.getServiceModel(VSP_ID,
+ activeVersion);
+
+ createPackageFromUpload(VSP_ID, USER1, "/emptyComposition");
+ activeVersion = vendorSoftwareProductManager.getVsp(VSP_ID, null, USER1).getVersionInfo()
+ .getVersion();
+
+ List<ServiceArtifact> secondExternalArtifacts = enrichedServiceModelDaoMock
+ .getExternalArtifacts(VSP_ID, activeVersion);
+ ToscaServiceModel secondServiceModel = enrichedServiceModelDaoMock.getServiceModel(VSP_ID,
+ activeVersion);
+
+ Assert.assertNotEquals(firstExternalArtifacts, secondExternalArtifacts);
+ Assert.assertNotEquals(firstServiceModel, secondServiceModel);
- verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1));
}
+ @Test(dependsOnMethods = {"testMibsDeletedInCsar"})
+ public void testServiceTemplatesAreDeletedInCsarOnNewUpload() throws IOException {
+ String nestedPath = "Definitions" + File.separator + "nested";
+
+ uploadFileAndProcess(VSP_ID, USER1, "/vspmanager/zips/fullCompositionNested.zip");
+ checkinSubmitCreatePackage(VSP_ID, USER1);
+ List<String> nestedFileNamesServiceTemplates =
+ getWantedFileNamesFromCsar(nestedPath);
+
+ uploadFileAndProcess(VSP_ID, USER1, "/vspmanager/zips/fullComposition.zip");
+ checkinSubmitCreatePackage(VSP_ID, USER1);
+ List<String> emptyNestedNamesList = getWantedFileNamesFromCsar(nestedPath);
+
+ Assert.assertEquals(emptyNestedNamesList.size(), 0);
+ Assert.assertNotEquals(emptyNestedNamesList.size(), nestedFileNamesServiceTemplates.size());
+ }*/
private List<String> getWantedFileNamesFromCsar(String pathInCsar)
- throws IOException {
- File translatedFile = vendorSoftwareProductManager.getTranslatedFile(VSP_ID, VERSION10, USER1);
+ throws IOException {
+ File translatedFile = vendorSoftwareProductManager.getTranslatedFile(VSP_ID, VERSION10);
return getFileNamesFromFolderInCsar(translatedFile,
- pathInCsar);
+ pathInCsar);
}
private List<String> getFileNamesFromFolderInCsar(File csar, String folderName)
- throws IOException {
-
+ throws IOException {
List<String> fileNames = new ArrayList<>();
- try (FileInputStream fileInputStream = new FileInputStream(csar);
- ZipInputStream zip = new ZipInputStream(fileInputStream)) {
-
+ try (ZipInputStream zip = new ZipInputStream(new FileInputStream(csar))) {
ZipEntry ze;
while ((ze = zip.getNextEntry()) != null) {
@@ -711,28 +706,26 @@ public class VendorSoftwareProductManagerImplTest {
return fileNames;
}
-
- private void createPackageFromUpload(String vspId, String user, String filePath)
- throws IOException {
- uploadFileAndProcess(vspId, user, filePath);
- checkinSubmitCreatePackage(vspId, user);
- }
-
- private void uploadFileAndProcess(String vspId, String user, String filePath) throws IOException {
- vendorSoftwareProductManager.checkout(vspId, user);
-
- try (InputStream inputStream = this.getClass().getResourceAsStream(filePath)) {
- candidateManager.upload(vspId, VERSION01, inputStream, user, "zip", "file");
- candidateManager.process(vspId, VERSION01, user);
- }
- }
-
- private void checkinSubmitCreatePackage(String vspId, String user) throws IOException {
- vendorSoftwareProductManager.checkin(vspId, user);
- ValidationResponse submitResponse = vendorSoftwareProductManager.submit(vspId, user);
- Assert.assertTrue(submitResponse.isValid());
- vendorSoftwareProductManager.createPackage(vspId, VERSION10, user);
- }
+ /*
+ //Disabled for sonar null pointer issue for componentEntities
+ private Pair<String, String> uploadMib(String vspId, String user, String filePath,
+ String fileName) {
+ List<ComponentEntity> componentEntities = null;
+ //(List<ComponentEntity>) vendorSoftwareProductManager.listComponents(vspId, null, user);
+ monitoringUploadsManager.upload(getFileInputStream(filePath),
+ fileName, vspId,
+<<<<<<< HEAD
+ VERSION01, componentEntities.get(0).getId(), ArtifactType.SNMP_POLL);
+ //TODO: add validate of logActivity() func call
+=======
+ VERSION01, componentEntities.get(0).getId(), MonitoringUploadType.SNMP_POLL, user);
+ //TODO: add validate of addActionLog() func call
+>>>>>>> feature/Amdocs-ASDC-1710
+
+ return new ImmutablePair<>(componentEntities.get(0).getId(),
+ componentEntities.get(0).getComponentCompositionData()
+ .getDisplayName());
+ }*/
// TODO: 3/15/2017 fix and enable
/*
@@ -781,11 +774,11 @@ public class VendorSoftwareProductManagerImplTest {
*/
private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
- candidateManager.upload(vspId, VERSION01, upload, USER1, "zip", "file");
- candidateManager.process(vspId, VERSION01, user);
+ candidateManager.upload(vspId, VERSION01, upload, "zip", "file");
+ candidateManager.process(vspId, VERSION01);
- UploadDataEntity uploadData =
- orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version);
+ OrchestrationTemplateEntity uploadData =
+ orchestrationTemplateDataDaoMock.get(vspId, version);
Assert.assertNotNull(uploadData);
}
@@ -795,20 +788,40 @@ public class VendorSoftwareProductManagerImplTest {
capabilities.put(entryValueKey + "_" + key, value);
}
- private byte[] getBytes(String fileName) throws IOException {
+ public InputStream getFileInputStream(String fileName) {
URL url = this.getClass().getResource(fileName);
- try (InputStream inputStream = url.openStream()) {
- return FileUtils.toByteArray(inputStream);
+ try {
+ return url.openStream();
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ return null;
}
}
- private void assertVSPInWantedLocationInVSPList(String vspId, int location, String user) {
+/* private void assertVSPInWantedLocationInVSPList(String vspId, int location, String user) {
List<VersionedVendorSoftwareProductInfo> vspList =
- vendorSoftwareProductManager.listVsps(null, user);
+ vendorSoftwareProductManager.listVsps(null);
Assert.assertEquals(vspList.get(location).getVspDetails().getId(), vspId);
- }
-
-
+ }*/
+
+
+ // private void assertInfoArtifactIsInRightPathInCsar(String vspId, String zipFileName)
+// throws IOException {
+// ZipInputStream inputZipStream = new ZipInputStream(new FileInputStream(new File(zipFileName)));
+// boolean isInfoArtifactInZip = false;
+//
+// ZipEntry zipEntry;
+// while ((zipEntry = inputZipStream.getNextEntry()) != null) {
+// String currentEntryName = zipEntry.getName();
+// if(currentEntryName.equals("Artifacts\\Informative\\Guide\\VSP_" +
+// vspId + "_Information.txt")){
+// isInfoArtifactInZip = true;
+// break;
+// }
+// }
+//
+// Assert.assertTrue(isInfoArtifactInZip);
+// }
static VspDetails createVspDetails(String id, Version version, String name, String desc,
String vendorName, String vlm, String icon,
String category, String subCategory,
@@ -842,30 +855,68 @@ public class VendorSoftwareProductManagerImplTest {
Assert.assertEquals(actual.getFeatureGroups(), expected.getFeatureGroups());
}
- // todo ********************** move to common **************************************
+
+// @Test
+// public void testDownloadFile() throws IOException {
+// VspDetails expectedVsp = VSPCommon.createVspDetails(null, null, String.format("VSP-test-%s", vlm1Id), "Test-vsp", "vendorName", "vlm1Id", "icon", "category", "subCategory", "123", null);
+// VspDetails createdVsp = vendorSoftwareProductManager.createVsp(expectedVsp, USER1);
+//
+// id005 = createdVsp.getId();
+// Assert.assertNotNull(id005);
+// Assert.assertNotNull(createdVsp.getVersion());
+//
+// try (InputStream zipInputStream = new ZipFileUtils().getZipInputStream("/legalUploadWithWarning")) {
+//
+// UploadFileResponse uploadFileResponse = vendorSoftwareProductManager.upload(id005, zipInputStream, USER1);
+// vendorSoftwareProductManager.process(id005, USER1);
+// Optional<File> fileCandidate = vendorSoftwareProductManager.get(id005, USER1);
+//
+// File latestHeatPackage = fileCandidate.get();
+//
+// zipInputStream.reset();
+// byte[] uploaded = IOUtils.toByteArray(zipInputStream);
+//
+// Optional<FileContentHandler> zipContentMap = vendorSoftwareProductManager.getZipContentMap(uploadFileResponse, uploaded);
+// FileContentHandler fileContentHandler = new FileContentHandler();
+// if(zipContentMap.isPresent()){
+// fileContentHandler = zipContentMap.get();
+// }
+//
+// uploaded = IOUtils.toByteArray(fileContentHandler.getFiles().values());
+//
+// byte[] downloaded;
+// try (BufferedInputStream fileStream = new BufferedInputStream(new FileInputStream(latestHeatPackage))) {
+// downloaded = IOUtils.toByteArray(fileStream);
+// }
+//
+// Assert.assertTrue(Arrays.equals(uploaded, downloaded));
+// }
+// }
+
+ // todo ********************** move to common **************************************
private void mockVersioning(VersionableEntityAction action) {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
- action);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1,
+ action);
}
private void mockVersioningEntityNotExist(VersionableEntityAction action, String vspId) {
doThrow(new CoreException(new EntityNotExistErrorBuilder(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId).build()))
- .when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId, USER1,
- action);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId).build()))
+ .when(versioningManagerMock).getEntityVersionInfo(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, vspId, USER1,
+ action);
}
private void MockVersioningEntityLocked(VersionableEntityAction action) {
doThrow(new CoreException(new EditOnEntityLockedByOtherErrorBuilder(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1)
- .build()))
- .when(versioningManagerMock).getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER2,
- action);
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER1)
+ .build()))
+ .when(versioningManagerMock).getEntityVersionInfo(
+ VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, USER2,
+ action);
}
} \ No newline at end of file
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java
deleted file mode 100644
index ede8620cf9..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/mock/VendorSoftwareProductDaoFactoryMock.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct.impl.mock;
-
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
-
-public class VendorSoftwareProductDaoFactoryMock extends VendorSoftwareProductDaoFactory {
-
- @Override
- public VendorSoftwareProductDao createInterface() {
- return null;
- }
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
index 3d98ab76c6..1c9d61b51b 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/CandidateServiceImplTest.java
@@ -30,7 +30,6 @@ import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.ManifestCreator;
import org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule.CandidateServiceImpl;
@@ -57,8 +56,6 @@ import static org.testng.Assert.assertTrue;
public class CandidateServiceImplTest {
@Mock
private ManifestCreator manifestCreatorMock;
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
@InjectMocks
private CandidateServiceImpl candidateService;
@@ -95,7 +92,8 @@ public class CandidateServiceImplTest {
//vspDetails.setOnboardingMethod(VSPCommon.OnboardingMethod.HEAT.name());
vspDetails.setOnboardingMethod("HEAT");
- FilesDataStructure structure = JsonUtil.json2Object(getExpectedJson(), FilesDataStructure.class);
+ FilesDataStructure structure =
+ JsonUtil.json2Object(getExpectedJson(), FilesDataStructure.class);
Optional<ManifestContent> expectedManifest = getExpectedManifestJson();
doReturn(expectedManifest)
@@ -191,7 +189,8 @@ public class CandidateServiceImplTest {
fileData = createFileData("file1.yaml", true, FileData.Type.HEAT, null);
mockFileData.add(fileData);
fileData = createFileData("file1_vol.yaml", null, FileData.Type.HEAT_VOL, fileData);
- fileData = createFileData("file1.env", null, FileData.Type.HEAT_ENV, mockFileData.get(1).getData().get(0));
+ fileData = createFileData("file1.env", null, FileData.Type.HEAT_ENV,
+ mockFileData.get(1).getData().get(0));
mockFileData.add(createFileData("file2.sh", null, FileData.Type.OTHER, null));
mockFileData.add(createFileData("file3.yml", null, FileData.Type.OTHER, null));
mock.setData(mockFileData);
@@ -202,7 +201,7 @@ public class CandidateServiceImplTest {
FileData fileDataToAddTo) {
FileData fileData = new FileData();
fileData.setFile(fileName);
- if(isBase != null) {
+ if (isBase != null) {
fileData.setBase(isBase);
}
fileData.setType(fileType);
@@ -211,11 +210,9 @@ public class CandidateServiceImplTest {
}
private void addFileDataToList(FileData fileDataToAddTo, FileData fileData) {
- if(fileDataToAddTo != null)
- {
+ if (fileDataToAddTo != null) {
List<FileData> list = fileDataToAddTo.getData();
- if(CollectionUtils.isEmpty(list))
- {
+ if (CollectionUtils.isEmpty(list)) {
list = new ArrayList<>();
}
list.add(fileData);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
index 2f85f30dc5..9385d4a10c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionDataExtractorImplTest.java
@@ -27,8 +27,8 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate;
-import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.tosca.services.ToscaExtensionYamlUtil;
+import org.openecomp.sdc.tosca.services.ToscaUtil;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
@@ -110,11 +110,12 @@ public class CompositionDataExtractorImplTest {
try (InputStream yamlFile = new FileInputStream(file)) {
ServiceTemplate serviceTemplateFromYaml =
toscaExtensionYamlUtil.yamlToObject(yamlFile, ServiceTemplate.class);
- serviceTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplateFromYaml), serviceTemplateFromYaml);
+ serviceTemplates.put(ToscaUtil.getServiceTemplateFileName(serviceTemplateFromYaml),
+ serviceTemplateFromYaml);
try {
yamlFile.close();
} catch (IOException ignore) {
- log.debug("",ignore);
+ log.debug("", ignore);
}
} catch (FileNotFoundException exception) {
throw exception;
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java
index 1acd58d157..0d9245d779 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImplTest.java
@@ -22,12 +22,10 @@ package org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition;
import org.apache.commons.collections.CollectionUtils;
import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.sdc.common.errors.CoreException;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
@@ -43,6 +41,7 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -90,8 +89,6 @@ public class CompositionEntityDataManagerImplTest {
"}";
private Map<CompositionEntityId, Collection<String>> errorsById;
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
@InjectMocks
@Spy
private CompositionEntityDataManagerImpl compositionEntityDataManager;
@@ -248,7 +245,7 @@ public class CompositionEntityDataManagerImplTest {
Map<CompositionEntityId, Collection<String>> errorsById =
compositionEntityDataManager.validateEntitiesQuestionnaire();
- Assert.assertEquals(errorsById.size(), 0);
+ Assert.assertEquals(errorsById.size(), 1);
}
@Test(dependsOnMethods = "testNicAndComponentValidQuestionnaire")
@@ -259,9 +256,9 @@ public class CompositionEntityDataManagerImplTest {
Map<CompositionEntityId, Collection<String>> errorsById =
compositionEntityDataManager.validateEntitiesQuestionnaire();
- Assert.assertEquals(errorsById.size(), 1);
+ Assert.assertEquals(errorsById.size(), 2);
- CompositionEntityId component = errorsById.keySet().iterator().next();
+ CompositionEntityId component = new ArrayList<>(errorsById.keySet()).get(1);
List<String> errors = (List<String>) errorsById.get(component);
Assert.assertEquals(errors.size(), 1);
Assert.assertEquals(errors.get(0),
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
index acd76a151b..237e9cce8f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
@@ -20,27 +20,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator;
-import org.everit.json.schema.EmptySchema;
-import org.everit.json.schema.loader.SchemaLoader;
-import org.json.JSONObject;
-import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentCompositionSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NetworkCompositionSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.NicCompositionSchemaInput;
-import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.Map;
-
public class SchemaGeneratorTest {
/*
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
index df386b12cd..2a475fe895 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
@@ -21,9 +21,6 @@
package org.openecomp.sdc.vendorsoftwareproduct.tree;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -32,13 +29,10 @@ import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.healing.api.HealingManager;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerImpl;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
@@ -50,7 +44,11 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.zip.ZipOutputStream;
@@ -59,70 +57,69 @@ import static org.mockito.Mockito.doReturn;
import static org.testng.Assert.assertEquals;
public class UploadFileTest {
- private static final String USER1 = "vspTestUser1";
-
- public static final Version VERSION01 = new Version(0, 1);
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
- private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
- @Spy
- private CandidateServiceImpl candidateService;
- @Mock
- private HealingManager healingManagerMock;
- @Mock
- private CompositionDataExtractor compositionDataExtractorMock;
- @Mock
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
- @Mock
- private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private VendorSoftwareProductInfoDao vspInfoDaoMock;
-
- @InjectMocks
- private OrchestrationTemplateCandidateManagerImpl candidateManager;
-
- private static String vlm1Id;
- public static String id001 = null;
- public static String id002 = null;
-
- public static Version activeVersion002 = null;
-
-
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void testUploadFile() {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
- candidateManager.upload(id001, activeVersion002, getZipInputStream("/legalUpload"), USER1, OnboardingTypesEnum.ZIP.toString(), "legalUpload");
- }
-
-
- private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(vspId, activeVersion002,
- upload, user, OnboardingTypesEnum.ZIP.toString(),"file" );
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.ZIP);
- UploadDataEntity uploadData =
- orchestrationTemplateDataDaoMock.getOrchestrationTemplate(vspId, version);
-
- }
-
- public InputStream getZipInputStream(String name) {
- URL url = this.getClass().getResource(name);
- File templateDir = new File(url.getFile());
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (ZipOutputStream zos = new ZipOutputStream(baos)) {
- VSPCommon.zipDir(templateDir, "", zos, true);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return new ByteArrayInputStream(baos.toByteArray());
+ private static final String USER1 = "vspTestUser1";
+
+ public static final Version VERSION01 = new Version(0, 1);
+
+ @Mock
+ private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
+ @Spy
+ private CandidateServiceImpl candidateService;
+ @Mock
+ private HealingManager healingManagerMock;
+ @Mock
+ private CompositionDataExtractor compositionDataExtractorMock;
+ @Mock
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDaoMock;
+
+ @InjectMocks
+ private OrchestrationTemplateCandidateManagerImpl candidateManager;
+
+ private static String vlm1Id;
+ public static String id001 = null;
+ public static String id002 = null;
+
+ public static Version activeVersion002 = null;
+
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testUploadFile() {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+ candidateManager.upload(id001, activeVersion002, getZipInputStream("/legalUpload"),
+ OnboardingTypesEnum.ZIP.toString(), "legalUpload");
+ }
+
+
+ private void testLegalUpload(String vspId, Version version, InputStream upload, String user) {
+ UploadFileResponse uploadFileResponse = candidateManager.upload(vspId, activeVersion002,
+ upload, OnboardingTypesEnum.ZIP.toString(), "file");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.ZIP);
+ OrchestrationTemplateEntity uploadData = orchestrationTemplateDataDaoMock.get(vspId, version);
+
+ }
+
+ public InputStream getZipInputStream(String name) {
+ URL url = this.getClass().getResource(name);
+ File templateDir = new File(url.getFile());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (ZipOutputStream zos = new ZipOutputStream(baos)) {
+ VSPCommon.zipDir(templateDir, "", zos, true);
+ } catch (IOException e) {
+ e.printStackTrace();
}
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
index 4d925c00cd..13f3859c0c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
@@ -38,7 +38,7 @@ public class HeatCleanupOnNewUploadTest {/*
UploadDataEntity uploadDataEntity =
vendorSoftwareProductDao.getUploadData(new UploadDataEntity(vspId, vspActiveVersion));
Assert.assertTrue((uploadDataEntity.getContentData() != null) == exist);
- Assert.assertTrue((uploadDataEntity.getValidationData() != null) == exist);
+ Assert.assertTrue((uploadDataEntity.getInfo() != null) == exist);
Assert.assertTrue((uploadDataEntity.getPackageName() != null) == exist);
Assert.assertTrue((uploadDataEntity.getPackageVersion() != null) == exist);
//TODO: talio - delete enrich data on new upload
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java
index 3332e81e36..ee451e0a3c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java
@@ -7,52 +7,55 @@ import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.Onboardin
import java.io.IOException;
import java.io.InputStream;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
public class ManifestParsingTest {
- @Test
- public void testSuccessfulParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/ValidTosca.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertTrue(onboardingManifest.isValid());
- assertEquals(onboardingManifest.getMetadata().size(), 4);
- assertEquals(onboardingManifest.getSources().size(), 5);
- }
+ @Test
+ public void testSuccessfulParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/ValidTosca.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertTrue(onboardingManifest.isValid());
+ assertEquals(onboardingManifest.getMetadata().size(), 4);
+ assertEquals(onboardingManifest.getSources().size(), 5);
}
-
- @Test
- public void testNoMetadataParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca1.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertFalse(onboardingManifest.isValid());
- assertTrue(onboardingManifest.getErrors().stream().
- filter(error -> error.contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10)))
- .findAny().isPresent());
- }
+ }
+
+ @Test
+ public void testNoMetadataParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca1.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertFalse(onboardingManifest.isValid());
+ assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
+ .contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10))));
}
-
- @Test
- public void testBrokenMDParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca2.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertFalse(onboardingManifest.isValid());
- assertTrue(onboardingManifest.getErrors().stream().
- filter(error -> error.contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10)))
- .findAny().isPresent());
- }
+ }
+
+ @Test
+ public void testBrokenMDParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca2.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertFalse(onboardingManifest.isValid());
+ assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
+ .contains(Messages.MANIFEST_INVALID_LINE.getErrorMessage().substring(0, 10))));
}
-
- @Test
- public void testNoMetaParsing() throws IOException {
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca4.mf")) {
- OnboardingManifest onboardingManifest = new OnboardingManifest(is);
- assertFalse(onboardingManifest.isValid());
- assertTrue(onboardingManifest.getErrors().stream().
- filter(error -> error.contains(Messages.MANIFEST_NO_METADATA.getErrorMessage().substring(0, 10)))
- .findAny().isPresent());
- }
+ }
+
+ @Test
+ public void testNoMetaParsing() throws IOException {
+ try (InputStream is = getClass()
+ .getResourceAsStream("/vspmanager.csar/manifest/InvalidTosca4.mf")) {
+ OnboardingManifest onboardingManifest = new OnboardingManifest(is);
+ assertFalse(onboardingManifest.isValid());
+ assertTrue(onboardingManifest.getErrors().stream().anyMatch(error -> error
+ .contains(Messages.MANIFEST_NO_METADATA.getErrorMessage().substring(0, 10))));
}
+ }
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java
index a7fc0e1ba0..d574c9ee74 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java
@@ -33,7 +33,6 @@ import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.OrchestrationTemplateCandidateManagerImpl;
@@ -51,171 +50,163 @@ import java.io.InputStream;
import java.util.List;
import java.util.function.Predicate;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
public class UploadCSARFileTest {
- private static final String USER1 = "vspTestUser1";
-
- public static final Version VERSION01 = new Version(0, 1);
-
- @Mock
- private VendorSoftwareProductDao vendorSoftwareProductDaoMock;
- @Mock
- private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
-
- @Spy
- private CandidateServiceImpl candidateService;
- @Mock
- private HealingManager healingManagerMock;
- @Mock
- private CompositionDataExtractor compositionDataExtractorMock;
- @Mock
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
- @Mock
- private CompositionEntityDataManager compositionEntityDataManagerMock;
- @Mock
- private VendorSoftwareProductInfoDao vspInfoDaoMock;
- @Mock
- private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao;
- @Mock
- private ManifestCreatorNamingConventionImpl manifestCreator;
-
- private OrchestrationTemplateCandidateManagerImpl candidateManager;
-
-
- public static String id001 = null;
-
- public static Version activeVersion002 = null;
-
-
- @BeforeMethod
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- candidateService = new CandidateServiceImpl(manifestCreator,orchestrationTemplateCandidateDao);
- candidateManager = new OrchestrationTemplateCandidateManagerImpl( vendorSoftwareProductDaoMock,
- vspInfoDaoMock,
- orchestrationTemplateDataDaoMock,
- candidateService, healingManagerMock,
- compositionDataExtractorMock,
- serviceModelDaoMock,
- compositionEntityDataManagerMock,
- null,
- null,
- null,
- null,
- null);
- }
-
- @Test
- public void testSuccessfulUploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmock.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1, "csar", "SDCmock");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(0, uploadFileResponse.getErrors().size());
- assertTrue(uploadFileResponse.getErrors().isEmpty());
- }
- }
-
- @Test
- public void testFail1UploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail1.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "SDCmockFail1");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- assertTrue( uploadFileResponse.getErrors().values().stream()
- .filter(getListPredicate(Messages.CSAR_FILES_NOT_ALLOWED
- .getErrorMessage().substring(0, 7))).findAny().isPresent());
- }
- }
- private Predicate<List<ErrorMessage>> getListPredicate(String substring) {
- return error -> isEquals(substring, error);
+ public static final Version VERSION01 = new Version("0.1");
+
+ @Mock
+ private OrchestrationTemplateDao orchestrationTemplateDataDaoMock;
+ @Spy
+ private CandidateServiceImpl candidateService;
+ @Mock
+ private HealingManager healingManagerMock;
+ @Mock
+ private CompositionDataExtractor compositionDataExtractorMock;
+ @Mock
+ private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
+ @Mock
+ private CompositionEntityDataManager compositionEntityDataManagerMock;
+ @Mock
+ private VendorSoftwareProductInfoDao vspInfoDaoMock;
+ @Mock
+ private OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDao;
+ @Mock
+ private ManifestCreatorNamingConventionImpl manifestCreator;
+
+ private OrchestrationTemplateCandidateManagerImpl candidateManager;
+
+
+ public static String id001 = null;
+
+ public static Version activeVersion002 = null;
+
+
+ @BeforeMethod
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ candidateService = new CandidateServiceImpl(manifestCreator, orchestrationTemplateCandidateDao);
+ candidateManager = new OrchestrationTemplateCandidateManagerImpl(vspInfoDaoMock,
+ candidateService, healingManagerMock);
+ }
+
+ @Test
+ public void testSuccessfulUploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmock.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is, "csar", "SDCmock");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(0, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().isEmpty());
}
-
- private boolean isEquals(String substring, List<ErrorMessage> error) {
- return error.iterator().next().getMessage().contains(substring);
+ }
+
+ @Test
+ public void testFail1UploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail1.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "SDCmockFail1");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().values().stream().anyMatch(
+ getListPredicate(Messages.CSAR_FILES_NOT_ALLOWED.getErrorMessage().substring(0, 7))));
}
-
- @Test
- public void testFail2UploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail2.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "SDCmockFail2");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- assertTrue( uploadFileResponse.getErrors().values().stream()
- .filter(getListPredicate(Messages.CSAR_FILE_NOT_FOUND
- .getErrorMessage().substring(0,7))).findAny().isPresent());
- }
+ }
+
+ private Predicate<List<ErrorMessage>> getListPredicate(String substring) {
+ return error -> isEquals(substring, error);
+ }
+
+ private boolean isEquals(String substring, List<ErrorMessage> error) {
+ return error.iterator().next().getMessage().contains(substring);
+ }
+
+ @Test
+ public void testFail2UploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail2.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "SDCmockFail2");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().values().stream().anyMatch(
+ getListPredicate(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage().substring(0, 7))));
}
- @Test
- public void testFail3UploadFile() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail3.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "SDCmockFail3");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- }
+ }
+
+ @Test
+ public void testFail3UploadFile() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockFail3.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "SDCmockFail3");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
}
-
- @Test
- public void testUploadFileIsNotZip() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = new ByteArrayInputStream( "Thia is not a zip file".getBytes() );) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1,
- "csar", "file");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertFalse(uploadFileResponse.getErrors().isEmpty());
- assertTrue( uploadFileResponse.getErrors().values().stream()
- .filter(getListPredicate(Messages.CSAR_FILE_NOT_FOUND
- .getErrorMessage().substring(0,7))).findAny().isPresent());
- }
+ }
+
+ @Test
+ public void testUploadFileIsNotZip() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = new ByteArrayInputStream("Thia is not a zip file".getBytes());) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is,
+ "csar", "file");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertFalse(uploadFileResponse.getErrors().isEmpty());
+ assertTrue(uploadFileResponse.getErrors().values().stream().anyMatch(
+ getListPredicate(Messages.CSAR_FILE_NOT_FOUND.getErrorMessage().substring(0, 7))));
}
- @Test
- public void testUploadFileIsEmpty() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
-
- try (InputStream is = new ByteArrayInputStream( new byte[]{} )) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001,
- activeVersion002, is, USER1, "csar", "file");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- }
+ }
+
+ @Test
+ public void testUploadFileIsEmpty() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+
+ try (InputStream is = new ByteArrayInputStream(new byte[]{})) {
+ UploadFileResponse uploadFileResponse = candidateManager.upload(id001,
+ activeVersion002, is, "csar", "file");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
}
+ }
- @Test
- public void testMFError() throws Exception {
- VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
- doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
+ @Test
+ public void testMFError() throws Exception {
+ VspDetails vspDetails = new VspDetails("dummyId", new Version(1, 0));
+ doReturn(vspDetails).when(vspInfoDaoMock).get(any(VspDetails.class));
- try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockBrokenMF.csar")) {
- UploadFileResponse uploadFileResponse = candidateManager.upload(id001, activeVersion002, is, USER1, "csar", "SDCmockBrokenMF");
- assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
- assertEquals(1, uploadFileResponse.getErrors().size());
- assertTrue( uploadFileResponse.getErrors()
- .values().stream()
- .filter(getListPredicate(Messages.MANIFEST_NO_METADATA.getErrorMessage())).findAny().isPresent());
+ try (InputStream is = getClass().getResourceAsStream("/vspmanager.csar/SDCmockBrokenMF.csar")) {
+ UploadFileResponse uploadFileResponse =
+ candidateManager.upload(id001, activeVersion002, is, "csar", "SDCmockBrokenMF");
+ assertEquals(uploadFileResponse.getOnboardingType(), OnboardingTypesEnum.CSAR);
+ assertEquals(1, uploadFileResponse.getErrors().size());
+ assertTrue(uploadFileResponse.getErrors().values().stream()
+ .anyMatch(getListPredicate(Messages.MANIFEST_NO_METADATA.getErrorMessage())));
- }
}
+ }
}