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.sanity;
27 import org.junit.Rule;
28 import org.junit.rules.TestName;
29 import org.openecomp.sdc.be.model.ComponentInstance;
30 import org.openecomp.sdc.be.model.Resource;
31 import org.openecomp.sdc.be.model.Service;
32 import org.openecomp.sdc.be.model.User;
33 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
34 import org.openecomp.sdc.ci.tests.api.ExtentTestActions;
35 import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders;
36 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
37 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
38 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
41 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
42 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
43 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
44 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis;
45 import org.testng.annotations.BeforeMethod;
46 import org.testng.annotations.Optional;
47 import org.testng.annotations.Parameters;
48 import org.testng.annotations.Test;
50 import com.aventstack.extentreports.Status;
51 import com.clearspring.analytics.util.Pair;
53 import fj.data.Either;
60 public class Onboard extends ComponentBaseTest {
64 public static TestName name = new TestName();
67 super(name, Onboard.class.getName());
70 protected String makeDistributionValue;
74 @Parameters({ "makeDistribution" })
76 public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) {
77 makeDistributionValue = makeDistributionReadValue;
81 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
82 public void onboardVNFShotFlow(String filepath, String vnfFile) throws Exception, Throwable {
84 System.out.println("print - >" + makeDistributionValue);
85 runOnboardToDistributionFlow(filepath, vnfFile);
92 public void runOnboardToDistributionFlow(String filepath, String vnfFile) throws Exception {
94 ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile));
95 User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
97 Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(filepath, vnfFile, user);
98 VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
99 vendorSoftwareProductObject.setVspName(createVendorSoftwareProduct.left);
101 // create VF base on VNF imported from previous step - have, resourceReqDetails object include part of resource metadata
102 ResourceReqDetails resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(vendorSoftwareProductObject, vendorSoftwareProductObject.getVspName());
103 ExtentTestActions.log(Status.INFO, String.format("Create VF %s From VSP", resourceReqDetails.getName()));
104 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails, vendorSoftwareProductObject.getVspName());
105 ExtentTestActions.log(Status.INFO, String.format("Certify VF"));
106 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
108 //--------------------------SERVICE--------------------------------
109 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(user);
110 ExtentTestActions.log(Status.INFO, String.format("Create Service %s", serviceReqDetails.getName()));
111 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
112 ExtentTestActions.log(Status.INFO, String.format("add VF to Service"));
113 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
114 addComponentInstanceToComponentContainer.left().value();
115 ExtentTestActions.log(Status.INFO, String.format("Certify Service"));
116 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
118 // ExtentTestActions.log(Status.INFO, String.format("Distribute Service"));
119 // AtomicOperationUtils.distributeService(service, true);
121 ExtentTestActions.log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile));