2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.ci.tests.execute.sanity;
23 import ch.qos.logback.classic.Level;
24 import ch.qos.logback.classic.LoggerContext;
25 import com.clearspring.analytics.util.Pair;
26 import fj.data.Either;
27 import org.openecomp.sdc.be.model.ComponentInstance;
28 import org.openecomp.sdc.be.model.Resource;
29 import org.openecomp.sdc.be.model.Service;
30 import org.openecomp.sdc.be.model.User;
31 import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders;
32 import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
33 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
34 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
35 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
38 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
39 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
40 import org.openecomp.sdc.ci.tests.utils.general.*;
41 import org.slf4j.LoggerFactory;
42 import org.testng.annotations.BeforeMethod;
43 import org.testng.annotations.Test;
46 import java.sql.Timestamp;
47 import java.util.List;
49 import static org.testng.AssertJUnit.assertTrue;
52 public class OnboardViaApis{
55 private static final String FULL_PATH = "C://tmp//CSARs//";
56 protected static String filepath = FileHandling.getVnfRepositoryPath();
58 //-------------------------------------------------------------------------------------------------------
59 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
60 // ResourceReqDetails resourceDetails;
61 Timestamp timestamp = new Timestamp(System.currentTimeMillis());
66 LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
67 lc.getLogger("org.apache").setLevel(Level.OFF);
68 lc.getLogger("org.*").setLevel(Level.OFF);
69 lc.getLogger("org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest").setLevel(Level.OFF);
70 // resourceDetails = ElementFactory.getDefaultResource();
73 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
74 public void onboardVNFTestViaApis(String filepath, String vnfFile) throws Exception, Throwable {
75 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
76 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
77 Service service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile);
82 public void onboardingAndParser() throws Exception {
83 Service service = null;
84 List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath);
85 String vnfFile = fileNamesFromFolder.get(7);
86 System.err.println(timestamp + " Starting test with VNF: " + vnfFile);
87 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
88 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
89 service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile);
92 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
93 public void updateVSPFullScenario(String filepath, String vnfFile) throws Exception
95 //CREATE DATA REQUIRED FOR TEST
96 boolean skipReport = true;
97 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
98 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
99 Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers);
100 // VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
101 VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
102 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
103 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
104 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
105 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
106 // serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1);
107 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
108 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
109 ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value();
110 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
113 VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails1, false);
114 VendorLicenseModelRestUtils.validateVlmExist(amdocsLicenseMembers.getVendorId(), amdocsLicenseMembers.getVersion(), sdncDesignerDetails1);
116 // Update the VSP With the VLM new version and submit the VSP
117 vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1);
118 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
119 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
120 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
121 System.out.println(distributeAndValidateService);
124 public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception, AWTException {
126 Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1);
127 VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
128 vendorSoftwareProductObject.setName(createVendorSoftwareProduct.left);
130 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
131 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
132 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
134 // serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1);
135 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
137 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
138 ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value();
140 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();