aboutsummaryrefslogtreecommitdiffstats
path: root/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsThroughAPI.java
blob: e3a7ed43b5646b25a48cf5cdbc0c30787ffe7e25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.sdc.frontend.ci.tests.execute.sanity;

import com.aventstack.extentreports.Status;
import fj.data.Either;
import org.onap.sdc.backend.ci.tests.data.providers.OnboardingDataProviders;
import org.onap.sdc.frontend.ci.tests.dataProvider.OnbordingDataProviders;
import org.onap.sdc.backend.ci.tests.datatypes.enums.CvfcTypeEnum;
import org.onap.sdc.backend.ci.tests.datatypes.http.RestResponse;
import org.onap.sdc.frontend.ci.tests.pages.GeneralPageElements;
import org.onap.sdc.frontend.ci.tests.utilities.CatalogUIUtilitis;
import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
import org.onap.sdc.frontend.ci.tests.utilities.OnboardingUiUtils;
import org.onap.sdc.backend.ci.tests.utils.rest.ResourceRestUtils;
import org.onap.sdc.frontend.ci.tests.verificator.CatalogVerificator;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.onap.sdc.backend.ci.tests.datatypes.ResourceReqDetails;
import org.onap.sdc.backend.ci.tests.datatypes.ServiceReqDetails;
import org.onap.sdc.frontend.ci.tests.datatypes.TopMenuButtonsEnum;
import org.onap.sdc.backend.ci.tests.datatypes.VendorLicenseModel;
import org.onap.sdc.backend.ci.tests.datatypes.VendorSoftwareProductObject;
import org.onap.sdc.backend.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum;
import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
import org.onap.sdc.frontend.ci.tests.pages.ResourceGeneralPage;
import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils;
import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory;
import org.onap.sdc.backend.ci.tests.utils.general.FileHandling;
import org.onap.sdc.backend.ci.tests.utils.general.OnboardingUtillViaApis;
import org.onap.sdc.backend.ci.tests.utils.general.OnboardingUtils;
import org.onap.sdc.backend.ci.tests.utils.general.VendorLicenseModelRestUtils;
import org.onap.sdc.backend.ci.tests.utils.general.VendorSoftwareProductRestUtils;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import static org.testng.AssertJUnit.assertTrue;

public class OnboardingFlowsThroughAPI extends SetupCDTest {

    protected boolean skipReport = false;
    private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);


//	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

    @Test
    public void addVesFileToVsp() throws Exception {
        String vnfFile = "vMME_Ericsson_small_v2.zip";
        String vesArtifactFile = "VES.zip";
        String filePath = FileHandling.getFilePath("VFCArtifacts");
        String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile;
        List<String> vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
        List<String> tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
        Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
        cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation);
        getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);

        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
            vendorLicenseModel, cvfcArtifacts);
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        List<ComponentInstance> componentInstances = resource.getComponentInstances();
        for (ComponentInstance componentInstance : componentInstances) {
            if (componentInstance.getDeploymentArtifacts() != null && !componentInstance.getDeploymentArtifacts().isEmpty()) {
                Map<String, ArtifactDefinition> deploymentArtifacts = componentInstance.getDeploymentArtifacts();
                for (Entry<String, ArtifactDefinition> entry : deploymentArtifacts.entrySet()) {
                    if (entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())) {
                        for (String vesArtifact : vesArtifacts) {
                            if (entry.getValue().getArtifactName().equals(vesArtifact)) {
                                tempVesArtifacts.remove(vesArtifact);
                            }
                        }
                    }
                }
            }
        }
        assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty());
    }

//	741433: Update Old VSP
//	2.	Updated VSP "JSA AUG 2017" with the attached zip from v3 to v4. Follow normal steps to update the VF
//	3.     Update the VSP "vHSS-EPC-RDM3-Lab-0830" using the attached zip. Follow the normal steps to update the VF
//	@Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
//	public void create2(String filePath, String vnfFile) throws Exception{
//		setLog(vnfFile);
//	}


    //	741509: E2E flow using old VLM
    @Test
    public void VlmReuse() throws Exception {
        List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
        List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(2, fileNamesFromFolder);
        String filePath = FileHandling.getVnfRepositoryPath();
        String vnfFile = newRandomFileNamesFromFolder.get(0);
        getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
//		setLog(vnfFile);
        getExtendTest().log(Status.INFO, "Create Vendor License");
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
        getExtendTest().log(Status.INFO, "Create Vendor Software Product: " + resourceReqDetails.getName());
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
            vendorLicenseModel, null);
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        getExtendTest().log(Status.INFO, "Create Resource: " + resourceReqDetails.getName());
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        getExtendTest().log(Status.INFO, "Certify the Resource: " + resourceReqDetails.getName());
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();

        ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
        getExtendTest().log(Status.INFO, "Create Service: " + serviceReqDetails.getName());
        org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();

        getExtendTest().log(Status.INFO, "Add VF to service");
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, "Certify the service");
        service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, "Start distributing the service");
        Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        getExtendTest().log(Status.INFO, "Service distributed");
        assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);

