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;
24 import com.aventstack.extentreports.Status;
25 import fj.data.Either;
26 import org.junit.Rule;
27 import org.junit.rules.TestName;
28 import org.openecomp.sdc.be.model.ComponentInstance;
29 import org.openecomp.sdc.be.model.Resource;
30 import org.openecomp.sdc.be.model.Service;
31 import org.openecomp.sdc.be.model.User;
32 import org.openecomp.sdc.ci.tests.api.ComponentBaseTest;
33 import org.openecomp.sdc.ci.tests.api.ExtentTestActions;
34 import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders;
35 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
36 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
37 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
38 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
39 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
40 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
41 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
42 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
43 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis;
44 import org.testng.annotations.*;
51 public class Onboard extends ComponentBaseTest {
55 public static TestName name = new TestName();
58 super(name, Onboard.class.getName());
61 protected String makeDistributionValue;
62 protected String makeToscaValidationValue;
65 @Parameters({ "makeDistribution" })
67 public void beforeTestReadParams(@Optional("true") String makeDistributionReadValue) {
68 makeDistributionValue = makeDistributionReadValue;
69 logger.info("makeDistributionReadValue - > " + makeDistributionValue);
72 @Parameters({ "makeToscaValidation" })
74 public void makeToscaValidation(@Optional("false") String makeToscaValidationReadValue) {
75 makeToscaValidationValue = makeToscaValidationReadValue;
76 logger.info("makeToscaValidationReadValue - > " + makeToscaValidationValue);
80 @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
81 public void onboardVNFShotFlow(String filePath, String vnfFile) throws Exception, Throwable {
83 System.out.println("print - >" + makeDistributionValue);
84 runOnboardToDistributionFlow(filePath, vnfFile);
88 public void passTest() {
89 System.out.println("print - >" + "test Passed");
96 public void runOnboardToDistributionFlow(String filePath, String vnfFile) throws Exception {
98 ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile));
99 User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
100 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
101 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user);
102 // vendorSoftwareProductObject.setName(vendorSoftwareProductObject.getName());
104 // create VF base on VNF imported from previous step - have, resourceReqDetails object include part of resource metadata
105 // ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
106 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
107 ExtentTestActions.log(Status.INFO, String.format("Create VF %s From VSP", resourceReqDetails.getName()));
108 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails, UserRoleEnum.DESIGNER);
109 ExtentTestActions.log(Status.INFO, String.format("Certify VF"));
110 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
112 //--------------------------SERVICE--------------------------------
113 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(user);
114 ExtentTestActions.log(Status.INFO, String.format("Create Service %s", serviceReqDetails.getName()));
115 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
116 ExtentTestActions.log(Status.INFO, String.format("add VF to Service"));
117 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
118 addComponentInstanceToComponentContainer.left().value();
119 ExtentTestActions.log(Status.INFO, String.format("Certify Service"));
120 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
122 if (makeDistributionValue.equals("true")) {
123 ExtentTestActions.log(Status.INFO, String.format("Distribute Service"));
124 AtomicOperationUtils.distributeService(service, true);
127 if (makeToscaValidationValue.equals("true")) {
129 ExtentTestActions.log(Status.INFO, String.format("Start tosca validation"));
130 AtomicOperationUtils.toscaValidation(service ,vnfFile);
138 ExtentTestActions.log(Status.INFO, String.format("The onboarding %s test is passed ! ", vnfFile));