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/impl/VendorSoftwareProductManagerImpl.java26
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java2
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java29
3 files changed, 37 insertions, 20 deletions
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 b145b38355..995044588c 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
@@ -78,6 +78,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
@@ -137,7 +138,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
private HealingManager healingManager;
private VendorLicenseArtifactsService licenseArtifactsService;
- private CompositionEntityDataManager compositionEntityDataManager;
private InformationArtifactGenerator informationArtifactGenerator;
private PackageInfoDao packageInfoDao;
private ActivityLogManager activityLogManager;
@@ -153,7 +153,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao,
HealingManager healingManager,
VendorLicenseArtifactsService licenseArtifactsService,
- CompositionEntityDataManager compositionEntityDataManager,
InformationArtifactGenerator informationArtifactGenerator,
PackageInfoDao packageInfoDao,
ActivityLogManager activityLogManager) {
@@ -166,7 +165,6 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
this.enrichedServiceModelDao = enrichedServiceModelDao;
this.healingManager = healingManager;
this.licenseArtifactsService = licenseArtifactsService;
- this.compositionEntityDataManager = compositionEntityDataManager;
this.informationArtifactGenerator = informationArtifactGenerator;
this.packageInfoDao = packageInfoDao;
this.activityLogManager = activityLogManager;
@@ -479,11 +477,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
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());
+ } catch (RuntimeException rte) {
+ logger.error(
+ "Error trying to retrieve vsp[" + entry.getKey() + "] version[" + version.toString
+ () + "] " +
+ "message:" + rte
+ .getMessage());
}
}
@@ -543,11 +542,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
return checkin(vspId, user);
case Final:
- Version checkoutFinalVersion = checkout(vspId,user);
+ Version checkoutFinalVersion = checkout(vspId, user);
autoHeal(vspId, checkoutFinalVersion, vendorSoftwareProductInfo, user);
- Version checkinFinalVersion = checkin(vspId,user);
+ Version checkinFinalVersion = checkin(vspId, user);
ValidationResponse response = submit(vspId, user);
- if(!response.isValid()) {
+ if (!response.isValid()) {
return checkout(vspId, user);
}
@@ -828,7 +827,10 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version) {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
+ // The apis of CompositionEntityDataManager used here are stateful!
+ // so, it must be re-created from scratch when it is used!
+ CompositionEntityDataManager compositionEntityDataManager =
+ CompositionEntityDataManagerFactory.getInstance().createInterface();
compositionEntityDataManager
.addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
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 16f17e6192..3751195d6c 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
@@ -32,7 +32,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFacto
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.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory;
import org.openecomp.sdc.versioning.VersioningManagerFactory;
@@ -48,7 +47,6 @@ public class VspManagerFactoryImpl extends VspManagerFactory {
EnrichedServiceModelDaoFactory.getInstance().createInterface(),
HealingManagerFactory.getInstance().createInterface(),
VendorLicenseArtifactServiceFactory.getInstance().createInterface(),
- CompositionEntityDataManagerFactory.getInstance().createInterface(),
InformationArtifactGeneratorFactory.getInstance().createInterface(),
PackageInfoDaoFactory.getInstance().createInterface(),
ActivityLogManagerFactory.getInstance().createInterface());
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 540df7d5ed..5a2f76b6fa 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
@@ -56,9 +56,11 @@ 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.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
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.VendorSoftwareProductErrorCodes;
import org.openecomp.sdc.vendorsoftwareproduct.impl.mock.EnrichmentManagerFactoryImpl;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
@@ -284,7 +286,7 @@ public class VendorSoftwareProductManagerImplTest {
assertVspsEquals(vsp, vspToCreate);
verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor()+1));
+ Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
Assert.assertTrue(activityLogEntity.isSuccess());
}
@@ -409,7 +411,7 @@ public class VendorSoftwareProductManagerImplTest {
USER1, null);
verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor()+1));
+ Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
Assert.assertTrue(activityLogEntity.isSuccess());
}
@@ -427,7 +429,7 @@ public class VendorSoftwareProductManagerImplTest {
verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
- Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor()+1));
+ Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION01.getMajor() + 1));
Assert.assertTrue(activityLogEntity.isSuccess());
}
@@ -459,6 +461,7 @@ public class VendorSoftwareProductManagerImplTest {
public void testSubmitWithMissingData() throws IOException {
VersionInfo versionInfo = new VersionInfo();
versionInfo.setActiveVersion(VERSION01);
+
doReturn(versionInfo).when(versioningManagerMock).getEntityVersionInfo(
VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
VSP_ID, USER1, VersionableEntityAction.Read);
@@ -466,6 +469,20 @@ public class VendorSoftwareProductManagerImplTest {
VspDetails vsp = new VspDetails(VSP_ID, VERSION01);
doReturn(vsp).when(vspInfoDaoMock).get(anyObject());
+ VspQuestionnaireEntity vspQuestionnaire = new VspQuestionnaireEntity(VSP_ID, VERSION01);
+ vspQuestionnaire.setQuestionnaireData("{}");
+ doReturn(vspQuestionnaire).when(vspInfoDaoMock).getQuestionnaire(VSP_ID, VERSION01);
+
+ ComponentEntity comp1 = new ComponentEntity(VSP_ID, VERSION01, "comp1");
+ comp1.setQuestionnaireData("{}");
+ doReturn(Collections.singleton(comp1)).when(vendorSoftwareProductDaoMock)
+ .listComponentsCompositionAndQuestionnaire(VSP_ID, VERSION01);
+
+ NicEntity nic1 = new NicEntity(VSP_ID, VERSION01, "comp1", "nic1");
+ nic1.setQuestionnaireData("{}");
+ doReturn(Collections.singleton(nic1))
+ .when(vendorSoftwareProductDaoMock).listNicsByVsp(VSP_ID, VERSION01);
+
ValidationResponse validationResponse = vendorSoftwareProductManager.submit(VSP_ID, USER1);
Assert.assertNotNull(validationResponse);
Assert.assertFalse(validationResponse.isValid());
@@ -477,7 +494,7 @@ public class VendorSoftwareProductManagerImplTest {
verify(versioningManagerMock, never())
.submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
USER1, null);
- verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class),eq(USER1));
+ verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1));
}
// TODO: 3/15/2017 fix and enable
@@ -549,7 +566,7 @@ public class VendorSoftwareProductManagerImplTest {
verify(versioningManagerMock)
.submit(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, VSP_ID,
USER1, null);
- verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(),eq(USER1));
+ verify(activityLogManagerMock).addActionLog(activityLogEntityArg.capture(), eq(USER1));
ActivityLogEntity activityLogEntity = activityLogEntityArg.getValue();
Assert.assertEquals(activityLogEntity.getVersionId(), String.valueOf(VERSION10.getMajor()));
Assert.assertTrue(activityLogEntity.isSuccess());
@@ -612,7 +629,7 @@ public class VendorSoftwareProductManagerImplTest {
Assert.assertEquals(ce.getMessage(), Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
}
- verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class),eq(USER1));
+ verify(activityLogManagerMock, never()).addActionLog(any(ActivityLogEntity.class), eq(USER1));
}
/*
@Test