//		update
        vnfFile = newRandomFileNamesFromFolder.get(1);
        getExtendTest().log(Status.INFO, "Going to update VLM with new file " + vnfFile);
        VendorLicenseModelRestUtils.updateVendorLicense(vendorLicenseModel, sdncDesignerDetails, false);
        vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
            vendorLicenseModel, null);
        getExtendTest().log(Status.INFO, "Create new VSP: " + vendorSoftwareProductObject.getName());
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        getExtendTest().log(Status.INFO, "Create new resource: " + resourceReqDetails.getName());
        resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        getExtendTest().log(Status.INFO, "Certify the resource");
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();

        serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
        getExtendTest().log(Status.INFO, "Create new service: " + serviceReqDetails.getName());
        service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();

        getExtendTest().log(Status.INFO, "Add VF to service");
        addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, "Certify the service");
        service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, "Start distributing the service");
        distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        getExtendTest().log(Status.INFO, "Service distributed");
        assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
    }


    //	741607: E2E flow using old VSP
    @Test
    public void updateVfiVersionOnServiceLevel() throws Throwable {
        List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
        List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(2, fileNamesFromFolder);
        String filePath = FileHandling.getVnfRepositoryPath();
        String vnfFile = newRandomFileNamesFromFolder.get(0);
        getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(getUser());
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
            vendorLicenseModel, null);
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();

        ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
        org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();

        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
        service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);

//		update resource to v2.0
        String updateVnfFile = newRandomFileNamesFromFolder.get(1);
        getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile);
        VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, updateVnfFile);
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
        resourceReqDetails.setUniqueId(resource.getUniqueId());
        resourceReqDetails.setVersion(resource.getVersion());
        resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();

        service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
        AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);

        service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
    }


//	741608: E2E flow using old Service
//	@Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
//	public void create5(String filePath, String vnfFile) throws Exception{
//		setLog(vnfFile);
//		// 1. Create Service with old resource -> Certify this Service - > Distribute
//		// 2. Service is distributed
//		// 3. Update old Service: fetch few new resources and few old resources -> Certify this Service - > Distribute
//		// 4. Service is distributed
//	}

    //	741633: Update HEAT parameter value
    @Test()
    public void updateHeatParametersValue() throws Throwable {
        String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully";
        getExtendTest().log(Status.INFO, msg);
    }

    // temporaly disabled, until fixed
    @Test()
    public void updateVSPNameTest() throws Throwable {
        // External Defect: 430425
//		Import VSP v1.0
        List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
        List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(1, fileNamesFromFolder);
        String filePath = FileHandling.getVnfRepositoryPath();
        String vnfFile = newRandomFileNamesFromFolder.get(0);
        getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
        User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
        getExtendTest().log(Status.INFO, "Create Vendor License Model " + vendorLicenseModel.getVendorLicenseName());
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
        getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
            vendorLicenseModel, null);

//		Create VF, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
        Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
        AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();

//		Update VSP to v2.0 wih the zip from v1.0, update VSP name
        getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
        String origVspName = vendorSoftwareProductObject.getName();
        vendorSoftwareProductObject.setName("Upd" + ElementFactory.generateUUIDforSufix());
        vendorSoftwareProductObject = VendorSoftwareProductRestUtils.updateVSPWithNewVLMParameters(vendorSoftwareProductObject,
            vendorLicenseModel, sdncDesignerDetails1);
        VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);

        //Validate that VF cannot be found by the updated VSP name
        CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
        CatalogUIUtilitis.catalogSearchBox(vendorSoftwareProductObject.getName());
        int numOfElementsInFilteredCatalog = CatalogVerificator.getNumberOfElementsFromCatalogHeader();
        assertTrue(String.format("Wrong number fo elements, Expected : %s , Actual: %s", 0, numOfElementsInFilteredCatalog), numOfElementsInFilteredCatalog == 0);

        //Update VF with the new VSP version
        GeneralUIUtils.findComponentAndClick(origVspName);
        GeneralPageElements.clickCheckoutButton();
        GeneralPageElements.clickBrowseButton();
        OnboardingUiUtils.updateVSP(vendorSoftwareProductObject);


        //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)
        Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText()));

        //Validate that VF name in v1.0 is the old VF name
        GeneralPageElements.selectVersion("V1.0");
        Assert.assertTrue(origVspName.equals(ResourceGeneralPage.getNameText()));
    }

    @Test()
    public void UpdateVSPRevertToEarlierVersion() throws Throwable {
        // Test Case: 745821
//		1. Import VSP v1.0
        List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
        List<String> newRandomFileNamesFromFolder = OnboardingDataProviders.getRandomElements(1, fileNamesFromFolder);
        String filePath = FileHandling.getVnfRepositoryPath();
        String vnfFile = newRandomFileNamesFromFolder.get(0);
        getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
        User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
        getExtendTest().log(Status.INFO, "Create Vendor License Model " + vendorLicenseModel.getVendorLicenseName());
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource(); //getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
        getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails,
            vendorLicenseModel, null);
