summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java265
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java404
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VspHealTest.java217
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/QuestionnaireValidatorTest.java94
-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.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java250
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/HeatTreeManagerTest.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java19
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java154
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/ManifestParsingTest.java23
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/csar/UploadCSARFileTest.java23
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/validation/UploadFileValidationTest.java201
13 files changed, 62 insertions, 1628 deletions
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
deleted file mode 100644
index 3df06ba8eb..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/ComputeTest.java
+++ /dev/null
@@ -1,265 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct;
-
-public class ComputeTest {
-
- /*private static final String USER1 = "componentsTestUser1";
- private static final String USER2 = "componentsTestUser2";
- private static final Version VERSION01 = new Version(0, 1);
- private static final VendorSoftwareProductManager vendorSoftwareProductManager =
- new VendorSoftwareProductManagerImpl();
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory
- .getInstance().createInterface();
-
- private static String vsp1Id;
- private static String vsp2Id;
- private static String comp1 = "{\"displayName\": \"VFC_Manual\", " +
- "\"description\": \"desc manual\"}";
- private static String compute1 = "{\"name\": \"Compute_A\", " +
- "\"description\": \"desc manual compute\"}";
- private static String computeDelete = "{\"name\": \"Compute_Delete\", " +
- "\"description\": \"desc manual compute delete\"}";
-
- private static String comp1Id;
- private static String compute1Id;
- private ComputeEntity createdCompute;
-
- static ComponentEntity createComponent(String vspId, Version version, String compId) {
- ComponentEntity componentEntity = new ComponentEntity(vspId, version, compId);
- ComponentData compData = new ComponentData();
- compData.setName(compId + " name");
- compData.setDisplayName(compId + " display name");
- compData.setDescription(compId + " desc");
- componentEntity.setComponentCompositionData(compData);
- vendorSoftwareProductDao.createComponent(componentEntity);
- return componentEntity;
- }
-
- static ComputeEntity createComputeEntity(String vspId, String componentId, String data ){
- ComputeEntity comp = new ComputeEntity();
- comp.setVspId(vspId);
- comp.setComponentId(componentId);
- comp.setCompositionData(data);
- return comp;
- }
-
- @BeforeClass
- private void init() {
- VspDetails
- vsp1 = vendorSoftwareProductManager.createNewVsp(VSPCommon
- .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp1", "vendorName",
- "vlm1Id", "icon", "category", "subCategory", "123", null,
- VSPCommon.OnboardingMethod.HEAT.name()), USER1
- );
- vsp1Id = vsp1.getId(); //HEAT onboarded
-
- VspDetails vsp2 = vendorSoftwareProductManager.createNewVsp(VSPCommon
- .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp3",
- "vendorName",
- "vlm1Id", "icon", "category", "subCategory", "123", null, VSPCommon
- .OnboardingMethod.Manual.name()), USER1);
- vsp2Id = vsp2.getId(); //MANUAL onboarded
-
- ComponentEntity component = new ComponentEntity();
- component.setVspId(vsp2Id);
- component.setCompositionData(comp1);
- ComponentEntity createdComp = vendorSoftwareProductManager.createComponent(component, USER1);
- comp1Id = createdComp.getId();
- }
-
- @Test
- public void testListWhenNone() {
-
- final Collection<ListComputeResponse> listComputeResponses =
- vendorSoftwareProductManager.listCompute(vsp2Id, null, comp1Id, USER1);
- Assert.assertEquals(listComputeResponses.size(), 0);
- }
-
- @Test
- public void testCreateComputeInHeatOnboardedVsp_negative() {
- ComputeEntity comp = createComputeEntity(vsp1Id,comp1Id,compute1);
- try {
- createdCompute = vendorSoftwareProductManager.createCompute(comp, USER1);
- Assert.fail();
- }
- catch(CoreException exception){
- Assert.assertEquals(exception.code().id(),ADD_COMPUTE_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
- }
-
- @Test(dependsOnMethods = "testListWhenNone")
- public void testCreateCompute() {
- ComputeEntity comp = createComputeEntity(vsp2Id,comp1Id,compute1);
-
- createdCompute = vendorSoftwareProductManager.createCompute(comp, USER1);
- compute1Id = createdCompute.getId();
- Assert.assertNotNull(compute1Id);
- Assert.assertNotNull(createdCompute.getCompositionData());
- Assert.assertNotNull(
- vendorSoftwareProductManager.getCompute(vsp2Id, VERSION01, comp1Id,compute1Id,
- USER1).getData());
- }
-
- @Test(dependsOnMethods = "testCreateCompute")
- public void testCreateComputeNegative() {
- ComputeEntity comp = createComputeEntity(vsp2Id,comp1Id,compute1);
-
- try {
- ComputeEntity createdCompute = vendorSoftwareProductManager.createCompute(comp, USER1);
- Assert.fail();
- }
- catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(),DUPLICATE_COMPUTE_NAME_NOT_ALLOWED);
- }
- }
-
- @Test
- public void testGetNonExistingComponentId_negative() {
- testGet_negative(vsp1Id, null, "non existing component id", compute1Id, USER1,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testGetNonExistingVspId_negative() {
- testGet_negative("non existing vsp id", null, comp1Id, compute1Id, USER1,
- VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST);
- }
-
- @Test
- public void testGetNonExistingComputeId_negative() {
- testGet_negative(vsp1Id, null, comp1Id, "non existing compute id", USER1,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test(dependsOnMethods = "testCreateCompute")
- public void testGetCompute() {
- testGet(vsp2Id, VERSION01, comp1Id, compute1Id, USER1, createdCompute);
- }
-
-
- @Test(dependsOnMethods = "testCreateCompute")
- public void testListCompute() {
-
- final Collection<ListComputeResponse> actual =
- vendorSoftwareProductManager.listCompute(vsp2Id, null, comp1Id, USER1);
- Assert.assertEquals(actual.size(), 1);
- actual.forEach(listComputeResponse -> {
- Assert.assertEquals(listComputeResponse.isAssociatedWithDeploymentFlavor(), false);
- } );
- }
-
-
- @Test(dependsOnMethods = "testListCompute")
- public void testListComputeAssociatedWithDeployment() {
-
- //Create DF and associate compute1Id CF to it
- String deployment1Id = null;
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id,
- VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("DF_testListComputeAssociatedWithDeployment");
- deploymentFlavor.setDescription("creating a deployment flavor with compute flavor association");
- ComponentComputeAssociation association = new ComponentComputeAssociation();
- association.setComponentId(comp1Id);
- association.setComputeFlavorId(compute1Id);
- List<ComponentComputeAssociation> associations = new ArrayList<ComponentComputeAssociation>();
- associations.add(association);
- deploymentFlavor.setComponentComputeAssociations(associations);
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
-
- DeploymentFlavorEntity createddeployment = vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- Assert.assertEquals((createddeployment.getId() != null), true);
- deployment1Id = createddeployment.getId();
-
- final Collection<ListComputeResponse> actual =
- vendorSoftwareProductManager.listCompute(vsp2Id, null, comp1Id, USER1);
- Assert.assertEquals(actual.size(), 1);
- actual.forEach(listComputeResponse -> {
- Assert.assertEquals(listComputeResponse.isAssociatedWithDeploymentFlavor(), true);
- } );
- }
-
- @Test
- public void testUpdateNonExistingComponentId_negative() {
- testUpdate_negative(vsp1Id, "non existing component id", USER1,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testUpdateNonExistingVspId_negative() {
- testUpdate_negative("non existing vsp id", comp1Id, USER1,
- VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST);
- }
-
- @Test
- public void testDelete() {
- ComputeEntity comp = createComputeEntity(vsp2Id,comp1Id,computeDelete);
-
- ComputeEntity created = vendorSoftwareProductManager.createCompute(comp, USER1);
-
- vendorSoftwareProductManager.deleteCompute(vsp2Id,comp1Id,created.getId(),USER1);
- testGet_negative(vsp2Id,null, comp1Id, created.getId(),USER1,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testDeleteNonExistingComputeId_negative() {
- testDelete_negative(vsp2Id,comp1Id,"InvalidComputeId",USER1,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testDeleteNonExistingComponentId_negative() {
- testDelete_negative(vsp2Id,"InvalidComponentId",compute1Id,USER1,
- VersioningErrorCodes.VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testDeleteNonExistingVspId_negative() {
- testDelete_negative("InvalidVspId",comp1Id,compute1Id,USER1,
- VersioningErrorCodes.VERSIONABLE_ENTITY_NOT_EXIST);
- }
-
- private void testGet(String vspId, Version version, String componentId, String computeId, String
- user, ComputeEntity expected) {
- CompositionEntityResponse<ComputeData>
- response = vendorSoftwareProductManager.getCompute(vspId, null, componentId, computeId,
- user);
- Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData(), expected.getComputeCompositionData());
- Assert.assertNotNull(response.getSchema());
- }
-
- private void testGet_negative(String vspId, Version version, String componentId, String computeId,
- String user, String expectedErrorCode) {
- try {
- vendorSoftwareProductManager.getCompute(vspId, version, componentId, computeId, user);
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- private void testDelete_negative(String vspId, String componentId, String computeId, String user,
- String expectedErrorCode){
- try {
- vendorSoftwareProductManager.deleteCompute(vspId, componentId, computeId, user);
- Assert.fail();
- }
- catch(CoreException exception){
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- private void testUpdate_negative(String vspId, String componentId, String user,
- String expectedErrorCode) {
- try {
- vendorSoftwareProductManager
- .updateComponent(new ComponentEntity(vspId, null, componentId), 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/DeploymentFlavorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
deleted file mode 100644
index 77c81111a5..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/DeploymentFlavorTest.java
+++ /dev/null
@@ -1,404 +0,0 @@
-package org.openecomp.sdc.vendorsoftwareproduct;
-
-public class DeploymentFlavorTest {
- /*private static final String USER1 = "deploymentTestUser1";
- private static final String USER2 = "deploymentTestUser2";
- private static final Version VERSION01 = new Version(0, 1);
- private static final VendorSoftwareProductManager vendorSoftwareProductManager =
- new VendorSoftwareProductManagerImpl();
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
-
- private static String vsp1Id;
- private static String vsp2Id;
- private static String vsp3Id;
- private static String component11Id;
- private static String component21Id;
- private static String deployment1Id = "deployment1";
- private static String deployment2Id = "deployment2";
-
- @BeforeClass
- private void init() {
- List<String> featureGroups = new ArrayList<>();
- featureGroups.add("fg01");
- featureGroups.add("fg02");
- vsp1Id = vendorSoftwareProductManager.createNewVsp(VSPCommon
- .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp1", "vendorName1",
- "vlm1Id", "icon", "category", "subCategory", "123", featureGroups,
- VSPCommon.OnboardingMethod.
- Manual.name()), USER1).getId();
- component11Id = ComponentsTest.createComponent(vsp1Id, VERSION01, "component11").getId();
-
- vsp2Id = vendorSoftwareProductManager.createNewVsp(VSPCommon
- .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp2", "vendorName1",
- "vlm1Id", "icon", "category", "subCategory", "123", null,
- VSPCommon.OnboardingMethod.Manual.name()), USER1).getId();
- component21Id = ComponentsTest.createComponent(vsp2Id, VERSION01, "component21").getId();
-
- vsp3Id = vendorSoftwareProductManager.createNewVsp(VSPCommon
- .createVspDetails(null, null, "VSP_" + CommonMethods.nextUuId(), "Test-vsp3forDeployment",
- "vendorName1",
- "vlm1Id", "icon", "category", "subCategory", "123", null,
- VSPCommon.OnboardingMethod.HEAT.name()), USER1).getId();
- }
-
- 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);
- DeploymentFlavorEntity createdDeployment = vendorSoftwareProductManager
- .createDeploymentFlavor(deploymentFlavorEntity, USER1);
- deployment2Id = createdDeployment.getId();
- return deploymentFlavorEntity;
- }
-
- @Test
- public void testCreate() {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("TestDeploymentcreatewithoutFG");
- deploymentFlavor.setDescription("creating a deployment flavor without any FG and any " +
- "association");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- DeploymentFlavorEntity createddeployment = vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- Assert.assertEquals((createddeployment.getId() != null), true);
- deployment1Id = createddeployment.getId();
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testUniqueModelCreate() {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("TestDeploymentcreatewithoutFG");
- deploymentFlavor.setDescription("creating a deployment flavor without any FG and any " +
- "association");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- try {
- vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), DUPLICATE_DEPLOYMENT_FLAVOR_MODEL_NOT_ALLOWED);
- }
- }
-
- @Test
- public void testInvalidFeatureGroup() {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("TestInvalidFeatureGroup");
- deploymentFlavor.setDescription("creating a deployment flavor with invalid FG and without any" +
- " " +
- "association");
- deploymentFlavor.setFeatureGroupId("fg01");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- try {
- vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), FEATURE_GROUP_NOT_EXIST_FOR_VSP);
- }
- }
-
- @Test
- public void testInvalidAssociation() {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("testInvalidAssociation");
- deploymentFlavor.setDescription("creating a deployment flavor with wrong association with " +
- "null compute flavor id");
- List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
- ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
- componentComputeAssociation.setComputeFlavorId("72138712");
- componentComputeAssociationList.add(componentComputeAssociation);
- deploymentFlavor.setComponentComputeAssociations(componentComputeAssociationList);
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- try {
- vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), INVALID_COMPONENT_COMPUTE_ASSOCIATION);
- }
-
- }
-
- @Test
- public void testInvalidComputeFlavorIdAssociation() {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("testInvalidComputeFlavorIdAssociation");
- deploymentFlavor.setDescription("creating a deployment flavor with wrong compute flavor id in" +
- " assocation");
- List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
- ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
- componentComputeAssociation.setComponentId(component21Id);
- componentComputeAssociation.setComputeFlavorId("123123");
- componentComputeAssociationList.add(componentComputeAssociation);
- deploymentFlavor.setComponentComputeAssociations(componentComputeAssociationList);
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- try {
- vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), INVALID_COMPUTE_FLAVOR_ID);
- }
-
- }
-
- @Test
- public void testInvalidVfcIdAssociation() {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("testInvalidVfcIdAssociation");
- deploymentFlavor.setDescription("creating a deployment flavor with invalid vfcid association");
- List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
- ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
- componentComputeAssociation.setComponentId("WRONGVFCID");
- componentComputeAssociation.setComputeFlavorId("123123");
- componentComputeAssociationList.add(componentComputeAssociation);
- deploymentFlavor.setComponentComputeAssociations(componentComputeAssociationList);
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- try {
- vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
- }
-
- @Test
- public void testNegativeforVspHeatOnboarded() {
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp3Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("TestDeploymentcreatewithoutFG");
- deploymentFlavor.setDescription("creating a deployment flavor for VSP onboarded with HEAT");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- try {
- vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(),
- CREATE_DEPLOYMENT_FLAVOR_NOT_ALLOWED_IN_HEAT_ONBOARDING);
- }
- }
-
- @Test
- public void testGetNegative_InvalidVspId(){
- testGetNegative("InvalidVspId", VERSION01, deployment1Id, USER1, VERSIONABLE_ENTITY_NOT_EXIST);
- }
-
- @Test
- public void testGetNegative_InvalidDeploymentFlavorId(){
- testGetNegative(vsp1Id, VERSION01, deployment1Id, USER1, VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testGet(){
- DeploymentFlavorEntity expected = createDeploymentFlavor(vsp1Id, VERSION01,deployment2Id);
- testGet(vsp1Id, VERSION01, deployment2Id, USER1, expected);
- }
-
- private void testGet(String vspId, Version version, String componentId, String user,
- DeploymentFlavorEntity expected) {
- CompositionEntityResponse<DeploymentFlavor> response = vendorSoftwareProductManager
- .getDeploymentFlavor(vspId, null, componentId, user);
- Assert.assertEquals(response.getId(), expected.getId());
- Assert.assertEquals(response.getData().getDescription(),
- expected.getDeploymentFlavorCompositionData().getDescription());
- Assert.assertEquals(response.getData().getModel(),
- expected.getDeploymentFlavorCompositionData().getModel());
- Assert.assertEquals(response.getData().getFeatureGroupId(),
- expected.getDeploymentFlavorCompositionData().getFeatureGroupId());
- Assert.assertEquals(response.getData().getComponentComputeAssociations(),
- expected.getDeploymentFlavorCompositionData().getComponentComputeAssociations());
- Assert.assertNotNull(response.getSchema());
- }
-
- private void testGetNegative(String vspId, Version version, String deploymentFlavorId, String User,
- String expectedErrorCode){
- try{
- vendorSoftwareProductManager.getDeploymentFlavor(vspId, version, deploymentFlavorId, User);
- Assert.fail();
- } catch (CoreException exception){
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- @Test
- public void testUpdateNegative_InvalidVspId(){
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity("InvalidVspId",
- VERSION01,deployment2Id);
- DeploymentFlavor deploymentFlavorData = new DeploymentFlavor();
- deploymentFlavorData.setModel(deployment2Id);
- deploymentFlavorData.setDescription("updating a deployment flavor with invalid VspId and without any" +
- "association");
- deploymentFlavorData.setFeatureGroupId("fg01");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorData);
-
- testUpdateNegative(deploymentFlavorEntity, USER1, VERSIONABLE_ENTITY_NOT_EXIST);
- }
-
- @Test
- public void testUpdateNegative_InvalidDeploymentFlavorId(){
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp1Id,
- VERSION01,"InvalidDeploymentFlavorId");
- testUpdateNegative(deploymentFlavorEntity, USER1, VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testUpdateNegative_InvalidFeatureGroup(){
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id,
- VERSION01,deployment1Id);
- DeploymentFlavor deploymentFlavorData = new DeploymentFlavor();
- deploymentFlavorData.setModel("TestDeploymentCreateWithoutFG");
- deploymentFlavorData.setDescription("updating a deployment flavor with invalid FeatureGroupId and without any" +
- "association");
- deploymentFlavorData.setFeatureGroupId("fg01");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorData);
- String expectedError = "#/featureGroupId: "
- +deploymentFlavorData.getFeatureGroupId()+" is not a valid value. Possible values: ";
-
- final CompositionEntityValidationData validationData = vendorSoftwareProductManager
- .updateDeploymentFlavor(deploymentFlavorEntity, USER1);
- final Collection<String> errors = validationData.getErrors();
- final Object[] objects = errors.toArray();
- Assert.assertEquals(errors.size(), 1);
- Assert.assertEquals(objects[0], expectedError);
- }
-
- @Test(dependsOnMethods = "testCreate")
- public void testUpdateNegative_InvalidComputeFlavorIdAssociation(){
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id,
- VERSION01,deployment1Id);
- DeploymentFlavor deploymentFlavorData = new DeploymentFlavor();
- deploymentFlavorData.setModel("TestDeploymentcreatewithInvalidComputFlavorId");
- deploymentFlavorData.setDescription("updating a deployment flavor with wrong compute flavor id in" +
- " assocation");
- List<ComponentComputeAssociation> componentComputeAssociationList = new ArrayList<>();
- ComponentComputeAssociation componentComputeAssociation = new ComponentComputeAssociation();
- componentComputeAssociation.setComponentId(component21Id);
- componentComputeAssociation.setComputeFlavorId("123123");
- componentComputeAssociationList.add(componentComputeAssociation);
- deploymentFlavorData.setComponentComputeAssociations(componentComputeAssociationList);
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorData);
-
- testUpdateNegative(deploymentFlavorEntity, USER1, INVALID_COMPUTE_FLAVOR_ID);
- }
-
- @Test
- public void testUpdate(){
- //Creating a separate deployment flavor for testing deletion
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp1Id, VERSION01, deployment2Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("TestDeploymentCreateforUpdate");
- deploymentFlavor.setDescription("creating a deployment flavor for updation");
- deploymentFlavor.setFeatureGroupId("fg01");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- DeploymentFlavorEntity createdDeployment = vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- deployment2Id = createdDeployment.getId();
-
- final DeploymentFlavor deploymentFlavorCompositionData = createdDeployment.getDeploymentFlavorCompositionData();
- deploymentFlavorCompositionData.setModel("TestDeploymentCreateforUpdate"); //no change
- deploymentFlavorCompositionData.setDescription("updating deployment flavor"); //allow change
- deploymentFlavorCompositionData.setFeatureGroupId("fg01"); //no change
- createdDeployment.setDeploymentFlavorCompositionData(deploymentFlavorCompositionData);
-
- vendorSoftwareProductManager.updateDeploymentFlavor(createdDeployment, USER1);
- CompositionEntityResponse<DeploymentFlavor> deploymentFlavorCompositionEntityResponse = vendorSoftwareProductManager
- .getDeploymentFlavor(vsp1Id, VERSION01, deployment2Id, USER1);
- final DeploymentFlavor data = deploymentFlavorCompositionEntityResponse.getData();
-
- Assert.assertEquals(
- data.getDescription(),createdDeployment.getDeploymentFlavorCompositionData().getDescription());
- }
-
- @Test
- public void testUpdateVspWithNoFeatureGroup(){
- //Creating a separate deployment flavor for testing deletion
- DeploymentFlavorEntity deploymentFlavorEntity = new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment1Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("TestDeploymentCreateforUpdate");
- deploymentFlavor.setDescription("creating a deployment flavor for updation");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- DeploymentFlavorEntity createdDeployment = vendorSoftwareProductManager
- .createDeploymentFlavor(deploymentFlavorEntity, USER1);
- deployment1Id = createdDeployment.getId();
-
- final DeploymentFlavor deploymentFlavorCompositionData = createdDeployment.getDeploymentFlavorCompositionData();
- deploymentFlavorCompositionData.setModel("TestDeploymentCreateforUpdate"); //no change
- deploymentFlavorCompositionData.setDescription("updating deployment flavor"); //allow change
- createdDeployment.setDeploymentFlavorCompositionData(deploymentFlavorCompositionData);
-
- vendorSoftwareProductManager.updateDeploymentFlavor(createdDeployment, USER1);
- CompositionEntityResponse<DeploymentFlavor> deploymentFlavorCompositionEntityResponse =
- vendorSoftwareProductManager.getDeploymentFlavor(vsp2Id, VERSION01, deployment1Id, USER1);
- final DeploymentFlavor data = deploymentFlavorCompositionEntityResponse.getData();
-
- Assert.assertEquals(data.getDescription(),createdDeployment.getDeploymentFlavorCompositionData()
- .getDescription());
- }
-
- private void testUpdateNegative(DeploymentFlavorEntity deploymentFlavorEntity, String user,
- String expectedErrorCode) {
- try {
- vendorSoftwareProductManager
- .updateDeploymentFlavor(deploymentFlavorEntity, user);
- System.out.print("updated");
- Assert.fail();
- } catch (CoreException exception) {
- Assert.assertEquals(exception.code().id(), expectedErrorCode);
- }
- }
-
- @Test
- public void testDelete(){
- //Creating a separate deployment flavor for testing deletion
- DeploymentFlavorEntity deploymentFlavorEntity =
- new DeploymentFlavorEntity(vsp2Id, VERSION01, deployment2Id);
- DeploymentFlavor deploymentFlavor = new DeploymentFlavor();
- deploymentFlavor.setModel("TestDeploymentcreateWithoutFG");
- deploymentFlavor.setDescription("creating a deployment flavor without any FG and any " +
- "association");
- deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavor);
- DeploymentFlavorEntity createddeployment = vendorSoftwareProductManager.createDeploymentFlavor
- (deploymentFlavorEntity, USER1);
- deployment2Id = createddeployment.getId();
- vendorSoftwareProductManager.deleteDeploymentFlavor(vsp2Id, deployment2Id, USER1);
- testDeleteNegative(vsp2Id, deployment2Id, USER1,
- VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- @Test
- public void testDeleteNegative_InvalidVspId(){
- testDeleteNegative("InvalidVspId", deployment2Id, USER1,
- VERSIONABLE_ENTITY_NOT_EXIST);
- }
-
- @Test
- public void testDeleteNegative_NonExistingDeploymentFlavorId(){
- testDeleteNegative(vsp2Id, "NonExistingDeploymentFlavorId", USER1,
- VERSIONABLE_SUB_ENTITY_NOT_FOUND);
- }
-
- private void testDeleteNegative(String vspId, String deploymentId, String user,
- String expectedErrorCode) {
- try {
- vendorSoftwareProductManager
- .deleteDeploymentFlavor(vspId, deploymentId, 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/VspHealTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VspHealTest.java
deleted file mode 100644
index c091dcadac..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/VspHealTest.java
+++ /dev/null
@@ -1,217 +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;
-
-public class VspHealTest {/*
- private static VendorSoftwareProductManager vendorSoftwareProductManager = null;
- //new VendorSoftwareProductManagerImpl();
- private VendorSoftwareProductManagerImplTest vendorSoftwareProductManagerTest =
- new VendorSoftwareProductManagerImplTest();
- private static OrchestrationTemplateCandidateDao orchestrationTemplateCandidateDataDao =
- OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface();
- private static VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
- private static ComponentDao componentDao =
- ComponentDaoFactory.getInstance().createInterface();
- private static CompositionDataExtractor compositionDataExtractor =
- CompositionDataExtractorFactory.getInstance().createInterface();
- private static NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface();
- private static NicDao nicDao = NicDaoFactory.getInstance().createInterface();
- private static VspDetails vspDetails;
- private static final String USER = "vspTestUser1";
- public static final Version VERSION01 = new Version(0, 1);
- private static String vspId;
- private OrchestrationTemplateCandidateManager candidateManager;
-
- @BeforeTest
- private void init() {
- try {
- vspDetails = new VspDetails();
- vspDetails.setName("vspName_" + CommonMethods.nextUuId());
- vspDetails.setVendorName("vendor");
- vspId = vendorSoftwareProductManager.createVsp(vspDetails, USER).getId();
-
- } catch (Exception ignored) {
- System.out.println(ignored.getMessage());
- }
- }
-
- @Test
- public void shouldReturnEmptyFileDataStructureBeforeZipUpload() {
- Optional<FilesDataStructure> candidateFilesDataStructure = candidateManager
- .getFilesDataStructure(vspId, VERSION01, USER);
- Assert.assertNotNull(candidateFilesDataStructure);
- Assert.assertTrue(candidateFilesDataStructure.isPresent());
-
- checkFileDataStructureListsAreEmpty(candidateFilesDataStructure.get());
- }
-
- @Test(dependsOnMethods = "shouldReturnEmptyFileDataStructureBeforeZipUpload")
- public void shouldReturnFileDataStructureOnEmptyFileDataStructureInDB() {
- uploadAndProcessOrchestrationTemplate(vspId, USER, "/vspmanager/zips/emptyComposition.zip");
-
- orchestrationTemplateCandidateDataDao
- .deleteOrchestrationTemplateCandidateFileDataStructure(vspId, VERSION01);
- Assert.assertEquals(Optional.empty(), orchestrationTemplateCandidateDataDao
- .getOrchestrationTemplateCandidateFileDataStructure(vspId, VERSION01));
-
- Optional<FilesDataStructure> candidateFilesDataStructure = candidateManager
- .getFilesDataStructure(vspId, VERSION01, USER);
- Assert.assertNotNull(candidateFilesDataStructure);
- Assert.assertTrue(candidateFilesDataStructure.isPresent());
- }
-
- @Test(dependsOnMethods = "shouldReturnEmptyFileDataStructureBeforeZipUpload")
- public void shouldReturnEmptyFileDataStructureOnEmptyUpload() {
- try {
- uploadAndProcessOrchestrationTemplate(vspId, USER, "/vspmanager/zips/zipFileWithFolder.zip");
- } catch (Exception e) {
- Assert.assertEquals(e.getMessage(),
- "Failed to get orchestration template for VSP with id " + vspId);
- }
- }
-
- @Test(dependsOnMethods = {"shouldReturnEmptyFileDataStructureOnEmptyUpload"})
- public void shouldHealVspOnIsOldTrue() {
- vspDetails.setOldVersion(VersionHealingValues.True);
- vendorSoftwareProductDao.updateQuestionnaire(vspId, VERSION01, null);
-
- vendorSoftwareProductManager.heal(vspId, VERSION01, USER);
-
- VspQuestionnaireEntity questionnaire =
- vendorSoftwareProductDao.getQuestionnaire(vspId, VERSION01);
-
- Assert.assertNotNull(questionnaire.getQuestionnaireData());
- }
-
- @Test(dependsOnMethods = {"shouldHealVspOnIsOldTrue"})
- public void shouldHealNullQuestionnaire() {
- vendorSoftwareProductDao.updateQuestionnaire(vspId, VERSION01, null);
- vendorSoftwareProductManager.heal(vspId, VERSION01, USER);
- QuestionnaireResponse vspQuestionnaire =
- vendorSoftwareProductManager.getVspQuestionnaire(vspId, VERSION01, USER);
-
- Assert.assertNotNull(vspQuestionnaire.getData());
- }
-
- @Test(dependsOnMethods = {"shouldHealNullQuestionnaire"})
- public void shouldHealNullCompositionData() {
- uploadAndProcessOrchestrationTemplate(vspId, USER, "/vspmanager/zips/fullComposition.zip");
-
- Collection<ComponentEntity> componentEntitiesBeforeHeal =
- vendorSoftwareProductDao.listComponents(vspId, VERSION01);
- Collection<NetworkEntity> networkEntitiesBeforeHeal =
- vendorSoftwareProductDao.listNetworks(vspId, VERSION01);
-
- deleteCompositionData(vspId, VERSION01);
-
- vendorSoftwareProductManager.heal(vspId, VERSION01, USER);
-
- Collection<ComponentEntity> componentEntitiesAfterHeal =
- vendorSoftwareProductDao.listComponents(vspId, VERSION01);
- Collection<NetworkEntity> networkEntitiesAfterHeal =
- vendorSoftwareProductDao.listNetworks(vspId, VERSION01);
-
- checkCompositionDataIsHealed(componentEntitiesBeforeHeal, networkEntitiesBeforeHeal,
- componentEntitiesAfterHeal, networkEntitiesAfterHeal);
- }
-
- @Test(dependsOnMethods = {"shouldHealNullCompositionData"})
- public void shouldChangeComponentDisplayName() {
- uploadAndProcessOrchestrationTemplate(vspId, USER, "/vspmanager/zips/vCDN.zip");
-
- List<ComponentEntity> componentEntitiesBeforeHeal =
- (List<ComponentEntity>) vendorSoftwareProductDao.listComponents(vspId, VERSION01);
- Collection<ComponentEntity> componentsToHeal = new ArrayList<>();
-
- for (ComponentEntity component : componentEntitiesBeforeHeal) {
- changeComponentDisplayNameToOldVersion(component);
- }
-
- vendorSoftwareProductManager.heal(vspId, VERSION01, USER);
-
- List<ComponentEntity> componentEntitiesAfterHeal =
- (List<ComponentEntity>) vendorSoftwareProductDao.listComponents(vspId, VERSION01);
-
- assertComponentdisplayNameAsExpected(componentEntitiesBeforeHeal, componentEntitiesAfterHeal);
- }
-
- private void assertComponentdisplayNameAsExpected(
- List<ComponentEntity> componentEntitiesBeforeHeal,
- List<ComponentEntity> componentEntitiesAfterHeal) {
- ComponentEntity componentBefore = componentEntitiesBeforeHeal.get(0);
- ComponentEntity componentAfter = componentEntitiesAfterHeal.get(0);
- Assert.assertNotEquals(componentBefore, componentAfter);
-
- ComponentData componsitionDataBefore = componentBefore.getComponentCompositionData();
- ComponentData compositionDataAfter = componentAfter.getComponentCompositionData();
- Assert.assertTrue(
- componsitionDataBefore.getDisplayName().contains(compositionDataAfter.getDisplayName()));
- Assert.assertEquals(
- compositionDataExtractor.getComponentDisplayName(componsitionDataBefore.getName()),
- compositionDataAfter.getDisplayName());
- }
-
- private void changeComponentDisplayNameToOldVersion(ComponentEntity component) {
- ComponentData componentData = component.getComponentCompositionData();
- componentData.setDisplayName(componentData.getName());
- componentData.setVfcCode(componentData.getDisplayName());
- component.setComponentCompositionData(componentData);
- vendorSoftwareProductDao.updateComponent(component);
- }
-
-
- private void uploadAndProcessOrchestrationTemplate(String vspId, String user,
- String filePath) {
-
- candidateManager.upload(vspId, VERSION01,
- vendorSoftwareProductManagerTest
- .getFileInputStream(filePath), user);
- candidateManager.process(vspId, VERSION01, user);
- }
-
- private void deleteCompositionData(String vspId, Version version) {
- componentDao.deleteAll(vspId, version);
- networkDao.deleteAll(vspId, version);
- nicDao.deleteByVspId(vspId, version);
- }
-
- private void checkCompositionDataIsHealed(Collection<ComponentEntity> componentEntitiesBeforeHeal,
- Collection<NetworkEntity> networkEntitiesBeforeHeal,
- Collection<ComponentEntity> componentEntitiesAfterHeal,
- Collection<NetworkEntity> networkEntitiesAfterHeal) {
- Assert.assertNotNull(componentEntitiesAfterHeal);
- Assert.assertNotNull(networkEntitiesAfterHeal);
-
- Assert.assertEquals(componentEntitiesBeforeHeal.size(), componentEntitiesAfterHeal.size());
- Assert.assertEquals(networkEntitiesBeforeHeal.size(), networkEntitiesAfterHeal.size());
- }
-
-
- private void checkFileDataStructureListsAreEmpty(FilesDataStructure filesDataStructure) {
- Assert.assertEquals(filesDataStructure.getArtifacts().size(), 0);
- Assert.assertEquals(filesDataStructure.getModules().size(), 0);
- Assert.assertEquals(filesDataStructure.getNested().size(), 0);
- Assert.assertEquals(filesDataStructure.getUnassigned().size(), 0);
- }
-
-*/
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/QuestionnaireValidatorTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/QuestionnaireValidatorTest.java
deleted file mode 100644
index fbd8371d7b..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/QuestionnaireValidatorTest.java
+++ /dev/null
@@ -1,94 +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.services;
-
-public class QuestionnaireValidatorTest {
-/*
- public static QuestionnaireValidator validator = new QuestionnaireValidator();
-
- @Test(expectedExceptions = CoreException.class)
- public void testAddSubEntityBeforeRoot_negative() {
- validator.addSubEntity(createComponent("componentId2"), CompositionEntityType.vsp);
- }
-
- @Test(dependsOnMethods = "testAddSubEntityBeforeRoot_negative")
- public void testAddRootEntity() {
- validator.addRootEntity(createVspQuestionnaireEntity());
- }
-
- @Test(dependsOnMethods = "testAddRootEntity", expectedExceptions = CoreException.class)
- public void testAddRootEntityWhenAlreadyExist_negative() {
- validator.addRootEntity(createVspQuestionnaireEntity());
- }
-
- @Test(dependsOnMethods = "testAddRootEntity")
- public void testAddSubEntity() {
- validator.addSubEntity(createComponent("componentId1"), CompositionEntityType.vsp);
- }
-
- @Test(dependsOnMethods = "testAddRootEntity", expectedExceptions = CoreException.class)
- public void testAddSubEntityWithNonExistingParentType() {
- validator.addSubEntity(new ComponentEntity("vspId1", new Version(0, 1), "componentId2"), CompositionEntityType.nic);
- }
-
- @Test(dependsOnMethods = "testAddSubEntity")
- public void testAddSubEntities() throws Exception {
- Collection<UnifiedCompositionEntity> nics = new ArrayList<>();
- nics.add(createNic("nicId1", "componentId1"));
- nics.add(createNic("nicId2", "componentId1"));
- nics.add(createNic("nicId3", "componentId1"));
-
- validator.addSubEntities(nics, CompositionEntityType.component);
- }
-
-
- @Test(dependsOnMethods = "testAddSubEntities")
- public void testValidate() throws Exception {
- QuestionnaireValidationResult validationResult = validator.validate();
- Assert.assertTrue(validationResult.isValid());
- }
-
- private static VspQuestionnaireEntity createVspQuestionnaireEntity() {
- VspQuestionnaireEntity vspQuestionnaireEntity = new VspQuestionnaireEntity();
- vspQuestionnaireEntity.setId("vspId1");
- vspQuestionnaireEntity.setVersion(new Version(0, 1));
- vspQuestionnaireEntity.setQuestionnaireData("{\n" +
- " \"name\": \"bla bla\"\n" +
- "}");
- return vspQuestionnaireEntity;
- }
-
- private static ComponentEntity createComponent(String componentId) {
- ComponentEntity component = new ComponentEntity("vspId1", new Version(0, 1), componentId);
- component.setQuestionnaireData("{\n" +
- " \"name\": \"bla bla\"\n" +
- "}");
- return component;
- }
-
- private static UnifiedCompositionEntity createNic(String nicId, String componentId) {
- NicEntity nic = new NicEntity("vspId1", new Version(0, 1), componentId, nicId);
- nic.setQuestionnaireData("{\n" +
- " \"name\": \"bla bla\"\n" +
- "}");
- return nic;
- }*/
-}
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 5c4557360e..ea2d068bfd 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
@@ -20,6 +20,14 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.impl;
+import static org.mockito.Mockito.doReturn;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
import org.apache.commons.collections4.CollectionUtils;
import org.mockito.InjectMocks;
import org.mockito.Mock;
@@ -40,15 +48,6 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-
-import static org.mockito.Mockito.doReturn;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
/**
* @author Avrahamg
* @since November 09, 2016
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 dc5b126482..9aabef6234 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
@@ -16,6 +16,15 @@
package org.openecomp.sdc.vendorsoftwareproduct.services.impl.composition;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.NotDirectoryException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.io.FileUtils;
import org.mockito.InjectMocks;
import org.mockito.MockitoAnnotations;
@@ -31,16 +40,6 @@ import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.file.NotDirectoryException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @author shiria
* @since July 17, 2016.
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
deleted file mode 100644
index 237e9cce8f..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/services/schemagenerator/SchemaGeneratorTest.java
+++ /dev/null
@@ -1,250 +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.services.schemagenerator;
-
-public class SchemaGeneratorTest {
- /*
-
- private static int getMinOfVmMax(JSONObject schemaJson) {
- return schemaJson.getJSONObject("properties").getJSONObject("compute")
- .getJSONObject("properties").getJSONObject("numOfVMs").getJSONObject("properties")
- .getJSONObject("maximum").getInt("minimum");
- }
-
- private static JSONObject validateSchema(String schema) {
- System.out.println(schema);
- Assert.assertNotNull(schema);
- Assert.assertTrue(JsonUtil.isValidJson(schema));
- JSONObject schemaJson = new JSONObject(schema);
- Assert.assertFalse(SchemaLoader.load(schemaJson) instanceof EmptySchema);
- return schemaJson;
- }
-
- // TODO: 3/15/2017 fix and enable //@Test
- public void testGenerateVspQuestionnaire() {
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, null);
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateNetworkCompositionUpload() {
- Network network = new Network();
- network.setName("upload network1 name");
- network.setDhcp(true);
-
- NetworkCompositionSchemaInput input = new NetworkCompositionSchemaInput();
- input.setManual(false);
- input.setNetwork(network);
-
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.network, input);
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateNetworkCompositionManual() {
- NetworkCompositionSchemaInput input = new NetworkCompositionSchemaInput();
- input.setManual(true);
-
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.network, input);
-
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateComponentQuestionnaireWithoutInput() {
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component, null);
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateComponentQuestionnaireWithMissingInput() {
- ComponentQuestionnaireSchemaInput
- input = new ComponentQuestionnaireSchemaInput(Arrays.asList("nic1", "nic2"),
- JsonUtil.json2Object("{\n" +
- " \"compute\": {\n" +
- " \"numOfVMs\": {\n" +
- " \"blabla\": 70\n" + // no minimum
- " }\n" +
- " }\n" +
- "}", Map.class));
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component, input);
- JSONObject schemaJson = validateSchema(schema);
- //Assert.assertEquals(getMinOfVmMax(schemaJson), 0);
- }
-
- @Test
- public void testGenerateComponentQuestionnaireWithInvalidTypeInput() {
- ComponentQuestionnaireSchemaInput input =
- new ComponentQuestionnaireSchemaInput(Arrays.asList("nic1", "nic2"),
- JsonUtil.json2Object("{\n" +
- " \"compute\": {\n" +
- " \"numOfVMs\": {\n" +
- " \"minimum\": \"some string instead of integer\"\n" +
- // invalid minimum - string
- " }\n" +
- " }\n" +
- "}", Map.class));
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component, input);
- JSONObject schemaJson = validateSchema(schema);
- Assert.assertEquals(getMinOfVmMax(schemaJson), 0);
- }
-
- @Test
- public void testGenerateComponentQuestionnaireWithInvalidRangeInput() {
- ComponentQuestionnaireSchemaInput input =
- new ComponentQuestionnaireSchemaInput(Arrays.asList("nic1", "nic2"),
- JsonUtil.json2Object("{\n" +
- " \"compute\": {\n" +
- " \"numOfVMs\": {\n" +
- " \"minimum\": 150\n" + // invalid minimum - integer out of range (0-100)
- " }\n" +
- " }\n" +
- "}", Map.class));
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component, input);
- JSONObject schemaJson = validateSchema(schema);
- Assert.assertEquals(getMinOfVmMax(schemaJson), 0);
- }
-
- @Test
- public void testGenerateComponentQuestionnaireWithValidInput() {
- ComponentQuestionnaireSchemaInput input =
- new ComponentQuestionnaireSchemaInput(Arrays.asList("nic1", "nic2"),
- JsonUtil.json2Object("{\n" +
- " \"compute\": {\n" +
- " \"numOfVMs\": {\n" +
- " \"minimum\": 30\n" + // valid minimum - integer at the correct range (0-100)
- " }\n" +
- " }\n" +
- "}", Map.class));
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.component, input);
- JSONObject schemaJson = validateSchema(schema);
- Assert.assertEquals(getMinOfVmMax(schemaJson), 30);
- }
-
- @Test
- public void testGenerateNicQuestionnaire() {
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.nic, null);
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateComponentCompositionUpload() {
- ComponentData component = new ComponentData();
- component.setName("upload comp1 name");
- component.setDescription("upload comp1 desc");
-
- ComponentCompositionSchemaInput input = new ComponentCompositionSchemaInput();
- input.setManual(false);
- input.setComponent(component);
-
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.component, input);
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateComponentCompositionManual() {
- ComponentCompositionSchemaInput input = new ComponentCompositionSchemaInput();
- input.setManual(true);
-
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.component, input);
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateNicCompositionUpload() {
- Nic nic = new Nic();
- nic.setName("upload nic1 name");
- nic.setDescription("upload nic1 desc");
- nic.setNetworkId("upload nic1 networkId");
- //nic.setNetworkName("upload nic1 networkName");
- nic.setNetworkType(NetworkType.External);
-
- NicCompositionSchemaInput input = new NicCompositionSchemaInput();
- input.setManual(false);
- input.setNic(nic);
-
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.nic, input);
- validateSchema(schema);
- }
-
-
-// @Test
-// public void testGenerateNicCompositionManualWithoutNetworkId() {
-// Nic nic = new Nic();
-// nic.setName("upload nic1 name");
-// nic.setDescription("upload nic1 desc");
-// //nic.setNetworkName("upload nic1 networkName");
-// nic.setNetworkType(NetworkType.External);
-//
-// NicCompositionSchemaInput input = new NicCompositionSchemaInput();
-// input.setManual(true);
-// input.setNic(nic);
-//
-// String schema = SchemaGenerator.generate(SchemaTemplateContext.composition, CompositionEntityType.nic, input);
-// validateSchema(schema);
-// }
-
- @Test
- public void testGenerateNicCompositionUploadWithoutNetworkId() {
- Nic nic = new Nic();
- nic.setName("upload nic1 name");
- nic.setDescription("upload nic1 desc");
- //nic.setNetworkName("upload nic1 networkName");
- nic.setNetworkType(NetworkType.External);
-
- NicCompositionSchemaInput input = new NicCompositionSchemaInput();
- input.setManual(false);
- input.setNic(nic);
-
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.nic, input);
- validateSchema(schema);
- }
-
- @Test
- public void testGenerateNicCompositionManual() {Nic nic = new Nic();
- nic.setName("upload nic1 name");
- nic.setDescription("upload nic1 desc");
- nic.setNetworkType(NetworkType.Internal);
- NicCompositionSchemaInput input = new NicCompositionSchemaInput();
-
- input.setManual(true);
- input.setNetworkIds(
- Arrays.asList("manual networkId1", "manual networkId2", "manual networkId3"));
- input.setNic(nic);
- String schema = SchemaGenerator
- .generate(SchemaTemplateContext.composition, CompositionEntityType.nic, input);
- validateSchema(schema);
- }
- */
-}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/HeatTreeManagerTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/HeatTreeManagerTest.java
index 6f2bfd8a06..61c8f0515f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/HeatTreeManagerTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/HeatTreeManagerTest.java
@@ -20,12 +20,12 @@ 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.services.tree.HeatTreeManager;
-import org.testng.Assert;
-import org.testng.annotations.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;
+import org.testng.Assert;
+import org.testng.annotations.Test;
public class HeatTreeManagerTest extends TreeBaseTest {
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 2e0cbbbf05..10f09260ef 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,6 +21,17 @@
package org.openecomp.sdc.vendorsoftwareproduct.tree;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.testng.Assert.assertEquals;
+
+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;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -44,14 +55,6 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.*;
-import java.net.URL;
-import java.util.zip.ZipOutputStream;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-import static org.testng.Assert.assertEquals;
-
public class UploadFileTest {
private static final String USER1 = "vspTestUser1";
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
deleted file mode 100644
index 13f3859c0c..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/HeatCleanup/HeatCleanupOnNewUploadTest.java
+++ /dev/null
@@ -1,154 +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.upload.HeatCleanup;
-
-public class HeatCleanupOnNewUploadTest {/*
- private static final String USER1 = "vspTestUser1";
-
- private static final VendorSoftwareProductManager
- vendorSoftwareProductManager = new VendorSoftwareProductManagerImpl();
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory
- .getInstance().createInterface();
- private static final ServiceModelDao serviceModelDao =
- ServiceModelDaoFactory.getInstance().createInterface();
-
- private static String vspId = null;
- private static Version vspActiveVersion = null;
-
- private static void validateUploadContentExistence(boolean exist) {
- UploadDataEntity uploadDataEntity =
- vendorSoftwareProductDao.getUploadData(new UploadDataEntity(vspId, vspActiveVersion));
- Assert.assertTrue((uploadDataEntity.getContentData() != 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
- //Assert.assertTrue((serviceModelDao.getServiceModel(vspId, vspActiveVersion) != null) == ex
- }
-
- private static void validateCompositionDataExistence(boolean exist) {
- Assert.assertTrue(CollectionUtils
- .isNotEmpty(vendorSoftwareProductDao.listNetworks(vspId, vspActiveVersion)) == exist);
- Assert.assertTrue(CollectionUtils
- .isNotEmpty(vendorSoftwareProductDao.listComponents(vspId, vspActiveVersion)) == exist);
- Assert.assertTrue(CollectionUtils
- .isNotEmpty(vendorSoftwareProductDao.listNicsByVsp(vspId, vspActiveVersion)) == exist);
- }
-
- private static InputStream getFileInputStream(String fileName) {
- URL url = HeatCleanupOnNewUploadTest.class.getResource(fileName);
- try {
- return url.openStream();
- } catch (IOException exception) {
- exception.printStackTrace();
- return null;
- }
- }
-
- @BeforeClass
- private void init() {
- UniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- "VSPTestEmpty");
-
- VspDetails vspDetails = vendorSoftwareProductManager.createVsp(VSPCommon
- .createVspDetails(null, null, "VSPTestEmpty", "Test-vsp-empty", "vendorName", "vlm1Id",
- "icon", "category", "subCategory", "123", null, VSPCommon.OnboardingMethod.HEAT.name()),
- USER1);
- vspId = vspDetails.getId();
- vspActiveVersion = vspDetails.getVersion();
- }
-
- @Test
- public void testUploadWithComposition() {
- InputStream zis = getFileInputStream("/vspmanager/zips/fullComposition.zip");
-
- vendorSoftwareProductManager.upload(vspId, zis, USER1);
- OrchestrationTemplateActionResponse orchestrationTemplateActionResponse =
- vendorSoftwareProductManager.process(vspId, USER1);
-
- Assert.assertEquals(orchestrationTemplateActionResponse.getStatus(), UploadFileStatus.Success);
- Assert.assertTrue(MapUtils.isEmpty(MessageContainerUtil
- .getMessageByLevel(ErrorLevel.ERROR, orchestrationTemplateActionResponse.getErrors())));
-
- validateUploadContentExistence(true);
- validateCompositionDataExistence(true);
- }
-
- @Test(dependsOnMethods = {"testUploadWithComposition"})
- public void testProccesesMIBsDeletionAfterNewUpload() {
- InputStream zis1 = getFileInputStream("/vspmanager/zips/fullComposition.zip");
- InputStream zis2 = getFileInputStream("/vspmanager/zips/fullComposition.zip");
- InputStream mib = getFileInputStream("/vspmanager/zips/vDNS.zip");
-
- vendorSoftwareProductManager.upload(vspId, zis1, USER1);
- vendorSoftwareProductManager.process(vspId, USER1);
- List<ComponentEntity> components =
- (List<ComponentEntity>) vendorSoftwareProductDao.listComponents(vspId, vspActiveVersion);
- String componentId = components.get(0).getId();
-
- vendorSoftwareProductManager
- .upload(mib, "vDNS.zip", vspId, componentId, MonitoringUploadType.SNMP_TRAP, USER1);
- vendorSoftwareProductManager
- .createProcess(new ProcessEntity(vspId, vspActiveVersion, componentId, null), USER1);
-
- vendorSoftwareProductManager.upload(vspId, zis2, USER1);
- vendorSoftwareProductManager.process(vspId, USER1);
- Assert.assertTrue(
- vendorSoftwareProductManager.listFilenames(vspId, componentId, USER1).getSnmpTrap() ==
- null);
- Assert.assertTrue(CollectionUtils
- .isEmpty(vendorSoftwareProductDao.listProcesses(vspId, vspActiveVersion, componentId)));
- }
-
- @Test(dependsOnMethods = {"testProccesesMIBsDeletionAfterNewUpload"})
- public void testInvalidUploadAfterFullComposition() {
- InputStream zis = getFileInputStream("/vspmanager/zips/missingYml.zip");
-
- vendorSoftwareProductManager.upload(vspId, zis, USER1);
- OrchestrationTemplateActionResponse uploadFileResponse =
- vendorSoftwareProductManager.process(vspId, USER1);
- Assert.assertEquals(uploadFileResponse.getStatus(), UploadFileStatus.Failure);
- Assert.assertTrue(MapUtils.isNotEmpty(
- MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, uploadFileResponse.getErrors())));
-
- validateUploadContentExistence(true);
- //TODO: talio - check upload cleanup
-// validateCompositionDataExistence(false);
- }
-
- @Test(dependsOnMethods = {"testInvalidUploadAfterFullComposition"})
- public void testEmptyCompositionUploadAfterFullComposition() throws IOException {
- testUploadWithComposition();
-
- InputStream zis = getFileInputStream("/vspmanager/zips/emptyComposition.zip");
- vendorSoftwareProductManager.upload(vspId, zis, USER1);
- OrchestrationTemplateActionResponse uploadFileResponse =
- vendorSoftwareProductManager.process(vspId, USER1);
- Assert.assertEquals(uploadFileResponse.getStatus(), UploadFileStatus.Success);
- Assert.assertTrue(MapUtils.isEmpty(
- MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, uploadFileResponse.getErrors())));
-
- validateUploadContentExistence(true);
- validateCompositionDataExistence(false);
- }
-*/}
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 f0b37f5ffe..687ddc18c4 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
@@ -1,13 +1,32 @@
+/*
+ * 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.upload.csar;
-import org.junit.Test;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
import org.openecomp.sdc.common.errors.Messages;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.csar.OnboardingManifest;
import java.io.IOException;
import java.io.InputStream;
+import org.testng.annotations.Test;
-import static org.junit.Assert.*;
public class ManifestParsingTest {
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 5d56ffa061..42b7dc37d4 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
@@ -17,6 +17,17 @@
package org.openecomp.sdc.vendorsoftwareproduct.upload.csar;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.function.Predicate;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -34,18 +45,6 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.function.Predicate;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doReturn;
-
public class UploadCSARFileTest {
public static final Version VERSION01 = new Version("0.1");
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/validation/UploadFileValidationTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/validation/UploadFileValidationTest.java
deleted file mode 100644
index 0aa3e4037d..0000000000
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/upload/validation/UploadFileValidationTest.java
+++ /dev/null
@@ -1,201 +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.upload.validation;
-
-public class UploadFileValidationTest {
-/*
-
- private static final String USER1 = "UploadFileValidationTest";
- private static final String EMPTY_ZIP_FILE = "/validation/zips/emptyZip.zip";
- private static final String MISSING_MANIFEST_IN_ZIP_FILE =
- "/validation/zips/missingManifestInZip.zip";
- private static final String ZIP_FILE_WITH_FOLDER = "/validation/zips/zipFileWithFolder.zip";
- private static VendorSoftwareProductManager vendorSoftwareProductManager =
- new VendorSoftwareProductManagerImpl();
- private static String vspId;
-
- public static VendorLicenseModelEntity createVendorLicenseModel(String name, String desc,
- String icon) {
- VendorLicenseModelEntity vendorLicenseModel = new VendorLicenseModelEntity();
- vendorLicenseModel.setVendorName(name);
- vendorLicenseModel.setDescription(desc);
- vendorLicenseModel.setIconRef(icon);
- return vendorLicenseModel;
- }
-
- @BeforeTest
- private void init() {
- VspDetails vspDetails = new VspDetails();
- vspDetails.setVendorName("vspName_" + CommonMethods.nextUuId());
- vspId = vendorSoftwareProductManager.createVsp(vspDetails, USER1).getId();
-
- UniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- "VSP_syb_upload_various");
- UniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- "vsp_syb_upload_no_error");
- UniqueValueUtil
- .deleteUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- "vsp_syb");
- }
-
- @Test
- public void testUploadZipNull() {
- try {
- vendorSoftwareProductManager.upload(vspId, null, USER1);
- OrchestrationTemplateActionResponse response =
- vendorSoftwareProductManager.process(vspId, USER1);
- } catch (Exception exception) {
- Assert.assertEquals(exception.getMessage(),
- "Failed to get orchestration template for VSP with id " + vspId);
- }
- }
-
- @Test(dependsOnMethods = "testUploadZipNull")
- public void testUploadEmptyFile() {
- UploadFileResponse uploadFileResponse = vendorSoftwareProductManager
- .upload(vspId, new ByteArrayInputStream("".getBytes()),
- USER1);
- Assert.assertEquals(uploadFileResponse.getErrors().get(SdcCommon.UPLOAD_FILE).get(0)
- .getMessage(),
- Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage());
- }
-
- @Test(dependsOnMethods = "testUploadEmptyFile")
- public void testUploadEmptyZip() {
- UploadFileResponse uploadFileResponse = vendorSoftwareProductManager
- .upload(vspId, getFileInputStream(EMPTY_ZIP_FILE), USER1);
- Assert.assertEquals(uploadFileResponse.getErrors().get(SdcCommon.UPLOAD_FILE).get(0)
- .getMessage(),
- Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());
- */
-/*Assert.assertEquals(exception.getMessage(),
- Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage());*//*
-
- }
-
- @Test(dependsOnMethods = "testUploadEmptyZip")
- public void testUploadMissingManifestInZip() {
- vendorSoftwareProductManager.upload(vspId,
- getFileInputStream(MISSING_MANIFEST_IN_ZIP_FILE), USER1);
- OrchestrationTemplateActionResponse response =
- vendorSoftwareProductManager.process(vspId, USER1);
- Assert.assertEquals(response.getErrors().size(), 2);
- }
-
- @Test(dependsOnMethods = "testUploadMissingManifestInZip")
- public void testUploadZipWithFolder() {
- vendorSoftwareProductManager
- .upload(vspId, getFileInputStream(ZIP_FILE_WITH_FOLDER),
- USER1);
- OrchestrationTemplateActionResponse response =
- vendorSoftwareProductManager.process(vspId, USER1);
- Assert.assertEquals(response.getErrors().size(), 2);
- }
-
- @Test(dependsOnMethods = "testUploadZipWithFolder")
- public void testUploadVariousZips() {
-
- File[] files = getFileList("/validation/zips/various");
- InputStream is;
- for (File file : files) {
- if (file.isFile()) {
- OrchestrationTemplateActionResponse response;
- try {
-
- is = new FileInputStream(file);
- vendorSoftwareProductManager.upload(vspId, is, USER1);
- response =
- vendorSoftwareProductManager.process(vspId, USER1);
-
- } catch (FileNotFoundException exception) {
- throw new RuntimeException(exception);
- } catch (RuntimeException re) {
-
- throw new RuntimeException("failed upload:" + file.getName(), re);
- }
- System.out.println("zip:" + file.getName() + " Errors:" + calculateNumberOfMessages(
- MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, response.getErrors())) +
- " Warnings:" + calculateNumberOfMessages(
- MessageContainerUtil.getMessageByLevel(ErrorLevel.WARNING, response.getErrors())));
- }
- }
- }
-
- @Test(dependsOnMethods = "testUploadVariousZips")
- public void testUploadNoErrorVariousZips() {
-
-
- File[] files = getFileList("/validation/zips/various/noError");
- InputStream is;
- for (File file : files) {
- if (file.isFile()) {
- try {
- is = new FileInputStream(file);
- vendorSoftwareProductManager.upload(vspId, is, USER1);
- OrchestrationTemplateActionResponse response =
- vendorSoftwareProductManager.process(vspId, USER1);
- Map<String, List<ErrorMessage>> errors = response.getErrors();
- Assert.assertTrue(
- MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, errors)));
-
-
- } catch (FileNotFoundException exception) {
- throw new RuntimeException(exception);
- } catch (RuntimeException re) {
- Assert.fail("failed upload:" + file.getName() + " exception:" + re.getMessage());
- }
- }
- }
- }
-
- private InputStream getFileInputStream(String fileName) {
- URL url = this.getClass().getResource(fileName);
- try {
- return url.openStream();
- } catch (IOException exception) {
- exception.printStackTrace();
- return null;
- }
- }
-
- private File[] getFileList(String dir) {
- URL url = UploadFileValidationTest.class.getResource(dir);
-
- String path = url.getPath();
- File pathFile = new File(path);
- return pathFile.listFiles();
-
-
- }
-
- private int calculateNumberOfMessages(Map<String, List<ErrorMessage>> messages) {
- int sum = 0;
- for (List<ErrorMessage> errors : messages.values()) {
- sum += errors.size();
- }
- return sum;
- }
-
-*/
-
-}