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 fj.data.Either;
26 import org.openecomp.sdc.be.model.ComponentInstance;
27 import org.openecomp.sdc.be.model.Resource;
28 import org.openecomp.sdc.be.model.Service;
29 import org.openecomp.sdc.be.model.User;
30 import org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders;
31 import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
32 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
33 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
34 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
35 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
36 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
37 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
38 import org.openecomp.sdc.ci.tests.utilities.FileHandling;
39 import org.openecomp.sdc.ci.tests.utils.general.*;
40 import org.slf4j.LoggerFactory;
41 import org.testng.annotations.BeforeMethod;
42 import org.testng.annotations.Test;
44 import java.sql.Timestamp;
45 import java.util.List;
47 import static org.testng.AssertJUnit.assertTrue;
50 public class OnboardViaApis{
53 private static final String FULL_PATH = "C://tmp//CSARs//";
54 protected static String filepath = FileHandling.getVnfRepositoryPath();
56 //-------------------------------------------------------------------------------------------------------
57 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
58 // ResourceReqDetails resourceDetails;
59 Timestamp timestamp = new Timestamp(System.currentTimeMillis());
64 LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
65 lc.getLogger("org.apache").setLevel(Level.OFF);
66 lc.getLogger("org.*").setLevel(Level.OFF);
67 lc.getLogger("org.openecomp.sdc.ci.tests.datatypes.http.HttpRequest").setLevel(Level.OFF);
68 // resourceDetails = ElementFactory.getDefaultResource();
71 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
72 public void onboardVNFTestViaApis(String filepath, String vnfFile) throws Exception, Throwable {
73 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
74 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
75 Service service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile);
80 public void onboardingAndParser() throws Exception {
81 Service service = null;
82 List<String> fileNamesFromFolder = FileHandling.getZipFileNamesFromFolder(filepath);
83 String vnfFile = fileNamesFromFolder.get(7);
84 System.err.println(timestamp + " Starting test with VNF: " + vnfFile);
85 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
86 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
87 service = runOnboardViaApisOnly(serviceReqDetails, resourceReqDetails, filepath, vnfFile);
90 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
91 public void updateVSPFullScenario(String filepath, String vnfFile) throws Exception
93 //CREATE DATA REQUIRED FOR TEST
94 boolean skipReport = true;
95 AmdocsLicenseMembers amdocsLicenseMembers = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
96 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
97 VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filepath, sdncDesignerDetails1, amdocsLicenseMembers);
98 // VendorSoftwareProductObject vendorSoftwareProductObject = fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
99 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
100 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
101 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
102 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();//getServiceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
103 // serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1);
104 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
105 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
106 ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value();
107 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
110 VendorLicenseModelRestUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails1, false);
111 VendorLicenseModelRestUtils.validateVlmExist(amdocsLicenseMembers.getVendorId(), amdocsLicenseMembers.getVersion(), sdncDesignerDetails1);
113 // Update the VSP With the VLM new version and submit the VSP
114 vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject, amdocsLicenseMembers, sdncDesignerDetails1);
115 VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
116 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
117 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
118 System.out.println(distributeAndValidateService);
121 public Service runOnboardViaApisOnly(ServiceReqDetails serviceReqDetails, ResourceReqDetails resourceReqDetails, String filepath, String vnfFile) throws Exception {
123 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filepath, vnfFile, sdncDesignerDetails1);
124 vendorSoftwareProductObject.setName(vendorSoftwareProductObject.getName());
126 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
127 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
128 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
130 // serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(serviceReqDetails, sdncDesignerDetails1);
131 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
133 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
134 ComponentInstance componentInstanceDefinition = addComponentInstanceToComponentContainer.left().value();
136 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();