//		2. Create VF, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
        Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
        resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
//		3. Update VSP to v2.0
        getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
        VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile);
        VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
//		4. Update the VF with v2.0 of the VSP
        getExtendTest().log(Status.INFO, "Checkout VF v1.1");
        resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
        resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
        resourceReqDetails.setVersion("1.1");
        resourceReqDetails.setCsarVersion("2.0");
        getExtendTest().log(Status.INFO, "Update VF to v2.0");
        resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
        getExtendTest().log(Status.INFO, "Certify VF");
        Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
//		5. Update VSP to v3.0 wih the zip from v1.0
        getExtendTest().log(Status.INFO, "Update VSP to version 3.0");
        VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, false);
        VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
        getExtendTest().log(Status.INFO, "Checkout VF v2.1");
        resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
        resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
        resourceReqDetails.setVersion("2.1");
        resourceReqDetails.setCsarVersion("3.0");
        getExtendTest().log(Status.INFO, "Update VF to v3.0");
        ResourceRestUtils.updateResource(resourceReqDetails, sdncDesignerDetails1, resource_v1.getUniqueId());
//		6. Update VF to v3.0
        getExtendTest().log(Status.INFO, "Certify VF");
        Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
//		7. Compare versions v1.0 and v3.0 - should be the same
//      TODO: Shay add resource comparison.
//		8. Add each of the versions to service, certify - OK
        ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1);
        getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName());
        org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
        getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service");
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true);
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true);
        getExtendTest().log(Status.INFO, "Certify Service");
        service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        System.out.println("");
    }

    @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "updateList")
    public void updateVSPFlowFromOnboardToDistribution(String vnfFile1, String vnfFile2) throws Throwable {
        setLog(String.format("Create VSP from %s , update VSP with %s ", vnfFile1, vnfFile2));
//		1. Import VSP v1.0
        String filePath = org.onap.sdc.frontend.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
        User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
            .getVendorLicenseName()));
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails,
            vendorLicenseModel, null);
//		2. Create VF, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
        getExtendTest().log(Status.INFO, String.format("Certify the VF"));
//		3. Create Service add to it the certified VF and certify the Service v1.0
        ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
        Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
        getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
        service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Certify the Service"));
//		4. Distribute the Service v1.0
        Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
        assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
//		5. Update VSP to v2.0
        getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2);
        VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails1, filePath, vnfFile2);
        getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: ", vnfFile2));
        VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails1);
//		6. Update the VF with v2.0 of the VSP and certify the VF
        getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 ", resourceReqDetails.getName()));
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
        resourceReqDetails.setUniqueId(resource.getUniqueId());
        resourceReqDetails.setVersion("1.1");
        resourceReqDetails.setCsarVersion("2.0");
        getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 ", resourceReqDetails.getName(), vendorSoftwareProductObject.getName()));
        resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
        getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0"));
        Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
//		7. Update the Service with the VFi version 2.0
        getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1"));
        service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0"));
        AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
        getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0"));
        service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
//		8. Distribute the service v2.0
        distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
        assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
    }

    @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
    public void fromOnboardToDistribution(String filePath, String vnfFile) throws Throwable {
//		String vnfFile1 = "1-2016-20-visbc3vf-(VOIP)_v2.1.zip";
//		String vnfFile2 = "2-2016-20-visbc3vf-(VOIP)_v2.0.zip";
        setLog(String.format("%s", vnfFile));
//		1. Import VSP v1.0
        //String filePath = FileHandling.getVnfRepositoryPath();
        User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
            .getVendorLicenseName()));
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile));
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1,
            vendorLicenseModel);
//		VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
//		2. Create VF, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
        getExtendTest().log(Status.INFO, String.format("Certify the VF"));
//		3. Create Service add to it the certified VF and certify the Service v1.0
        ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
        Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
        getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
        service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Certify the Service"));
//		4. Distribute the Service v1.0
        Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
        assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
    }

    @Test()
    public void onboardE2EviaAPI() throws Throwable {
//			1. Import VSP v1.0
        String filePath = FileHandling.getVnfRepositoryPath();
        String vnfFile1 = "1-VF-vCSCF-StateDB-new-update_v3.0.zip";
        User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails1);
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
            .getVendorLicenseName()));
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1,
            vendorLicenseModel);
//			VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct);
//			2. Create VF, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
        getExtendTest().log(Status.INFO, String.format("Certify the VF"));
//			3. Create Service add to it the certified VF and certify the Service v1.0
        ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
        Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
        getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
        service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Certify the Service"));
//			4. Distribute the Service v1.0
        Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
        getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
        assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
    }

}