Fix for radio buttons
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / OnboardingFlows.java
1 package org.openecomp.sdc.ci.tests.execute.sanity;
2
3 import static org.testng.AssertJUnit.assertTrue;
4
5 import java.io.File;
6 import java.util.HashMap;
7 import java.util.List;
8 import java.util.Map;
9 import java.util.Map.Entry;
10
11 import org.openecomp.sdc.be.model.ArtifactDefinition;
12 import org.openecomp.sdc.be.model.ComponentInstance;
13 import org.openecomp.sdc.be.model.Resource;
14 import org.openecomp.sdc.be.model.Service;
15 import org.openecomp.sdc.be.model.User;
16 import org.openecomp.sdc.ci.tests.dataProviders.OnbordingDataProviders;
17 import org.openecomp.sdc.ci.tests.datatypes.AmdocsLicenseMembers;
18 import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
19 import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
20 import org.openecomp.sdc.ci.tests.datatypes.VendorSoftwareProductObject;
21 import org.openecomp.sdc.ci.tests.datatypes.enums.CvfcTypeEnum;
22 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
23 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
24 import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
25 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
26 import org.openecomp.sdc.ci.tests.utilities.OnboardingUiUtils;
27 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
28 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
29 import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
30 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtillViaApis;
31 import org.openecomp.sdc.ci.tests.utils.general.OnboardingUtils;
32 import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
33 import org.testng.annotations.Test;
34
35 import com.aventstack.extentreports.Status;
36 import com.clearspring.analytics.util.Pair;
37
38 import fj.data.Either;
39
40 public class OnboardingFlows extends SetupCDTest{
41         
42         protected boolean skipReport = false;
43         protected User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
44
45         
46 //      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
47         
48         @Test
49         public void addVesFileToVsp() throws Exception{
50                 String vnfFile = "vMME_Ericsson_small_v2.zip";
51                 String vesArtifactFile = "VES.zip";
52                 String filePath = FileHandling.getFilePath("VFCArtifacts");
53                 String vesArtifactFileLocation = filePath + File.separator + vesArtifactFile;
54                 List<String> vesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
55                 List<String> tempVesArtifacts = FileHandling.getFileNamesFromZip(vesArtifactFileLocation);
56                 Map<CvfcTypeEnum, String> cvfcArtifacts = new HashMap<>();
57                 cvfcArtifacts.put(CvfcTypeEnum.VES_EVENTS, vesArtifactFileLocation);
58                 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
59                 
60                 AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser());
61                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
62                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, cvfcArtifacts);
63                 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
64                 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
65                 List<ComponentInstance> componentInstances = resource.getComponentInstances();
66                 for(ComponentInstance componentInstance : componentInstances){
67                         if(componentInstance.getDeploymentArtifacts() !=null && !componentInstance.getDeploymentArtifacts().isEmpty()){
68                                 Map<String, ArtifactDefinition> deploymentArtifacts = componentInstance.getDeploymentArtifacts();
69                                 for(Entry<String, ArtifactDefinition> entry : deploymentArtifacts.entrySet()){
70                                         if(entry.getValue().getArtifactType().equals(CvfcTypeEnum.VES_EVENTS.getValue())){
71                                                 for(String vesArtifact : vesArtifacts){
72                                                         if(entry.getValue().getArtifactName().equals(vesArtifact)){
73                                                                 tempVesArtifacts.remove(vesArtifact);
74                                                         }
75                                                 }
76                                         }
77                                 }
78                         }
79                 }
80                 assertTrue("Not all VES_EVENTS artifact files are on the resource instance", tempVesArtifacts.isEmpty());               
81         }
82         
83 //      741433: Update Old VSP
84 //      2.      Updated VSP "JSA AUG 2017" with the attached zip from v3 to v4. Follow normal steps to update the VF
85 //      3.     Update the VSP "vHSS-EPC-RDM3-Lab-0830" using the attached zip. Follow the normal steps to update the VF
86 //      @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
87 //      public void create2(String filePath, String vnfFile) throws Exception{
88 //              setLog(vnfFile);
89 //      }
90         
91         
92 //      741509: E2E flow using old VLM
93         @Test
94         public void VlmReuse() throws Exception{
95                 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
96                 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder);
97                 String filePath = FileHandling.getVnfRepositoryPath();
98                 String vnfFile = newRandomFileNamesFromFolder.get(0);
99                 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
100 //              setLog(vnfFile);
101                 AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser());
102                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
103                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
104                 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
105                 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
106                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
107         
108                 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
109                 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
110                 
111                 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
112                 addComponentInstanceToComponentContainer.left().value();
113                 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
114                 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
115                 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
116                 
117 //              update
118                 vnfFile = newRandomFileNamesFromFolder.get(1);
119                 getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile);
120                 OnboardingUtils.updateVendorLicense(amdocsLicenseMembers, sdncDesignerDetails, "1.0");
121                 vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
122                 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
123                 resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
124                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
125         
126                 serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
127                 service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
128                 
129                 addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
130                 addComponentInstanceToComponentContainer.left().value();
131                 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
132                 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
133                 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
134                 
135                 
136         }
137         
138         
139 //      741607: E2E flow using old VSP
140         @Test
141         public void updateVfiVersionOnServiceLevel() throws Throwable{
142                 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
143                 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(2, fileNamesFromFolder);
144                 String filePath = FileHandling.getVnfRepositoryPath();
145                 String vnfFile = newRandomFileNamesFromFolder.get(0);
146                 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
147                 AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(getUser());
148                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
149                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardingUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails, amdocsLicenseMembers, null);
150                 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
151                 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
152                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
153         
154                 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails);
155                 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
156                 
157                 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
158                 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
159                 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
160                 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
161                 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
162                 
163 //              update resource to v2.0
164                 String updateVnfFile = newRandomFileNamesFromFolder.get(1);
165                 getExtendTest().log(Status.INFO, "Going to update VNF with file " + vnfFile);
166                 OnboardingUiUtils.updateVendorSoftwareProduct(vendorSoftwareProductObject.getVspId(), updateVnfFile, filePath, sdncDesignerDetails, "2.0");
167                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
168                 resourceReqDetails.setUniqueId(resource.getUniqueId());
169                 resourceReqDetails.setVersion(resource.getVersion());
170                 resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
171                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
172         
173                 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
174                 AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);         
175                 
176                 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
177                 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
178                 assertTrue("Distribution of service " + service.getName() + " failed", distributeAndValidateService);
179         }
180         
181         
182 //      741608: E2E flow using old Service
183 //      @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "randomVNF_List")
184 //      public void create5(String filePath, String vnfFile) throws Exception{
185 //              setLog(vnfFile);
186 //              // 1. Create Service with old resource -> Certify this Service - > Distribute
187 //              // 2. Service is distributed
188 //              // 3. Update old Service: fetch few new resources and few old resources -> Certify this Service - > Distribute
189 //              // 4. Service is distributed
190 //      }
191         
192 //      741633: Update HEAT parameter value
193         @Test()
194         public void updateHeatParametersValue() throws Throwable{
195                 String msg = "VfArtifacts-->checkDefaultCreatedEnvArtifactsAfterVspUpdate tests with data provider index 4(last one) check it fully";
196                 getExtendTest().log(Status.INFO, msg);
197         }
198
199         @Test()
200         public void UpdateVSPRevertToEarlierVersion() throws Throwable
201         {
202                 // Test Case: 745821
203 //              1. Import VSP v1.0
204                 List<String> fileNamesFromFolder = OnboardingUtils.getVnfNamesFileListExcludeToscaParserFailure();
205                 List<String> newRandomFileNamesFromFolder = OnbordingDataProviders.getRandomElements(1, fileNamesFromFolder);
206                 String filePath = FileHandling.getVnfRepositoryPath();
207                 String vnfFile = newRandomFileNamesFromFolder.get(0);
208                 getExtendTest().log(Status.INFO, "Going to upload VNF " + vnfFile);
209                 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
210                 AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUiUtils.createVendorLicense(sdncDesignerDetails1);
211                 getExtendTest().log(Status.INFO, "Create Vendor License Model " + amdocsLicenseMembers.getVendorLicenseName());
212                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();//getResourceReqDetails(ComponentConfigurationTypeEnum.DEFAULT);
213                 getExtendTest().log(Status.INFO, "Create Vendor Software Product " + resourceReqDetails.getName());
214                 Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
215                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
216 //              2. Create VF, certify - v1.0 is created
217                 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
218                 getExtendTest().log(Status.INFO, "Create VF " + resourceReqDetails.getName());
219                 Resource resource_v1 = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
220                 getExtendTest().log(Status.INFO, "Certify VF " + resourceReqDetails.getName());
221                 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
222 //              3. Update VSP to v2.0
223                 getExtendTest().log(Status.INFO, "Update VSP to version 2.0");
224                 OnboardingUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, "2.0", sdncDesignerDetails1, filePath, vnfFile);
225                 OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(),sdncDesignerDetails1);
226 //              4. Update the VF with v2.0 of the VSP
227                 getExtendTest().log(Status.INFO, "Checkout VF v1.1");
228                 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
229                 resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
230                 resourceReqDetails.setVersion("1.1");
231                 resourceReqDetails.setCsarVersion("2.0");
232                 getExtendTest().log(Status.INFO, "Update VF to v2.0");
233                 resource_v1 = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
234                 getExtendTest().log(Status.INFO, "Certify VF");
235                 Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
236 //              5. Update VSP to v3.0 wih the zip from v1.0
237                 getExtendTest().log(Status.INFO, "Update VSP to version 3.0");
238                 OnboardingUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, "3.0", sdncDesignerDetails1);
239                 OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(),sdncDesignerDetails1);
240                 getExtendTest().log(Status.INFO, "Checkout VF v2.1");
241                 resource_v1 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
242                 resourceReqDetails.setUniqueId(resource_v1.getUniqueId());
243                 resourceReqDetails.setVersion("2.1");
244                 resourceReqDetails.setCsarVersion("3.0");
245                 getExtendTest().log(Status.INFO, "Update VF to v3.0");
246                 ResourceRestUtils.updateResource(resourceReqDetails,sdncDesignerDetails1,resource_v1.getUniqueId());
247 //              6. Update VF to v3.0
248                 getExtendTest().log(Status.INFO, "Certify VF");
249                 Resource resource_v3 = (Resource) AtomicOperationUtils.changeComponentState(resource_v1, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
250 //              7. Compare versions v1.0 and v3.0 - should be the same
251 //      TODO: Shay add resource comparison.
252 //              8. Add each of the versions to service, certify - OK
253                 ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(sdncDesignerDetails1);
254                 getExtendTest().log(Status.INFO, "Create Service " + serviceReqDetails.getName() );
255                 org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
256                 getExtendTest().log(Status.INFO, "Add vf's v1 & v2 to service");
257                 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v1, service, UserRoleEnum.DESIGNER, true);
258                 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer1 = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource_v3, service, UserRoleEnum.DESIGNER, true);
259                 getExtendTest().log(Status.INFO, "Certify Service");
260                 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
261                 System.out.println("");
262         }
263
264         @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "updateList")
265         public void distributeServiceAndUpgradeWithNewHeatFile(String vnfFile1, String vnfFile2) throws Throwable
266         {
267                 setLog(String.format("Update VSP Test: Create VF from %s add it to service, distribute than upgrade the VF with file %s and update the service and distribute", vnfFile1, vnfFile2));
268 //              1. Import VSP v1.0
269                 String filePath = org.openecomp.sdc.ci.tests.utilities.FileHandling.getUpdateVSPVnfRepositoryPath();
270                 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
271                 AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1);
272                 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
273                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
274                 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
275                 Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
276                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct);
277 //              2. Create VF, certify - v1.0 is created
278                 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
279                 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
280                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
281                 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
282                 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
283 //              3. Create Service add to it the certified VF and certify the Service v1.0
284                 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
285                 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
286                 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
287                 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
288                 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
289                 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
290                 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
291                 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
292 //              5. Distribute the Service v1.0
293                 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
294                 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
295                 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
296 //              6. Update VSP to v2.0
297                 getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2);
298                 OnboardingUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, "2.0", sdncDesignerDetails1, filePath, vnfFile2);
299                 getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: " ,vnfFile2));
300                 OnboardingUtils.validateVspExist(vendorSoftwareProductObject.getVspId(),vendorSoftwareProductObject.getVersion(),sdncDesignerDetails1);
301 //              7. Update the VF with v2.0 of the VSP and certify the VF
302                 getExtendTest().log(Status.INFO, String.format("Checkout the VF %s v1.1 " ,resourceReqDetails.getName()));
303                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
304                 resourceReqDetails.setUniqueId(resource.getUniqueId());
305                 resourceReqDetails.setVersion("1.1");
306                 resourceReqDetails.setCsarVersion("2.0");
307                 getExtendTest().log(Status.INFO, String.format("Upgrade the VF %s v1.1 with the new VSP %s v2.0 " ,resourceReqDetails.getName(),vendorSoftwareProductObject.getName()));
308                 resource = AtomicOperationUtils.updateResource(resourceReqDetails, sdncDesignerDetails, true).left().value();
309                 getExtendTest().log(Status.INFO, String.format("Certify the VF to v2.0"));
310                 Resource resource_v2 = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
311 //              8. Update the Service with the VFi version 2.0
312                 getExtendTest().log(Status.INFO, String.format("Checkout the Service v1.1"));
313                 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
314                 getExtendTest().log(Status.INFO, String.format("Change the instance of the VF in the service to VFi v2.0"));
315                 AtomicOperationUtils.changeComponentInstanceVersion(service, componentInstance, resource, UserRoleEnum.DESIGNER, true);
316                 getExtendTest().log(Status.INFO, String.format("Certify the Service to v2.0"));
317                 service = (org.openecomp.sdc.be.model.Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
318 //              9. Distribute the service v2.0
319                 distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
320                 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
321                 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
322         }
323
324         @Test(dataProviderClass = org.openecomp.sdc.ci.tests.dataProvider.OnbordingDataProviders.class, dataProvider = "VNF_List")
325         public void distributeServiceFromHeatFile(String filePath, String vnfFile) throws Throwable
326         {
327 //              String vnfFile1 = "1-2016-20-visbc3vf-(VOIP)_v2.1.zip";
328 //              String vnfFile2 = "2-2016-20-visbc3vf-(VOIP)_v2.0.zip";
329                 setLog(String.format("Distribute Service Test: Create VF from %s add it to service than distribute", vnfFile));
330 //              1. Import VSP v1.0
331                 //String filePath = FileHandling.getVnfRepositoryPath();
332                 User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
333                 AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1);
334                 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
335                 ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
336                 getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile));
337                 Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
338                 VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile, createVendorSoftwareProduct);
339 //              2. Create VF, certify - v1.0 is created
340                 resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
341                 Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
342                 resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
343                 getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
344                 getExtendTest().log(Status.INFO, String.format("Certify the VF"));
345 //              3. Create Service add to it the certified VF and certify the Service v1.0
346                 ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
347                 Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
348                 getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
349                 Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
350                 ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
351                 getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
352                 service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
353                 getExtendTest().log(Status.INFO, String.format("Certify the Service"));
354 //              5. Distribute the Service v1.0
355                 Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
356                 getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
357                 assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
358         }
359           
360           @Test()
361           public void onboardE2EviaAPI() throws Throwable
362                 {
363 //                      1. Import VSP v1.0
364                         String filePath = FileHandling.getVnfRepositoryPath();
365                         String vnfFile1 = "HeatCandidate_2017-09-20_13-37_70Name_2017-491-4vshaken-HTTP-CM-vf-v1.0-(VOIP)_10202017.zip";
366                         User sdncDesignerDetails1 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
367                         AmdocsLicenseMembers amdocsLicenseMembers = OnboardingUtils.createVendorLicense(sdncDesignerDetails1);
368                         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", amdocsLicenseMembers.getVendorLicenseName()));
369                         ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
370                         getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
371                         Pair<String, Map<String, String>> createVendorSoftwareProduct = OnboardingUtils.createVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, sdncDesignerDetails1, amdocsLicenseMembers);
372                         VendorSoftwareProductObject vendorSoftwareProductObject = OnboardViaApis.fillVendorSoftwareProductObjectWithMetaData(vnfFile1, createVendorSoftwareProduct);
373 //                      2. Create VF, certify - v1.0 is created
374                         resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
375                         Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
376                         resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
377                         getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
378                         getExtendTest().log(Status.INFO, String.format("Certify the VF"));
379 //                      3. Create Service add to it the certified VF and certify the Service v1.0
380                         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
381                         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
382                         getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
383                         Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
384                         ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
385                         getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
386                         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
387                         getExtendTest().log(Status.INFO, String.format("Certify the Service"));
388 //                      5. Distribute the Service v1.0
389                         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
390                         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
391                         assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
392                         }
393         
394         @Override
395         protected UserRoleEnum getRole() {
396                 return UserRoleEnum.DESIGNER;
397         }
398         
399         
400 }