diff options
Diffstat (limited to 'ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java')
-rw-r--r-- | ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java | 230 |
1 files changed, 75 insertions, 155 deletions
diff --git a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java index f32709e219..6cea8d6c6f 100644 --- a/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java +++ b/ui-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/sanity/OnboardViaApis.java @@ -20,16 +20,12 @@ package org.openecomp.sdc.ci.tests.execute.sanity; -import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertTrue; import java.awt.AWTException; -import java.io.File; import java.sql.Timestamp; -import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.UUID; import org.openecomp.sdc.be.model.ComponentInstance; import org.openecomp.sdc.be.model.Resource; @@ -38,16 +34,16 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders; import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers; import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails; +import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails; import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject; import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum; import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum; import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse; import org.openecomp.sdc.ci.tests.utilities.FileHandling; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtillViaApis; -import org.openecomp.sdc.ci.tests.utilities.OnboardingUtils; import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils; import org.openecomp.sdc.ci.tests.utils.general.ElementFactory; -import org.openecomp.sdc.ci.tests.utils.rest.ResponseParser; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis; +import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils; import org.slf4j.LoggerFactory; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -58,6 +54,7 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.LoggerContext; import fj.data.Either; + public class OnboardViaApis{ @@ -79,23 +76,11 @@ public class OnboardViaApis{ // resourceDetails = ElementFactory.getDefaultResource(); } - @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List") + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") public void onboardVNFTestViaApis(String filepath, String vnfFile) throws Exception, Throwable { - Service service = null; - String fullFileName = FULL_PATH + vnfFile + ".csar"; - Timestamp timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Starting test with VNF: " + vnfFile); - service = runOnboardViaApisOnly(filepath, vnfFile); - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Finished test with VNF: " + vnfFile); - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Starting download service csar file: " + vnfFile); - File file = new File(fullFileName); - OnboardingUtillViaApis.downloadToscaCsarToDirectory(service, file); - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Finished download service csar file: " + vnfFile); - System.out.println("end"); - + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Service service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); } @@ -105,148 +90,83 @@ public class OnboardViaApis{ List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath); String vnfFile = fileNamesFromFolder.get(7); System.err.println(timestamp + " Starting test with VNF: " + vnfFile); - service = runOnboardViaApisOnly(filepath, vnfFile); - -// AtomicOperationUtils.getServiceObjectByNameAndVersion(sdncModifierDetails, serviceName, serviceVersion); -// RestResponse distributeService = AtomicOperationUtils.distributeService(service, true); -// Map<Long, ServiceDistributionStatus> convertServiceDistributionStatusToObject = ResponseParser.convertServiceDistributionStatusToObject(distributeService.getResponse()); -// convertServiceDistributionStatusToObject. + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile); } - - - - public Service runOnboardViaApisOnly(String filepath, String vnfFile) throws Exception, AWTException { - Timestamp timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Starting onboard VNF: " + vnfFile); - Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(filepath, vnfFile, sdncDesignerDetails1); - String vspName = createVendorSoftwareProduct.left; - VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; - timestamp = new Timestamp(System.currentTimeMillis()); - System.err.println(timestamp + " Finished onboard VNF: " + vnfFile); - ResourceReqDetails resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(vendorSoftwareProductObject, vspName); - Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails, vspName); - - AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true); - resource = AtomicOperationUtils.getResourceObject(resource.getUniqueId()); - // create service - - Service service = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true).left().value(); - Either<ComponentInstance,RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List") + public void updateVSPFullScenario(String filepath, String vnfFile) throws Exception + { + //CREATE DATA REQUIRED FOR TEST + boolean skipReport = true; + AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1); + ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); + Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers); + VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT); +// serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - return service; - } - - - - - - - - public static Pair<String, Map<String, String>> createVendorSoftwareProduct(String HeatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) - throws Exception { - Pair<String, Map<String, String>> pair = createVSP(HeatFileName, filepath, user, amdocsLicenseMembers); - - String vspid = pair.right.get("vspId"); - - prepareVspForUse(user, vspid); - - return pair; + // TEST START + + // Update exist VLM Version (From 1.0 to 2.0) + OnboardingUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails1, "1.0"); + // Set VLM version to 2.0 in VLM Meta data object + amdocsLicenseMembers.setLicenseVersionId("2.0"); + amdocsLicenseMembers.setLicenseVersionLabel("2.0"); + OnboardingUtils.validateVlmExist(amdocsLicenseMembers.getVendorId(), amdocsLicenseMembers.getLicenseVersionId(), sdncDesignerDetails1); + + // Update the VSP With the VLM new version and submit the VSP + vendorSoftwareProductObject = OnboardingUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1, "1.1", "2.0"); + OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(), sdncDesignerDetails1); + Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service); + assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService); + System.out.println(distributeAndValidateService); } - - public static void prepareVspForUse(User user, String vspid) throws Exception { - RestResponse checkin = OnboardingUtils.checkinVendorSoftwareProduct(vspid, user); - assertEquals("did not succeed to checking new VSP", 200, checkin.getErrorCode().intValue()); - - RestResponse submit = OnboardingUtils.submitVendorSoftwareProduct(vspid, user); - assertEquals("did not succeed to submit new VSP", 200, submit.getErrorCode().intValue()); - - RestResponse createPackage = OnboardingUtils.createPackageOfVendorSoftwareProduct(vspid, user); - assertEquals("did not succeed to create package of new VSP ", 200, createPackage.getErrorCode().intValue()); + public static VendorSoftwareProductObject fillVendorSoftwareProductObjectWithMetaData(String vnfFile, Pair<String, Map<String, String>> createVendorSoftwareProduct) { + VendorSoftwareProductObject vendorSoftwareProductObject = new VendorSoftwareProductObject(); + Map<String, String> map = createVendorSoftwareProduct.right; + vendorSoftwareProductObject.setAttContact(map.get("attContact")); + vendorSoftwareProductObject.setCategory(map.get("category")); + vendorSoftwareProductObject.setComponentId(map.get("componentId")); + vendorSoftwareProductObject.setDescription(map.get("description")); + vendorSoftwareProductObject.setSubCategory(map.get("subCategory")); + vendorSoftwareProductObject.setVendorName(map.get("vendorName")); + vendorSoftwareProductObject.setVspId(map.get("vspId")); + vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); + String[] arrFileNameAndExtension = vnfFile.split("\\."); + vendorSoftwareProductObject.setOnboardingMethod("NetworkPackage"); + vendorSoftwareProductObject.setNetworkPackageName(arrFileNameAndExtension[0]); + vendorSoftwareProductObject.setOnboardingOrigin(arrFileNameAndExtension[1]); + + return vendorSoftwareProductObject; } - public static AmdocsLicenseMembers createVendorLicense(User user) throws Exception { - - AmdocsLicenseMembers amdocsLicenseMembers; - String vendorLicenseName = "ciLicense" + UUID.randomUUID().toString().split("-")[0]; - RestResponse vendorLicenseResponse = OnboardingUtils.createVendorLicenseModels_1(vendorLicenseName, user); - assertEquals("did not succeed to create vendor license model", 200, vendorLicenseResponse.getErrorCode().intValue()); - String vendorId = ResponseParser.getValueFromJsonResponse(vendorLicenseResponse.getResponse(), "value"); - - RestResponse vendorKeyGroupsResponse = OnboardingUtils.createVendorKeyGroups_2(vendorId, user); - assertEquals("did not succeed to create vendor key groups", 200, vendorKeyGroupsResponse.getErrorCode().intValue()); - String keyGroupId = ResponseParser.getValueFromJsonResponse(vendorKeyGroupsResponse.getResponse(), "value"); - - RestResponse vendorEntitlementPool = OnboardingUtils.createVendorEntitlementPool_3(vendorId, user); - assertEquals("did not succeed to create vendor entitlement pool", 200, vendorEntitlementPool.getErrorCode().intValue()); - String entitlementPoolId = ResponseParser.getValueFromJsonResponse(vendorEntitlementPool.getResponse(), "value"); - - RestResponse vendorLicenseFeatureGroups = OnboardingUtils.createVendorLicenseFeatureGroups_4(vendorId, keyGroupId, entitlementPoolId, user); - assertEquals("did not succeed to create vendor license feature groups", 200, vendorLicenseFeatureGroups.getErrorCode().intValue()); - String featureGroupId = ResponseParser.getValueFromJsonResponse(vendorLicenseFeatureGroups.getResponse(), "value"); - RestResponse vendorLicenseAgreement = OnboardingUtils.createVendorLicenseAgreement_5(vendorId, featureGroupId, user); - assertEquals("did not succeed to create vendor license agreement", 200, vendorLicenseAgreement.getErrorCode().intValue()); - String vendorLicenseAgreementId = ResponseParser.getValueFromJsonResponse(vendorLicenseAgreement.getResponse(), "value"); + public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception, AWTException { - RestResponse checkinVendorLicense = OnboardingUtils.checkinVendorLicense(vendorId, user); - assertEquals("did not succeed to checkin vendor license", 200, checkinVendorLicense.getErrorCode().intValue()); - - RestResponse submitVendorLicense = OnboardingUtils.submitVendorLicense(vendorId, user); - assertEquals("did not succeed to submit vendor license", 200, submitVendorLicense.getErrorCode().intValue()); - - amdocsLicenseMembers = new AmdocsLicenseMembers(vendorId, vendorLicenseName, vendorLicenseAgreementId, featureGroupId); - - return amdocsLicenseMembers; - } - - - public static Pair<String, Map<String, String>> createVSP(String HeatFileName, String filepath, User user, AmdocsLicenseMembers amdocsLicenseMembers) throws Exception { - String vspName = OnboardingUtils.handleFilename(HeatFileName); - - Pair<RestResponse, Map<String, String>> createNewVspPair = OnboardingUtils.createNewVendorSoftwareProduct(vspName, amdocsLicenseMembers, user); - RestResponse createNewVendorSoftwareProduct = createNewVspPair.left; - assertEquals("did not succeed to create new VSP", 200,createNewVendorSoftwareProduct.getErrorCode().intValue()); - String vspid = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "vspId"); - String componentId = ResponseParser.getValueFromJsonResponse(createNewVendorSoftwareProduct.getResponse(), "componentId"); - - Map<String, String> vspMeta = createNewVspPair.right; - Map<String, String> vspObject = new HashMap<String, String>(); - Iterator<String> iterator = vspMeta.keySet().iterator(); - while(iterator.hasNext()){ - Object key = iterator.next(); - Object value = vspMeta.get(key); - vspObject.put(key.toString(), value.toString()); - } - vspObject.put("vspId", vspid); - vspObject.put("componentId", componentId); - vspObject.put("vendorName", amdocsLicenseMembers.getVendorLicenseName()); - vspObject.put("attContact", user.getUserId()); - - RestResponse uploadHeatPackage = OnboardingUtils.uploadHeatPackage(filepath, HeatFileName, vspid, user); - assertEquals("did not succeed to upload HEAT package", 200, uploadHeatPackage.getErrorCode().intValue()); + Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1); + VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right; + vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left); - RestResponse validateUpload = OnboardingUtils.validateUpload(vspid, user); - assertEquals("did not succeed to validate upload process", 200, validateUpload.getErrorCode().intValue()); + resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject); + Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails); + resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); - Pair<String, Map<String, String>> pair = new Pair<String, Map<String, String>>(vspName, vspObject); +// serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1); + Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value(); - return pair; - } - - - - - - - - - -// ---------------------------------------------------------------------------------------------------------------------------------------- - - - - + Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true); + ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value(); + service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft(); + return service; + } } |