4cec05ef9c050087fbcf9d1643eff99fa03c875b
[sdc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.sdc.frontend.ci.tests.execute.sanity;
22
23 import com.aventstack.extentreports.Status;
24 import fj.data.Either;
25 import org.onap.sdc.backend.ci.tests.data.providers.OnboardingDataProviders;
26 import org.onap.sdc.frontend.ci.tests.dataProvider.OnbordingDataProviders;
27 import org.onap.sdc.backend.ci.tests.datatypes.enums.CvfcTypeEnum;
28 import org.onap.sdc.backend.ci.tests.datatypes.http.RestResponse;
29 import org.onap.sdc.frontend.ci.tests.pages.GeneralPageElements;
30 import org.onap.sdc.frontend.ci.tests.utilities.CatalogUIUtilitis;
31 import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
32 import org.onap.sdc.frontend.ci.tests.utilities.OnboardingUiUtils;
33 import org.onap.sdc.backend.ci.tests.utils.rest.ResourceRestUtils;
34 import org.onap.sdc.frontend.ci.tests.verificator.CatalogVerificator;
35 import org.openecomp.sdc.be.model.ArtifactDefinition;
36 import org.openecomp.sdc.be.model.ComponentInstance;
37 import org.openecomp.sdc.be.model.Resource;
38 import org.openecomp.sdc.be.model.Service;
39 import org.openecomp.sdc.be.model.User;
40 import org.onap.sdc.backend.ci.tests.datatypes.ResourceReqDetails;
41 import org.onap.sdc.backend.ci.tests.datatypes.ServiceReqDetails;
42 import org.onap.sdc.frontend.ci.tests.datatypes.TopMenuButtonsEnum;
43 import org.onap.sdc.backend.ci.tests.datatypes.VendorLicenseModel;
44 import org.onap.sdc.backend.ci.tests.datatypes.VendorSoftwareProductObject;
45 import org.onap.sdc.backend.ci.tests.datatypes.enums.LifeCycleStatesEnum;
46 import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum;
47 import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
48 import org.onap.sdc.frontend.ci.tests.pages.ResourceGeneralPage;
49 import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils;
50 import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory;
51 import org.onap.sdc.backend.ci.tests.utils.general.FileHandling;
52 import org.onap.sdc.backend.ci.tests.utils.general.OnboardingUtillViaApis;
53 import org.onap.sdc.backend.ci.tests.utils.general.OnboardingUtils;
54 import org.onap.sdc.backend.ci.tests.utils.general.VendorLicenseModelRestUtils;
55 import org.onap.sdc.backend.ci.tests.utils.general.VendorSoftwareProductRestUtils;
56 import org.testng.Assert;
57 import org.testng.annotations.Test;
58
59 import java.io.File;
60 import java.util.HashMap;
61 import java.util.List;
62 import java.util.Map;
63 import java.util.Map.Entry;
64
65 import static org.testng.AssertJUnit.assertTrue;
66
67 public class OnboardingFlowsThroughAPI extends SetupCDTest {
68
69     protected boolean skipReport = false;
70     private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
71
72
73 //      https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestPlan&id=6184
74
75     @Test
76     public void addVesFileToVsp() throws Exception {
77         String vnfFile = "vMME_Ericsson_small_v2.zip";
78         String vesArtifactFile = "VES.zip";
79         String filePath = FileHandling.getFilePath("VFCArtifacts");
80         String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile;
81         List<String> vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
82         List<String> tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
83         Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
84         cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation);
85         getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
86
87         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
88         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
89         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
90             vendorLicenseModel, cvfcArtifacts);
91         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
92         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
93         List<ComponentInstance> componentInstances = resource.getComponentInstances();
94         for (ComponentInstance componentInstance : componentInstances) {
95             if (componentInstance.getDeploymentArtifacts() != null && !componentInstance.getDeploymentArtifacts().isEmpty()) {
96                 Map<String, ArtifactDefinition> deploymentArtifacts = componentInstance.getDeploymentArtifacts();
97                 for (Entry<String, ArtifactDefinition> entry : deploymentArtifacts.entrySet()) {
98                     if (entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())) {
99                         for (String vesArtifact : vesArtifacts) {
100                             if (entry.getValue().getArtifactName().equals(vesArtifact)) {
101                                 tempVesArtifacts.remove(vesArtifact);
102                             }
103                         }
104                     }
105                 }
106             }
107         }
108         assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty());
109     }
110
111 //      741433: Update Old VSP
112 //      2.      Updated VSP "JSA AUG 2017" with the attached zip from v3 to v4. Follow normal steps to update the VF
113 //      3.     Update the VSP "vHSS-EPC-RDM3-Lab-0830" using the attached zip. Follow the normal steps to update the VF
114 //      @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
115 //      public void create2(String filePath, String vnfFile) throws Exception{
116 //              setLog(vnfFile);
117 //      }
118
119
120     //  741509: E2E flow using old VLM
121     @Test
122     public void VlmReuse() throws Exception {
123         List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
124         List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(2, fileNamesFromFolder);
125         String filePath = FileHandling.getVnfRepositoryPath();
126         String vnfFile = newRandomFileNamesFromFolder.get(0);
127         getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
128 //              setLog(vnfFile);
129         getExtendTest().log(Status.INFO, "Create Vendor License");
130         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
131         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
132         getExtendTest().log(Status.INFO, "Create Vendor Software Product: " + resourceReqDetails.getName());
133         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
134             vendorLicenseModel, null);
135         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
136         getExtendTest().log(Status.INFO, "Create Resource: " + resourceReqDetails.getName());
137         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
138         getExtendTest().log(Status.INFO, "Certify the Resource: " + resourceReqDetails.getName());
139         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
140
141         ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
142         getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName());
143         org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
144
145         getExtendTest().log(Status.INFO, "Add VF to service");
146         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
147         addComponentInstanceToComponentContainer.left().value();
148         getExtendTest().log(Status.INFO, "Certify the service");
149         service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
150         getExtendTest().log(Status.INFO, "Start distributing the service");
151         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
152         getExtendTest().log(Status.INFO, "Service distributed");
153         assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
154
155 //              update
156         vnfFile = newRandomFileNamesFromFolder.get(1);
157         getExtendTest().log(Status.INFO, "Going to update VLM with new file " + vnfFile);
158         VendorLicenseModelRestUtils.updateVendorLicense(vendorLicenseModel, sdncDesignerDetails, false);
159         vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
160             vendorLicenseModel, null);
161         getExtendTest().log(Status.INFO, "Create new VSP: " + vendorSoftwareProductObject.getName());
162         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
163         getExtendTest().log(Status.INFO, "Create new resource: " + resourceReqDetails.getName());
164         resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
165         getExtendTest().log(Status.INFO, "Certify the resource");
166         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
167
168         serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
169         getExtendTest().log(Status.INFO, "Create new service: " + serviceReqDetails.getName());
170         service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
171
172         getExtendTest().log(Status.INFO, "Add VF to service");
173         addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
174         addComponentInstanceToComponentContainer.left().value();
175         getExtendTest().log(Status.INFO, "Certify the service");
176         service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
177         getExtendTest().log(Status.INFO, "Start distributing the service");
178         distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
179         getExtendTest().log(Status.INFO, "Service distributed");
180         assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
181     }
182
183
184     //  741607: E2E flow using old VSP
185     @Test
186     public void updateVfiVersionOnServiceLevel() throws Throwable {
187         List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
188         List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(2, fileNamesFromFolder);
189         String filePath = FileHandling.getVnfRepositoryPath();
190         String vnfFile = newRandomFileNamesFromFolder.get(0);
191         getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
192         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
193         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
194         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
195             vendorLicenseModel, null);
196         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
197         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
198         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
199
200         ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
201         org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
202
203         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
204         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
205         service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
206         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
207         assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
208
209 //              update resource to v2.0
210         String updateVnfFile = newRandomFileNamesFromFolder.get(1);
211         getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile);
212         VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, updateVnfFile);
213         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
214         resourceReqDetails.setUniqueId(resource.getUniqueId());
215         resourceReqDetails.setVersion(resource.getVersion());
216         resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
217         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
218
219         service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
220         AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
221
222         service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
223         distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
224         assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
225     }
226
227
228 //      741608: E2E flow using old Service
229 //      @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
230 //      public void create5(String filePath, String vnfFile) throws Exception{
231 //              setLog(vnfFile);
232 //              // 1. Create Service with old resource -> Certify this Service - > Distribute
233 //              // 2. Service is distributed
234 //              // 3. Update old Service: fetch few new resources and few old resources -> Certify this Service - > Distribute
235 //              // 4. Service is distributed
236 //      }
237
238     //  741633: Update HEAT parameter value
239     @Test()
240     public void updateHeatParametersValue() throws Throwable {
241         String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully";
242         getExtendTest().log(Status.INFO, msg);
243     }
244
245     // temporaly disabled, until fixed
246     @Test()
247     public void updateVSPNameTest() throws Throwable {
248         // External Defect: 430425
249 //              Import VSP v1.0
250         List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
251         List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(1, fileNamesFromFolder);
252         String filePath = FileHandling.getVnfRepositoryPath();
253         String vnfFile = newRandomFileNamesFromFolder.get(0);
254         getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
255         User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
256         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
257         getExtendTest().log(Status.INFO, "Create Vendor License Model " + vendorLicenseModel.getVendorLicenseName());
258         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
259         getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
260         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
261             vendorLicenseModel, null);
262
263 //              Create VF, certify - v1.0 is created
264         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
265         getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
266         Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
267         getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
268         AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
269
270 //              Update VSP to v2.0 wih the zip from v1.0, update VSP name
271         getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
272         String origVspName = vendorSoftwareProductObject.getName();
273         vendorSoftwareProductObject.setName("Upd" + ElementFactory.generateUUIDforSufix());
274         vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject,
275             vendorLicenseModel, sdncDesignerDetails1);
276         VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
277
278         //Validate that VF cannot be found by the updated VSP name
279         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
280         CatalogUIUtilitis.catalogSearchBox(vendorSoftwareProductObject.getName());
281         int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader();
282         assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 0, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 0);
283
284         //Update VF with the new VSP version
285         GeneralUIUtils.findComponentAndClick(origVspName);
286         GeneralPageElements.clickCheckoutButton();
287         GeneralPageElements.clickBrowseButton();
288         OnboardingUiUtils.updateVSP(vendorSoftwareProductObject);
289
290
291         //Validate that VF name in v1.1 is not changed to new VSP name (it is required to keep the name if at least one certification was done)
292         Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText()));
293
294         //Validate that VF name in v1.0 is the old VF name
295         GeneralPageElements.selectVersion("V1.0");
296         Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText()));
297     }
298
299     @Test()
300     public void UpdateVSPRevertToEarlierVersion() throws Throwable {
301         // Test Case: 745821
302 //              1. Import VSP v1.0
303         List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
304         List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(1, fileNamesFromFolder);
305         String filePath = FileHandling.getVnfRepositoryPath();
306         String vnfFile = newRandomFileNamesFromFolder.get(0);
307         getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
308         User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
309         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
310         getExtendTest().log(Status.INFO, "Create Vendor License Model " + vendorLicenseModel.getVendorLicenseName());
311         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
312         getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
313         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
314             vendorLicenseModel, null);
315 //              2. Create VF, certify - v1.0 is created
316         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
317         getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
318         Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
319         getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
320         resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
321 //              3. Update VSP to v2.0
322         getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
323         VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile);
324         VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
325 //              4. Update the VF with v2.0 of the VSP
326         getExtendTest().log(Status.INFO, "Checkout VF v1.1");
327         resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
328         resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
329         resourceReqDetails.setVersion("1.1");
330         resourceReqDetails.setCsarVersion("2.0");
331         getExtendTest().log(Status.INFO, "Update VF to v2.0");
332         resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
333         getExtendTest().log(Status.INFO, "Certify VF");
334         Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
335 //              5. Update VSP to v3.0 wih the zip from v1.0
336         getExtendTest().log(Status.INFO, "Update VSP to version 3.0");
337         VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, false);
338         VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
339         getExtendTest().log(Status.INFO, "Checkout VF v2.1");
340         resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
341         resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
342         resourceReqDetails.setVersion("2.1");
343         resourceReqDetails.setCsarVersion("3.0");
344         getExtendTest().log(Status.INFO, "Update VF to v3.0");
345         ResourceRestUtils.updateResource(resourceReqDetails, sdncDesignerDetails1, resource_v1.getUniqueId());
346 //              6. Update VF to v3.0
347         getExtendTest().log(Status.INFO, "Certify VF");
348         Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
349 //              7. Compare versions v1.0 and v3.0 - should be the same
350 //      TODO: Shay add resource comparison.
351 //              8. Add each of the versions to service, certify - OK
352         ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1);
353         getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName());
354         org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
355         getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service");
356         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true);
357         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true);
358         getExtendTest().log(Status.INFO, "Certify Service");
359         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
360         System.out.println("");
361     }
362
363     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "updateList")
364     public void updateVSPFlowFromOnboardToDistribution(String vnfFile1, String vnfFile2) throws Throwable {
365         setLog(String.format("Create VSP from %s , update VSP with %s ", vnfFile1, vnfFile2));
366 //              1. Import VSP v1.0
367         String filePath = org.onap.sdc.frontend.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
368         User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
369         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
370         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
371             .getVendorLicenseName()));
372         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
373         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
374         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails,
375             vendorLicenseModel, null);
376 //              2. Create VF, certify - v1.0 is created
377         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
378         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
379         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
380         getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
381         getExtendTest().log(Status.INFO, String.format("Certify the VF"));
382 //              3. Create Service add to it the certified VF and certify the Service v1.0
383         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
384         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
385         getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
386         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
387         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
388         getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
389         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
390         getExtendTest().log(Status.INFO, String.format("Certify the Service"));
391 //              4. Distribute the Service v1.0
392         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
393         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
394         assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
395 //              5. Update VSP to v2.0
396         getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2);
397         VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile2);
398         getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: ", vnfFile2));
399         VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
400 //              6. Update the VF with v2.0 of the VSP and certify the VF
401         getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 ", resourceReqDetails.getName()));
402         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
403         resourceReqDetails.setUniqueId(resource.getUniqueId());
404         resourceReqDetails.setVersion("1.1");
405         resourceReqDetails.setCsarVersion("2.0");
406         getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 ", resourceReqDetails.getName(), vendorSoftwareProductObject.getName()));
407         resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
408         getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0"));
409         Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
410 //              7. Update the Service with the VFi version 2.0
411         getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1"));
412         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
413         getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0"));
414         AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
415         getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0"));
416         service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
417 //              8. Distribute the service v2.0
418         distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
419         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
420         assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
421     }
422
423     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
424     public void fromOnboardToDistribution(String filePath, String vnfFile) throws Throwable {
425 //              String vnfFile1 = "1-2016-20-visbc3vf-(VOIP)_v2.1.zip";
426 //              String vnfFile2 = "2-2016-20-visbc3vf-(VOIP)_v2.0.zip";
427         setLog(String.format("%s", vnfFile));
428 //              1. Import VSP v1.0
429         //String filePath = FileHandling.getVnfRepositoryPath();
430         User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
431         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
432         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
433             .getVendorLicenseName()));
434         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
435         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile));
436         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1,
437             vendorLicenseModel);
438 //              VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
439 //              2. Create VF, certify - v1.0 is created
440         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
441         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
442         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
443         getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
444         getExtendTest().log(Status.INFO, String.format("Certify the VF"));
445 //              3. Create Service add to it the certified VF and certify the Service v1.0
446         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
447         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
448         getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
449         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
450         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
451         getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
452         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
453         getExtendTest().log(Status.INFO, String.format("Certify the Service"));
454 //              4. Distribute the Service v1.0
455         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
456         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
457         assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
458     }
459
460     @Test()
461     public void onboardE2EviaAPI() throws Throwable {
462 //                      1. Import VSP v1.0
463         String filePath = FileHandling.getVnfRepositoryPath();
464         String vnfFile1 = "1-VF-vCSCF-StateDB-new-update_v3.0.zip";
465         User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
466         VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
467         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
468             .getVendorLicenseName()));
469         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
470         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
471         VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1,
472             vendorLicenseModel);
473 //                      VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct);
474 //                      2. Create VF, certify - v1.0 is created
475         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
476         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
477         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
478         getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
479         getExtendTest().log(Status.INFO, String.format("Certify the VF"));
480 //                      3. Create Service add to it the certified VF and certify the Service v1.0
481         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
482         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
483         getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
484         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
485         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
486         getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
487         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
488         getExtendTest().log(Status.INFO, String.format("Certify the Service"));
489 //                      4. Distribute the Service v1.0
490         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
491         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
492         assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
493     }
494
495     @Override
496     protected UserRoleEnum getRole() {
497         return UserRoleEnum.DESIGNER;
498     }
499
500 }