From 9f33060362b6bf8b3a7cdcdab6ce3d1c81946300 Mon Sep 17 00:00:00 2001 From: shrikantawachar Date: Mon, 12 Feb 2018 16:57:59 +0530 Subject: Enforcing HEAT validation after HEAT upload Back end implementation , Junits for Enforcing HEAT validation after heat upload. Change-Id: I0572b1d5e455023d45dc3b50b0bae7f3b6bbcc2e Issue-ID: SDC-1027 Signed-off-by: shrikantawachar --- .../OrchestrationTemplateCandidateManager.java | 12 +- .../VendorSoftwareProductManager.java | 17 ++- .../VendorSoftwareProductInvalidErrorBuilder.java | 32 ++++- .../OrchestrationTemplateCandidateManagerImpl.java | 13 +- .../impl/VendorSoftwareProductManagerImpl.java | 131 +++++++++++++++------ .../impl/VspManagerFactoryImpl.java | 12 +- .../impl/orchestration/OrchestrationUtil.java | 3 +- .../OrchestrationTemplateProcessCsarHandler.java | 12 +- .../OrchestrationTemplateProcessZipHandler.java | 20 +++- ...hestrationTemplateCandidateManagerImplTest.java | 57 +++++++++ .../impl/VendorSoftwareProductManagerImplTest.java | 91 ++++++++++---- 11 files changed, 305 insertions(+), 95 deletions(-) (limited to 'openecomp-be/backend') 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 84318dbdd8..a28e2c8144 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 @@ -1,9 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * 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 @@ -15,7 +12,6 @@ * 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; @@ -46,4 +42,6 @@ public interface OrchestrationTemplateCandidateManager { Optional> get(String vspId, Version version) throws IOException; OrchestrationTemplateCandidateData getInfo(String vspId, Version version); + + void abort(String vspId, Version version); } 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 2e38122856..7528110d37 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 @@ -1,21 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * 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; @@ -27,6 +23,7 @@ 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.candidateheat.FilesDataStructure; import org.openecomp.sdc.versioning.dao.types.Version; import java.io.File; @@ -34,6 +31,7 @@ import java.io.IOException; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Optional; public interface VendorSoftwareProductManager { @@ -59,6 +57,7 @@ public interface VendorSoftwareProductManager { OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version); + Optional getOrchestrationTemplateStructure(String vspId, Version version); PackageInfo createPackage(String vspId, Version version) throws IOException; 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 ca20d97e4a..c3a2862e39 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 @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,13 @@ 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 " + - "minimum of one Deployment Flavor defined for being able to be instantiated.Please add a Deployment Flavor and re-submit the VSP."; + 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 static final String CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED = "Uploaded network package" + + " file %s was not processed/aborted."; + private static final String INVALID_PROCESSED_CANDIDATE = "Uploaded network package file %s" + + " is invalid and need to be aborted"; private VendorSoftwareProductInvalidErrorBuilder() { @@ -60,4 +65,25 @@ public class VendorSoftwareProductInvalidErrorBuilder { return builder.build(); } + public static ErrorCode candidateDataNotProcessedOrAbortedErrorBuilder(String fileName) { + ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes + .VSP_INVALID, ErrorCategory.APPLICATION); + builder.withMessage(String.format(CANDIDATE_DATA_NOT_PROCESSED_OR_ABORTED, fileName)); + return builder.build(); + } + + public static ErrorCode invalidProcessedCandidate(String fileName) { + ErrorCode.ErrorCodeBuilder builder = getErrorCodeBuilder(VendorSoftwareProductErrorCodes + .VSP_INVALID, ErrorCategory.APPLICATION); + builder.withMessage(String.format(INVALID_PROCESSED_CANDIDATE, fileName)); + return builder.build(); + } + + public static ErrorCode.ErrorCodeBuilder getErrorCodeBuilder(String errorCode, ErrorCategory + errorCategory) { + ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + builder.withId(errorCode); + builder.withCategory(errorCategory); + return builder; + } } 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 aa90b5dee6..97a4a213af 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 @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ public class OrchestrationTemplateCandidateManagerImpl public OrchestrationTemplateCandidateManagerImpl(VendorSoftwareProductInfoDao vspInfoDao, CandidateService candidateService - ) { + ) { this.vspInfoDao = vspInfoDao; this.candidateService = candidateService; } @@ -129,8 +129,8 @@ public class OrchestrationTemplateCandidateManagerImpl if (!candidateDataEntity.isPresent()) { ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage - (), "")); + getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), + "")); LOGGER.error(errorMessage.getMessage()); return Optional.empty(); } @@ -157,6 +157,11 @@ public class OrchestrationTemplateCandidateManagerImpl return candidateService.getOrchestrationTemplateCandidateInfo(vspId, version); } + @Override + public void abort(String vspId, Version version) { + candidateService.deleteOrchestrationTemplateCandidate(vspId, version); + } + private Optional fetchCandidateDataEntity( String vspId, Version version) { return Optional 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 78ce0787bf..cc24873e92 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 @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsSe import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager; import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager; +import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; @@ -63,6 +64,7 @@ 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.OrchestrationTemplateCandidateData; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; @@ -82,6 +84,7 @@ 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.candidateheat.FilesDataStructure; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType; @@ -114,6 +117,7 @@ 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; @@ -121,6 +125,7 @@ import java.util.zip.ZipOutputStream; public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager { private final OrchestrationTemplateDao orchestrationTemplateDao; + private final OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager; private final VendorSoftwareProductInfoDao vspInfoDao; private final VendorLicenseFacade vendorLicenseFacade; private final ServiceModelDao serviceModelDao; @@ -137,22 +142,24 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa private final ManualVspToscaManager manualVspToscaManager; public VendorSoftwareProductManagerImpl( - OrchestrationTemplateDao orchestrationTemplateDataDao, - VendorSoftwareProductInfoDao vspInfoDao, - VendorLicenseFacade vendorLicenseFacade, - ServiceModelDao serviceModelDao, - EnrichedServiceModelDao enrichedServiceModelDao, - VendorLicenseArtifactsService licenseArtifactsService, - InformationArtifactGenerator informationArtifactGenerator, - PackageInfoDao packageInfoDao, - DeploymentFlavorDao deploymentFlavorDao, - ComponentDao componentDao, - ComponentDependencyModelDao componentDependencyModelDao, - NicDao nicDao, - ComputeDao computeDao, - ImageDao imageDao, - ManualVspToscaManager manualVspToscaManager) { + OrchestrationTemplateDao orchestrationTemplateDataDao, + OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager, + VendorSoftwareProductInfoDao vspInfoDao, + VendorLicenseFacade vendorLicenseFacade, + ServiceModelDao serviceModelDao, + EnrichedServiceModelDao enrichedServiceModelDao, + VendorLicenseArtifactsService licenseArtifactsService, + InformationArtifactGenerator informationArtifactGenerator, + PackageInfoDao packageInfoDao, + DeploymentFlavorDao deploymentFlavorDao, + ComponentDao componentDao, + ComponentDependencyModelDao componentDependencyModelDao, + NicDao nicDao, + ComputeDao computeDao, + ImageDao imageDao, + ManualVspToscaManager manualVspToscaManager) { this.orchestrationTemplateDao = orchestrationTemplateDataDao; + this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager; this.vspInfoDao = vspInfoDao; this.vendorLicenseFacade = vendorLicenseFacade; this.serviceModelDao = serviceModelDao; @@ -170,6 +177,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa registerToVersioning(); } + private void registerToVersioning() { serviceModelDao.registerVersioning( VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE); @@ -177,27 +185,19 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE); } - @Override public ValidationResponse validate(String vspId, Version version) throws IOException { VspDetails vspDetails = getValidatedVsp(vspId, version); - Collection componentDependencies = - componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null)); - - ValidationResponse validationResponse = new ValidationResponse(); - validationResponse.setQuestionnaireValidationResult( - validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), - vspDetails.getOnboardingMethod())); - List vspErrors = new ArrayList<>(validateVspFields(vspDetails)); - if (validateComponentDependencies(componentDependencies)) { - vspErrors - .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder()); - } - if (Objects.nonNull(vspDetails.getOnboardingMethod()) && - OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) { + ValidationResponse validationResponse = new ValidationResponse(); + if (Objects.nonNull(vspDetails.getOnboardingMethod()) + && OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) { validateManualOnboardingMethod(vspDetails, validationResponse, vspErrors); } else { + validateOrchestrationTemplateCandidate(validationResponse, vspErrors, vspId, version); + if (!validationResponse.isValid()) { + return validationResponse; + } if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null || vspDetails.getFeatureGroups() != null) { vspErrors.addAll(validateMandatoryLicenseFields(vspDetails)); @@ -206,20 +206,59 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa orchestrationTemplateDao.get(vspId, version); ToscaServiceModel serviceModel = serviceModelDao.getServiceModel(vspId, vspDetails.getVersion()); - if (!isOrchestrationTemplateExist(orchestrationTemplate) || - !isServiceModelExist(serviceModel)) { + if (!isOrchestrationTemplateExist(orchestrationTemplate) + || !isServiceModelExist(serviceModel)) { vspErrors.add(VendorSoftwareProductInvalidErrorBuilder .vendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(), vspDetails.getVersion())); } validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate)); } + Collection componentDependencies = + componentDependencyModelDao.list(new ComponentDependencyModelEntity(vspId, version, null)); + + QuestionnaireValidationResult questionnaireValidationResult = validateQuestionnaire + (vspDetails.getId(), vspDetails.getVersion(), vspDetails.getOnboardingMethod()); + + if (Objects.nonNull(questionnaireValidationResult)) { + if (validationResponse.getQuestionnaireValidationResult() == null || validationResponse + .getQuestionnaireValidationResult().getValidationData() == null) { + validationResponse.setQuestionnaireValidationResult(questionnaireValidationResult); + } else { + validationResponse.getQuestionnaireValidationResult().getValidationData().addAll + (questionnaireValidationResult.getValidationData()); + } + } + + if (validateComponentDependencies(componentDependencies)) { + vspErrors + .add(ComponentDependencyModelErrorBuilder.getcyclicDependencyComponentErrorBuilder()); + } validationResponse .setVspErrors(vspErrors); validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails)); return validationResponse; } + private void validateOrchestrationTemplateCandidate(ValidationResponse validationResponse, + List vspErrors, String vspId, + Version version) { + OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = + orchestrationTemplateCandidateManager.getInfo(vspId, version); + String validationData = orchestrationTemplateCandidateData.getValidationData(); + String fileName = orchestrationTemplateCandidateData.getFileName(); + if (Objects.nonNull(orchestrationTemplateCandidateData.getFileSuffix())) { + if (validationData.isEmpty()) { + vspErrors.add(VendorSoftwareProductInvalidErrorBuilder + .candidateDataNotProcessedOrAbortedErrorBuilder(fileName)); + validationResponse.setVspErrors(vspErrors); + } else { + vspErrors.add(VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate(fileName)); + validationResponse.setVspErrors(vspErrors); + } + } + } + private void validateManualOnboardingMethod(VspDetails vspDetails, ValidationResponse validationResponse, List vspErrors) { @@ -236,8 +275,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa Set componentValidationResult = componentValidation(vspDetails.getId(), vspDetails.getVersion()); if (!CollectionUtils.isEmpty(componentValidationResult)) { - if (validationResponse.getQuestionnaireValidationResult() == null || - validationResponse.getQuestionnaireValidationResult().getValidationData() == null) { + if (validationResponse.getQuestionnaireValidationResult() == null + || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) { validationResponse.setQuestionnaireValidationResult( new QuestionnaireValidationResult(componentValidationResult)); } else { @@ -587,6 +626,20 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa return orchestrationTemplateDao.getInfo(vspId, version); } + @Override + public Optional getOrchestrationTemplateStructure(String vspId, + Version version) { + Optional jsonFileDataStructure = + orchestrationTemplateDao.getOrchestrationTemplateStructure(vspId, version); + + if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) { + return Optional + .of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class)); + } else { + return Optional.empty(); + } + } + @Override public PackageInfo createPackage(String vspId, Version version) { ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version); @@ -770,10 +823,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa } private boolean isOrchestrationTemplateExist(OrchestrationTemplateEntity orchestrationTemplate) { - return orchestrationTemplate != null && - orchestrationTemplate.getContentData() != null && - orchestrationTemplate.getFileSuffix() != null && - orchestrationTemplate.getFileName() != null; + return orchestrationTemplate != null + && orchestrationTemplate.getContentData() != null + && orchestrationTemplate.getFileSuffix() != null + && orchestrationTemplate.getFileName() != null; } private boolean isServiceModelExist(ToscaServiceModel serviceModel) { 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 a2c0aea423..4749e7f2dd 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 @@ -1,9 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * 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 @@ -15,7 +12,6 @@ * 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.impl; @@ -24,6 +20,7 @@ import org.openecomp.core.model.dao.EnrichedServiceModelDaoFactory; import org.openecomp.core.model.dao.ServiceModelDaoFactory; import org.openecomp.sdc.vendorlicense.VendorLicenseArtifactServiceFactory; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory; +import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory; @@ -41,6 +38,7 @@ public class VspManagerFactoryImpl extends VspManagerFactory { private static final VendorSoftwareProductManager INSTANCE = new VendorSoftwareProductManagerImpl( OrchestrationTemplateDaoFactory.getInstance().createInterface(), + OrchestrationTemplateCandidateManagerFactory.getInstance().createInterface(), VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(), VendorLicenseFacadeFactory.getInstance().createInterface(), ServiceModelDaoFactory.getInstance().createInterface(), 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 9031e926a4..fae8f8b697 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,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -317,6 +317,7 @@ public class OrchestrationUtil { (String) manifestAsMap.get("name")); uploadData.setPackageVersion(Objects.isNull(manifestAsMap.get("version")) ? null : (String) manifestAsMap.get("version")); + uploadData.setFilesDataStructure(candidateData.getFilesDataStructure()); orchestrationTemplateDataDao.update(vspDetails.getId(), vspDetails.getVersion(), uploadData); VspMergeDaoFactory.getInstance().createInterface() 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 1db8875a05..6365b9ef74 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,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import org.openecomp.sdc.common.errors.GeneralErrorBuilder; import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree; +import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.heat.services.tree.ToscaTreeManager; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; @@ -97,7 +98,13 @@ public class OrchestrationTemplateProcessCsarHandler OrchestrationTemplateActionResponse response) throws IOException { response.setFileNames(new ArrayList<>(fileContentHandler.getFileList())); Map> errors = validateCsar(fileContentHandler); + toscaTreeManager.createTree(); + if (!isValid(errors)) { + response.addStructureErrors(errors); + toscaTreeManager.addErrors(errors); + candidateService.updateValidationData(vspDetails.getId(), vspDetails.getVersion(), + new ValidationStructureList(toscaTreeManager.getTree())); return; } @@ -126,7 +133,8 @@ public class OrchestrationTemplateProcessCsarHandler orchestrationUtil.saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel, toscaServiceModel); - + candidateService + .deleteOrchestrationTemplateCandidate(vspDetails.getId(), vspDetails.getVersion()); } private void addFiles(FileContentHandler fileContentHandler) { 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 9f29d9316b..f155e45c06 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,5 +1,5 @@ /* - * Copyright © 2016-2017 European Support Limited + * Copyright © 2016-2018 European Support Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ 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.heat.datatypes.structure.HeatStructureTree; +import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.logging.messages.AuditMessages; @@ -61,7 +62,6 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp private static final Logger LOGGER = LoggerFactory.getLogger(OrchestrationTemplateProcessZipHandler.class); private final CandidateService candidateService = CandidateServiceFactory.getInstance().createInterface(); - private static final String VSP_ID = "VSP id"; @Override public OrchestrationTemplateActionResponse process(VspDetails vspDetails, @@ -108,7 +108,12 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp } HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap); - + Map> errors = getErrors(response); + if (MapUtils.isNotEmpty(errors)) { + response.addStructureErrors(errors); + candidateService.updateValidationData(vspId, version, new ValidationStructureList(tree)); + return response; + } Map componentsQuestionnaire = new HashMap<>(); Map> componentNicsQuestionnaire = new HashMap<>(); Map> componentMibList = new HashMap<>(); @@ -152,9 +157,18 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp LOGGER.audit(AuditMessages.AUDIT_MSG + AuditMessages.HEAT_TRANSLATION_COMPLETED + vspId); uploadFileResponse.addStructureErrors(uploadErrors); + candidateService.deleteOrchestrationTemplateCandidate(vspId, version); return response; } + private Map> getErrors(OrchestrationTemplateActionResponse + orchestrationTemplateActionResponse) { + Map> errors = + MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, + orchestrationTemplateActionResponse.getErrors()); + return MapUtils.isEmpty(errors) ? null : orchestrationTemplateActionResponse.getErrors(); + } + private HeatStructureTree createAndValidateHeatTree(OrchestrationTemplateActionResponse response, FileContentHandler fileContentMap) { VendorSoftwareProductUtils.addFileNamesToUploadFileResponse(fileContentMap, response); 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 5af39551b4..e1d58c6a18 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,3 +1,19 @@ +/* + * Copyright © 2016-2018 European Support Limited + * + * 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. + */ + package org.openecomp.sdc.vendorsoftwareproduct.impl; import static org.mockito.Matchers.any; @@ -11,6 +27,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; @@ -23,6 +40,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil; import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse; +import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData; import org.openecomp.sdc.vendorsoftwareproduct.utils.ZipFileUtils; import org.openecomp.sdc.versioning.dao.types.Version; @@ -59,6 +77,8 @@ public class OrchestrationTemplateCandidateManagerImplTest { private static final String COMPONENT_NAME_3 = "oam_server"; private static final String COMPONENT_NAME_4 = "ps_server"; + private static final String USER1 = "vspTestUser1"; + @Mock private VendorSoftwareProductInfoDao vspInfoDaoMock; @Mock @@ -240,6 +260,43 @@ public class OrchestrationTemplateCandidateManagerImplTest { Assert.assertEquals(componentDependenciesBeforeDelete.size(), 2); } + @Test + public void testGetFileDataStructure() { + Optional jsonFileDataStructure = Optional.of(new String("{\n" + + " \"modules\": [\n" + + " {\n" + + " \"yaml\": \"hot-mog-0108-bs1271.yml\",\n" + + " \"env\": \"hot-mog-0108-bs1271.env\"\n" + + " }\n" + + " ],\n" + + " \"unassigned\": [],\n" + + " \"artifacts\": [],\n" + + " \"nested\": []\n" + + "}")); + Optional filesDataStructureOptional = Optional.of(JsonUtil.json2Object + (jsonFileDataStructure.get(), FilesDataStructure.class)); + doReturn(filesDataStructureOptional).when(candidateServiceMock) + .getOrchestrationTemplateCandidateFileDataStructure(VSP_ID, VERSION01); + Optional filesDataStructure = candidateManager.getFilesDataStructure(VSP_ID, + VERSION01); + assertNotNull(filesDataStructure); + assertEquals(filesDataStructureOptional.get().getModules().size(), filesDataStructure.get() + .getModules().size()); + assertEquals(filesDataStructureOptional.get().getModules().get(0).getName(), + filesDataStructure.get().getModules().get(0).getName()); + } + + @Test + public void testAbort() { + + Mockito.doNothing().when(candidateServiceMock).deleteOrchestrationTemplateCandidate(VSP_ID, + VERSION01); + candidateManager.abort(VSP_ID, VERSION01); + + Mockito.verify(candidateServiceMock, Mockito.times(1)).deleteOrchestrationTemplateCandidate + (VSP_ID, VERSION01); + } + private Map getVspInitComponentIdNameInfo() { Map componentIdNameInfoBeforeProcess = new HashMap<>(); componentIdNameInfoBeforeProcess.put(COMPONENT_ORIG_ID_1, COMPONENT_NAME_1); 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 fd274d0898..2e10f1351e 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 @@ -1,9 +1,6 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ +/* + * Copyright © 2016-2018 European Support Limited + * * 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 @@ -15,11 +12,18 @@ * 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.impl; +import static org.mockito.Matchers.any; +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; + import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.InjectMocks; @@ -40,32 +44,31 @@ 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.tosca.datatypes.ToscaServiceModel; -import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade; import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService; +import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager; import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager; import org.openecomp.sdc.vendorsoftwareproduct.MonitoringUploadsManager; import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager; import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants; +import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao; 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.VendorSoftwareProductInfoDao; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; 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.impl.mock.EnrichmentManagerFactoryImpl; import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; -import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager; import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor; import org.openecomp.sdc.versioning.VersioningManager; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdc.versioning.dao.types.VersionStatus; -import org.openecomp.sdc.versioning.errors.EditOnEntityLockedByOtherErrorBuilder; -import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder; import org.openecomp.sdc.versioning.types.VersionInfo; import org.openecomp.sdc.versioning.types.VersionableEntityAction; import org.testng.Assert; @@ -84,18 +87,9 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import static org.mockito.Matchers.any; -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; - public class VendorSoftwareProductManagerImplTest { private static final String INVALID_VERSION_MSG = "Invalid requested version."; @@ -142,6 +136,10 @@ public class VendorSoftwareProductManagerImplTest { @InjectMocks private VendorSoftwareProductManagerImpl vendorSoftwareProductManager; + @Mock + private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManagerMock; + @Mock + private ComponentDependencyModelDao componentDependencyModelDao; private OrchestrationTemplateCandidateManager candidateManager; private MonitoringUploadsManager monitoringUploadsManager; @@ -587,6 +585,59 @@ public class VendorSoftwareProductManagerImplTest { assertVSPInWantedLocationInVSPList(id007, 0, USER3); } */ + @Test + public void testSubmitWithCandidateDataNotProcessed() throws IOException { + VspDetails vsp = + createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-vsp", "vendorName", "vlm1Id", "icon", + "category", "subCategory", "licenseAgreementId", + Collections.singletonList("featureGroupId")); + vsp.setOnboardingMethod("NetworkPackage"); + doReturn(vsp).when(vspInfoDaoMock).get(anyObject()); + + OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = new + OrchestrationTemplateCandidateData(); + orchestrationTemplateCandidateData.setFileSuffix("zip"); + orchestrationTemplateCandidateData.setFilesDataStructure("testdata"); + orchestrationTemplateCandidateData.setValidationData(""); + doReturn(orchestrationTemplateCandidateData).when(orchestrationTemplateCandidateManagerMock) + .getInfo(VSP_ID, VERSION01); + ValidationResponse validationResponse = + vendorSoftwareProductManager.validate(VSP_ID, VERSION01); + Assert.assertNotNull(validationResponse); + Assert.assertFalse(validationResponse.isValid()); + Assert.assertNotNull(validationResponse.getVspErrors()); + Assert.assertEquals(validationResponse.getVspErrors().size(), 1); + + verify(versioningManagerMock, never()) + .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1, null); + } + + @Test + public void testSubmitWithCandidateProcessedIsInvalid() throws IOException { + VspDetails vsp = createVspDetails(VSP_ID, VERSION01, "Vsp1", "Test-VSP", "vendorName", + "vl1Id", "icond", "category", "subcategory", "licenseAgreementId", Collections + .singletonList("featureGroupId")); + vsp.setOnboardingMethod("NetworkPackage"); + doReturn(vsp).when(vspInfoDaoMock).get(anyObject()); + + OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = new + OrchestrationTemplateCandidateData(); + orchestrationTemplateCandidateData.setFileSuffix("zip"); + orchestrationTemplateCandidateData.setValidationData("Invalid processed data"); + doReturn(orchestrationTemplateCandidateData).when(orchestrationTemplateCandidateManagerMock) + .getInfo(VSP_ID, VERSION01); + ValidationResponse validationResponse = + vendorSoftwareProductManager.validate(VSP_ID, VERSION01); + Assert.assertNotNull(validationResponse); + Assert.assertFalse(validationResponse.isValid()); + Assert.assertNotNull(validationResponse.getVspErrors()); + Assert.assertEquals(validationResponse.getVspErrors().size(), 1); + + verify(versioningManagerMock, never()) + .submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID, + USER1, null); + } private void testLegalUpload(String vspId, Version version, InputStream upload, String user) { candidateManager.upload(vspId, VERSION01, upload, "zip", "file"); -- cgit 1.2.3-korg