Added oparent to sdc main
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / execute / sanity / PortMirroring.java
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.openecomp.sdc.ci.tests.execute.sanity;
22
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
25 import org.openecomp.sdc.be.model.Resource;
26 import org.openecomp.sdc.be.model.Service;
27 import org.openecomp.sdc.ci.tests.datatypes.*;
28 import org.openecomp.sdc.ci.tests.datatypes.enums.LifeCycleStatesEnum;
29 import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
30 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
31 import org.openecomp.sdc.ci.tests.pages.CompositionPage;
32 import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
33 import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage;
34 import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis;
35 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
36 import org.openecomp.sdc.ci.tests.utilities.HomeUtils;
37 import org.openecomp.sdc.ci.tests.utilities.PortMirroringUtils;
38 import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
39 import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
40 import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
41 import org.openecomp.sdc.ci.tests.verificator.PortMirroringVerificator;
42 import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
43 import org.testng.AssertJUnit;
44 import org.testng.annotations.Test;
45
46 import java.io.File;
47
48 import static org.testng.Assert.assertTrue;
49
50 public class PortMirroring extends SetupCDTest {
51
52     @Test
53     public void createPortMirroringConfigurationServiceProxy() throws Throwable {
54         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
55         ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails();
56         CanvasManager canvasManager = portMirrioringConfigurationObject.getCanvasManager();
57         CanvasElement serviceElementVmmeSourceName = portMirrioringConfigurationObject.getServiceElementVmmeSourceName();
58         String vmmeSourceName = portMirrioringConfigurationObject.getVmmeSourceName();
59         CanvasElement serviceElementVprobeCollector = portMirrioringConfigurationObject.getServiceElementVprobeCollector();
60         String vprobeSourceName = portMirrioringConfigurationObject.getVprobeSourceName();
61
62         serviceReqDetails.setVersion("0.1");
63         getExtendTest().log(Status.INFO, "Validating links between elements were created");
64         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2);
65
66         canvasManager.clickOnCanvaElement(serviceElementVmmeSourceName);
67         PortMirroringVerificator.validatingProxyServiceNameAndType(vmmeSourceName, "0");
68
69         canvasManager.clickOnCanvaElement(serviceElementVprobeCollector);
70         PortMirroringVerificator.validatingProxyServiceNameAndType(vprobeSourceName, "0");
71     }
72
73     @Test
74     public void distributePortMirroringConfigurationServiceProxy() throws Throwable {
75         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
76         ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails();
77         Service service = portMirrioringConfigurationObject.getService();
78
79         serviceReqDetails.setVersion("0.1");
80         getExtendTest().log(Status.INFO, "Validating links between elements were created");
81         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2);
82
83         getExtendTest().log(Status.INFO, String.format("Going to certify the Service"));
84         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
85         getExtendTest().log(Status.INFO, String.format("Service is certified"));
86         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
87         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
88         AssertJUnit.assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
89     }
90
91     @Test
92     public void createPortMirroringByPolicyServiceProxy() throws Throwable {            
93         //Using API onboard and certify 2 zip files Source: vmmme and Collector: Vprobe
94         String filePath = FileHandling.getPortMirroringRepositoryPath();
95         ServiceContainer serviceContainerVmme_Source = PortMirroringUtils.createServiceFromHeatFile(filePath, "2016-227_vmme_vmme_30_1610_e2e.zip");
96
97         // create service with required pnf's and certify it
98         Resource resourceCisco = PortMirroringUtils.GeneratePNFAndUpdateInput(PortMirroringEnum.CISCO_VENDOR_NAME.getValue(), PortMirroringEnum.CISCO_VENDOR_MODEL_NUMBER.getValue(), getUser());
99         Resource resourceAPCON1 = PortMirroringUtils.GeneratePNFAndUpdateInput(PortMirroringEnum.APCON1_VENDOR_NAME.getValue(), PortMirroringEnum.APCON1_VENDOR_MODEL_NUMBER.getValue(), getUser());
100         Resource resourceAPCON2 = PortMirroringUtils.GeneratePNFAndUpdateInput(PortMirroringEnum.APCON2_VENDOR_NAME.getValue(), PortMirroringEnum.APCON2_VENDOR_MODEL_NUMBER.getValue(), getUser());
101
102         ServiceReqDetails serviceReqDetailsCollector = ElementFactory.getDefaultService();
103         serviceReqDetailsCollector.setServiceType(PortMirroringEnum.SERVICE_TYPE.getValue());
104         getExtendTest().log(Status.INFO, String.format("Creating collector service %s (PNF container)", serviceReqDetailsCollector.getName()));
105         Service serviceCollector = AtomicOperationUtils.createCustomService(serviceReqDetailsCollector, UserRoleEnum.DESIGNER, true).left().value();
106
107         getExtendTest().log(Status.INFO, String.format("Adding pnf's: %s,%s,%s to service %s", resourceCisco.getName(), resourceAPCON1.getName(), resourceAPCON2.getName(), serviceCollector.getName()));
108
109         AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceCisco, serviceCollector, UserRoleEnum.DESIGNER, true, "80", "80");
110         AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceAPCON1, serviceCollector, UserRoleEnum.DESIGNER, true, "80", "200");
111         AtomicOperationUtils.addComponentInstanceToComponentContainer(resourceAPCON2, serviceCollector, UserRoleEnum.DESIGNER, true, "200", "200");
112
113         serviceCollector = (Service) AtomicOperationUtils.changeComponentState(serviceCollector, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
114
115         // create container service
116         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
117         getExtendTest().log(Status.INFO, String.format("Creating container service %s", serviceReqDetails.getName()));
118         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
119
120         String vmmeSourceName = serviceContainerVmme_Source.getService().getName();
121         String collectorServiceName = serviceCollector.getName();
122
123         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
124         GeneralUIUtils.findComponentAndClick(service.getName());
125
126         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
127         CanvasManager canvasManager = CanvasManager.getCanvasManager();
128
129         CompositionPage.searchForElement(vmmeSourceName);
130         CanvasElement serviceElementVmmeSource = canvasManager.createElementOnCanvas(vmmeSourceName);
131
132         CompositionPage.searchForElement(collectorServiceName);
133         CanvasElement serviceElementCollectorService = canvasManager.createElementOnCanvas(collectorServiceName);
134
135         CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
136         CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
137
138         ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("",
139                 "",
140                 PortMirroringEnum.PM_REQ_TYPE.getValue(),
141                 PortMirroringEnum.PMCP_SOURCE_CAP.getValue());
142
143         canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSource,
144                 portMirroringConfigurationByPolicyElement,
145                 connectionWizardPopUpObjectVMME);
146
147         serviceReqDetails.setVersion("0.1");
148         getExtendTest().log(Status.INFO, "Validating link between elements was created");
149         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 1);
150
151         canvasManager.clickOnCanvaElement(serviceElementVmmeSource);
152         PortMirroringVerificator.validatingProxyServiceNameAndType(vmmeSourceName, "0");
153
154         getExtendTest().log(Status.INFO, "Adding properties to PMCP");
155         
156         if(true){
157 //                      throw new SkipException("Open bug 373762, can't update properties on CP or VFC instance  on Composition screen");
158                 SetupCDTest.getExtendTest().log(Status.INFO, "Open bug 373762, can't update properties on CP or VFC instance  on Composition screen");
159                 }
160
161         canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement);
162         CompositionPage.showPropertiesAndAttributesTab();
163         CompositionPage.setSingleProperty(DataTestIdEnum.PortMirroring.COLLECTOR_NODE.getValue(), PortMirroringUtils.createProxyInstanceServiceName(collectorServiceName, "1"));
164         CompositionPage.setSingleProperty(DataTestIdEnum.PortMirroring.EQUIP_MODEL.getValue(), PortMirroringEnum.CISCO_VENDOR_MODEL_NUMBER.getValue());
165         CompositionPage.setSingleProperty(DataTestIdEnum.PortMirroring.EQUIP_VENDOR.getValue(), PortMirroringEnum.CISCO_VENDOR_NAME.getValue());
166
167         // Distribute the Port Mirroning Configuration By Policy
168         getExtendTest().log(Status.INFO, String.format("Going to certify the Service"));
169         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
170         getExtendTest().log(Status.INFO, String.format("Service is certified"));
171         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
172         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
173         AssertJUnit.assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
174     }
175
176     @Test
177     public void deletePMCPLink() throws Throwable {
178         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
179         getExtendTest().log(Status.INFO, String.format("Creating container service %s", serviceReqDetails.getName()));
180         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
181
182         String filePath = FileHandling.getPortMirroringRepositoryPath();
183         ServiceContainer serviceContainerVmme_Source = PortMirroringUtils.createServiceFromHeatFile(filePath, "2016-227_vmme_vmme_30_1610_e2e.zip");
184
185         String vmmeSourceName = serviceContainerVmme_Source.getService().getName();
186
187         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
188         GeneralUIUtils.findComponentAndClick(service.getName());
189
190         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
191         CanvasManager canvasManager = CanvasManager.getCanvasManager();
192
193         CompositionPage.searchForElement(vmmeSourceName);
194         CanvasElement serviceElementVmmeSource = canvasManager.createElementOnCanvas(vmmeSourceName);
195
196         CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
197         CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
198
199         ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("",
200                 "",
201                 PortMirroringEnum.PM_REQ_TYPE.getValue(),
202                 PortMirroringEnum.PMCP_SOURCE_CAP.getValue());
203
204         canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSource,
205                 portMirroringConfigurationByPolicyElement,
206                 connectionWizardPopUpObjectVMME);
207
208         serviceReqDetails.setVersion("0.1");
209         getExtendTest().log(Status.INFO, "Validating link between elements was created");
210         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 1);
211
212         canvasManager.openLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement);
213         canvasManager.closeLinkPopupReqsCapsConnection();
214         canvasManager.deleteLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement);
215
216         getExtendTest().log(Status.INFO, "Validating link deleted");
217         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 0);
218     }
219
220     @Test
221     public void verifyPMCNotExistInVF() throws Exception {
222         Resource resource = PortMirroringUtils.getResourceByType(ResourceTypeEnum.VF, "VF", "VendorModel");
223
224         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
225
226         GeneralUIUtils.findComponentAndClick(resource.getName());
227         ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
228
229         CompositionPage.searchForElement(PortMirroringEnum.PMC_ELEMENT_IN_PALLETE.getValue());
230
231         getExtendTest().log(Status.INFO, "Verify that Port Mirroring Configuration and Configuration by Policy doesn't exist for VF ");
232         boolean isPMCFound = GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.PortMirroring.PMC_NAME_IN_PALLETE.getValue());
233         boolean isPMCPFound = GeneralUIUtils.isElementInvisibleByTestId(DataTestIdEnum.PortMirroring.PMCP_NAME_IN_PALLETE.getValue());
234
235         assertTrue(isPMCFound);
236         assertTrue(isPMCPFound);
237     }
238
239     @Test
240     public void verifyPMCPTabs() throws Exception {
241
242         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
243         getExtendTest().log(Status.INFO, String.format("Creating container service %s", serviceReqDetails.getName()));
244         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
245
246         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
247         GeneralUIUtils.findComponentAndClick(service.getName());
248
249         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
250         CanvasManager canvasManager = CanvasManager.getCanvasManager();
251
252         CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
253         CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
254         canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement);
255
256         PortMirroringVerificator.validateGeneralInfo();
257         PortMirroringVerificator.validateReqsAndCapsTabExist();
258     }
259
260
261     @Test
262     public void editPMCPName() throws Exception {
263
264         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
265         getExtendTest().log(Status.INFO, String.format("Creating container service %s", serviceReqDetails.getName()));
266         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
267
268         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
269         GeneralUIUtils.findComponentAndClick(service.getName());
270
271         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
272         CanvasManager canvasManager = CanvasManager.getCanvasManager();
273
274         CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
275         CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
276
277         canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement);
278
279         getExtendTest().log(Status.INFO, "Edit PMCP Name");
280 //        GeneralUIUtils.clickOnElementById(DataTestIdEnum.CompositionRightPanel.EDIT_PENCIL.getValue());
281 //        GeneralUIUtils.setTextInElementByDataTestID(DataTestIdEnum.CompositionRightPanel.INSTANCE_NAME_TEXTBOX.getValue(), PortMirroringEnum.PMCP_NEWNAME.getValue());
282 //        GeneralUIUtils.clickOnElementByTestId("OK");
283         canvasManager.updateElementNameInCanvas(portMirroringConfigurationByPolicyElement,PortMirroringEnum.PMCP_NEWNAME.getValue());
284
285         PortMirroringVerificator.validateElementName(PortMirroringEnum.PMCP_NEWNAME.getValue());
286     }
287
288
289     @Test
290     public void deletePMCP() throws Exception {
291
292         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
293         getExtendTest().log(Status.INFO, String.format("Creating container service %s", serviceReqDetails.getName()));
294         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
295
296         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
297         GeneralUIUtils.findComponentAndClick(service.getName());
298
299         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
300         CanvasManager canvasManager = CanvasManager.getCanvasManager();
301
302         CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
303         CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
304
305         canvasManager.clickOnCanvaElement(portMirroringConfigurationByPolicyElement);
306
307         getExtendTest().log(Status.INFO, String.format("Delete element %s", portMirroringConfigurationByPolicyElement.getElementType()));
308 //        GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionRightPanel.DELETE_ITEM.getValue());
309 //        GeneralUIUtils.clickOnElementByTestId("OK");
310         canvasManager.deleteElementFromCanvas(portMirroringConfigurationByPolicyElement);
311
312         PortMirroringVerificator.validateElementName(service.getName());
313     }
314
315     @Test
316     public void createPortMirroringConfigurationMulipleInstances() throws Throwable {
317         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
318         ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails();
319         CanvasElement serviceElementVmmeSourceName = portMirrioringConfigurationObject.getServiceElementVmmeSourceName();
320
321         serviceReqDetails.setVersion("0.1");
322         getExtendTest().log(Status.INFO, "Validating 2 links between elements were created");
323         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2);
324
325         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click();
326         GeneralUIUtils.ultimateWait();
327         GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName());
328
329         getExtendTest().log(Status.INFO, "Adding second PMC to composition");
330         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
331
332         CanvasManager canvasManager = CanvasManager.getCanvasManager();
333         CompositionPage.searchForElement(PortMirroringEnum.PMC_ELEMENT_IN_PALLETE.getValue());
334         CanvasElement portMirroringConfigurationElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMC_ELEMENT_IN_PALLETE.getValue());
335
336 //        ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("", "",
337 //                PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMC1_SOURCE_CAP.getValue());
338
339         ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("", "",
340               PortMirroringEnum.PM_REQ_TYPE.getValue(), PortMirroringEnum.PMC_SOURCE_CAP.getValue());
341
342         getExtendTest().log(Status.INFO, "Connect VMME to PMC again");
343         canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName,portMirroringConfigurationElement,
344                connectionWizardPopUpObjectVMME);
345
346         getExtendTest().log(Status.INFO, "Connect VMME to PMC again");
347         canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationElement,
348                connectionWizardPopUpObjectVMME);
349
350         getExtendTest().log(Status.INFO, "Validating 4 links between elements exist");
351         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 4);
352
353         getExtendTest().log(Status.INFO, "Adding second PMCP to composition");
354         CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
355         CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
356
357         ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME_PMCP = new ConnectionWizardPopUpObject("",
358                 "",
359                 PortMirroringEnum.PM_REQ_TYPE.getValue(),
360                 PortMirroringEnum.PMCP_SOURCE_CAP.getValue());
361
362         getExtendTest().log(Status.INFO, "Connect VMME to PMCP again");
363         canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationByPolicyElement,
364                connectionWizardPopUpObjectVMME_PMCP);
365
366         getExtendTest().log(Status.INFO, "Connect VMME to PMCP again");
367         canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSourceName, portMirroringConfigurationByPolicyElement,
368                 connectionWizardPopUpObjectVMME_PMCP);
369
370         serviceReqDetails.setVersion("0.1");
371         getExtendTest().log(Status.INFO, "Validating 6 links between elements exist");
372         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 6);
373     }
374
375     @Test
376     public void downloadArtifactFromPMCService() throws Throwable {
377         //Scenario of bug 362271
378         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
379         ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails();
380
381         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click();
382         GeneralUIUtils.ultimateWait();
383         GeneralUIUtils.findComponentAndClick(serviceReqDetails.getName());
384
385         ServiceGeneralPage.getLeftMenu().moveToToscaArtifactsScreen();
386
387         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ToscaArtifactsScreenEnum.TOSCA_MODEL.getValue());
388         File latestFilefromDir = org.openecomp.sdc.ci.tests.utilities.FileHandling.getLastModifiedFileNameFromDir();
389         String actualToscaModelFilename = latestFilefromDir.getName();
390
391         GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.ToscaArtifactsScreenEnum.TOSCA_TEMPLATE.getValue());
392         latestFilefromDir = org.openecomp.sdc.ci.tests.utilities.FileHandling.getLastModifiedFileNameFromDir();
393         String actualToscaTemplateFilename = latestFilefromDir.getName();
394
395         String expectedToscaModelFilename = String.format("service-%s-csar.csar", serviceReqDetails.getName());
396         String expectedToscaTemplateFilename = String.format("service-%s-template.yml", serviceReqDetails.getName());
397
398         getExtendTest().log(Status.INFO, "Validating tosca artifact downloaded successfully");
399         AssertJUnit.assertTrue(actualToscaModelFilename.equalsIgnoreCase(expectedToscaModelFilename));
400         AssertJUnit.assertTrue(actualToscaTemplateFilename.equalsIgnoreCase(expectedToscaTemplateFilename));
401     }
402
403     @Test
404     public void checkoutMirroringConfigurationServiceProxyAndDeletePMC() throws Throwable {
405         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
406         ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails();
407         Service service = portMirrioringConfigurationObject.getService();
408         CanvasElement portMirroringConfigurationElement = portMirrioringConfigurationObject.getPortMirroringConfigurationElement();
409
410         serviceReqDetails.setVersion("0.1");
411         getExtendTest().log(Status.INFO, "Validating links between elements were created");
412         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2);
413
414         getExtendTest().log(Status.INFO, String.format("Going to certify the Service"));
415         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
416
417         getExtendTest().log(Status.INFO, String.format("Checkout Port Mirroring Service"));
418         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
419
420         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click();
421         GeneralUIUtils.ultimateWait();
422         HomeUtils.findComponentAndClickByVersion(service.getName(), "1.1");
423
424         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
425         CanvasManager canvasManager = CanvasManager.getCanvasManager();
426         GeneralUIUtils.ultimateWait();
427 //        canvasManager.clickOnCanvasPosition(portMirroringConfigurationElement.getLocation().getLeft(), portMirroringConfigurationElement.getLocation().getRight());
428         canvasManager.clickOnCanvaElement(portMirroringConfigurationElement);
429         getExtendTest().log(Status.INFO, String.format("Delete element %s", portMirroringConfigurationElement.getElementType()));
430 //        GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.CompositionRightPanel.DELETE_ITEM.getValue());
431 //        GeneralUIUtils.clickOnElementByTestId("OK");
432         canvasManager.deleteElementFromCanvas(portMirroringConfigurationElement);
433
434         PortMirroringVerificator.validateElementName(service.getName());
435         getExtendTest().log(Status.INFO, "Validating 0 links after delete the port mirroring element");
436         serviceReqDetails.setVersion("1.1");
437         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 0);
438
439         getExtendTest().log(Status.INFO, String.format("Going to certify the Service"));
440         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
441
442         getExtendTest().log(Status.INFO, String.format("Service is certified"));
443         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
444         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
445         AssertJUnit.assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
446     }
447
448     @Test
449     public void updatePortMirroringServiceInstance() throws Throwable {
450
451         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
452         Service service = portMirrioringConfigurationObject.getService();
453         CanvasElement vmmeCanvasElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName();
454
455         getExtendTest().log(Status.INFO, String.format("Going to certify the Service"));
456         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
457
458         Service serviceContainerVmme_Source = portMirrioringConfigurationObject.getServiceContainerVmme_Source();
459         getExtendTest().log(Status.INFO, String.format("Checkout the vmme Service"));
460         serviceContainerVmme_Source = (Service) AtomicOperationUtils.changeComponentState(serviceContainerVmme_Source, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
461         getExtendTest().log(Status.INFO, String.format("Going to certify the vmme Service"));
462         serviceContainerVmme_Source = (Service) AtomicOperationUtils.changeComponentState(serviceContainerVmme_Source, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
463
464         getExtendTest().log(Status.INFO, String.format("Checkout Port Mirroring Service"));
465         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
466
467         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click();
468         GeneralUIUtils.ultimateWait();
469         HomeUtils.findComponentAndClickByVersion(service.getName(), "1.1");
470
471         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
472         CanvasManager canvasManager = CanvasManager.getCanvasManager();
473
474         getExtendTest().log(Status.INFO, String.format("Change vmme source %s instance to version 2.0", serviceContainerVmme_Source.getName()));
475         CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0",false);
476
477         getExtendTest().log(Status.INFO, String.format("Going to certify the Service"));
478         service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
479
480         getExtendTest().log(Status.INFO, String.format("Service is certified"));
481         Boolean distributeAndValidateService = AtomicOperationUtils.distributeAndValidateService(service);
482         getExtendTest().log(Status.INFO, String.format("Distribute and validate the Service"));
483         AssertJUnit.assertTrue("Distribution status is " + distributeAndValidateService, distributeAndValidateService);
484     }
485
486     @Test
487     public void updateLinkPropertiesPortMirroringService() throws Throwable {
488
489         ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
490         getExtendTest().log(Status.INFO, String.format("Creating container service %s", serviceReqDetails.getName()));
491         Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
492
493         String filePath = FileHandling.getPortMirroringRepositoryPath();
494         ServiceContainer serviceContainerVmme_Source = PortMirroringUtils.createServiceFromHeatFile(filePath, "2016-227_vmme_vmme_30_1610_e2e.zip");
495
496         String vmmeSourceName = serviceContainerVmme_Source.getService().getName();
497
498         CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
499         GeneralUIUtils.findComponentAndClick(service.getName());
500
501         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
502         CanvasManager canvasManager = CanvasManager.getCanvasManager();
503
504         CompositionPage.searchForElement(vmmeSourceName);
505         CanvasElement serviceElementVmmeSource = canvasManager.createElementOnCanvas(vmmeSourceName);
506
507         CompositionPage.searchForElement(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
508         CanvasElement portMirroringConfigurationByPolicyElement = canvasManager.createElementOnCanvas(PortMirroringEnum.PMCP_ELEMENT_IN_PALLETE.getValue());
509
510         ConnectionWizardPopUpObject connectionWizardPopUpObjectVMME = new ConnectionWizardPopUpObject("",
511                 "",
512                 PortMirroringEnum.PM_REQ_TYPE.getValue(),
513                 PortMirroringEnum.PMCP_SOURCE_CAP.getValue());
514
515         canvasManager.linkElementsAndSelectCapReqTypeAndCapReqName(serviceElementVmmeSource,
516                 portMirroringConfigurationByPolicyElement,
517                 connectionWizardPopUpObjectVMME);
518
519         serviceReqDetails.setVersion("0.1");
520         getExtendTest().log(Status.INFO, "Validating link between elements was created");
521         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 1);
522
523         canvasManager.openLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement);
524
525         getExtendTest().log(Status.INFO, "Fill link properties with data");
526         GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NETWORK_ROLE_XPATH.getValue(),PortMirroringEnum.NETWORK_ROLE_VALUE.getValue());
527         GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NFC_TYPE_XPATH.getValue(),PortMirroringEnum.NFC_TYPE_VALUE.getValue());
528         GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.PPS_CAPACITY_XPATH.getValue(),PortMirroringEnum.PPS_CAPACITY_VALUE.getValue());
529         GeneralUIUtils.setTextInElementByXpath(PortMirroringEnum.NF_TYPE_XPATH.getValue(),PortMirroringEnum.NF_TYPE_VALUE.getValue());
530         GeneralUIUtils.ultimateWait();
531         
532 //        if(true){
533 //                      throw new SkipException("Open bug 373765, Can't  update link property on Port Mirroring connection");
534 //              }
535
536         canvasManager.clickSaveOnLinkPopup();
537         Thread.sleep(3000); //Temp solution. Don't remove.
538         canvasManager.openLinkPopupReqsCapsConnection(serviceElementVmmeSource, portMirroringConfigurationByPolicyElement);
539
540         PortMirroringVerificator.validateLinkProperties();
541     }
542
543     @Test
544     public void restorePortMirroringServiceLink() throws Throwable {
545
546         //Scenario is taken from bug 361475 - Second Scenario
547         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
548         ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails();
549         Service service = portMirrioringConfigurationObject.getService();
550         CanvasElement vmmeCanvasElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName();
551         Service serviceContainerVmme_Source = portMirrioringConfigurationObject.getServiceContainerVmme_Source();
552
553         getExtendTest().log(Status.INFO, String.format("Checkout the vmme Service"));
554         serviceContainerVmme_Source = (Service) AtomicOperationUtils.changeComponentState(serviceContainerVmme_Source, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
555         getExtendTest().log(Status.INFO, String.format("Going to certify the vmme Service"));
556         serviceContainerVmme_Source = (Service) AtomicOperationUtils.changeComponentState(serviceContainerVmme_Source, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
557
558         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click();
559         GeneralUIUtils.ultimateWait();
560         HomeUtils.findComponentAndClick(service.getName());
561
562         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
563         CanvasManager canvasManager = CanvasManager.getCanvasManager();
564
565         getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 2.0", serviceContainerVmme_Source.getName()));
566         CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0",false);
567
568         getExtendTest().log(Status.INFO, "Validating 1 link exist after change version to the vmme service (Newer version)");
569         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2);
570
571         getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 1.0", serviceContainerVmme_Source.getName()));
572         CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "1.0",false);
573         
574         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 2);
575     }
576
577     @Test
578     public void restoreServiceVersionOnContainerService() throws Throwable {
579         //Scenario is taken from bug 361475 - First Scenario
580         PortMirrioringConfigurationObject portMirrioringConfigurationObject = PortMirroringUtils.createPortMirriongConfigurationStructure(false);
581         ServiceReqDetails serviceReqDetails = portMirrioringConfigurationObject.getServiceReqDetails();
582         Service service = portMirrioringConfigurationObject.getService();
583         CanvasElement vmmeCanvasElement = portMirrioringConfigurationObject.getServiceElementVmmeSourceName();
584         Service serviceContainerVmme_Source = portMirrioringConfigurationObject.getServiceContainerVmme_Source();
585         Service serviceContainerVprobe_Vprobe_Collector = portMirrioringConfigurationObject.getServiceContainerVprobe_Collector();
586         CanvasElement vprobeCanvasElement = portMirrioringConfigurationObject.getServiceElementVprobeCollector();
587
588
589         getExtendTest().log(Status.INFO, String.format("Checkout the vmme Service"));
590         serviceContainerVmme_Source = (Service) AtomicOperationUtils.changeComponentState(serviceContainerVmme_Source, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CHECKOUT, true).getLeft();
591         getExtendTest().log(Status.INFO, String.format("Going to certify the vmme Service"));
592         serviceContainerVmme_Source = (Service) AtomicOperationUtils.changeComponentState(serviceContainerVmme_Source, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
593
594         GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.MainMenuButtonsFromInsideFrame.HOME_BUTTON.getValue()).click();
595         GeneralUIUtils.ultimateWait();
596         HomeUtils.findComponentAndClick(service.getName());
597
598         ServiceGeneralPage.getLeftMenu().moveToCompositionScreen();
599         CanvasManager canvasManager = CanvasManager.getCanvasManager();
600
601 //        canvasManager.linkElements(vmmeCanvasElement, CircleSize.SERVICE, vprobeCanvasElement, CircleSize.SERVICE);
602         canvasManager.linkElements(vmmeCanvasElement, vprobeCanvasElement);
603
604         getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 2.0", serviceContainerVmme_Source.getName()));
605         CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "2.0",false);
606
607         getExtendTest().log(Status.INFO, "Validating 1 link exist after change version to the vmme service (Newer version)");
608         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 3);
609
610         getExtendTest().log(Status.INFO, String.format("Changing vmme source %s instance to version 1.0", serviceContainerVmme_Source.getName()));
611         CompositionPage.changeComponentVersion(canvasManager, vmmeCanvasElement, "1.0",false);
612         
613         ServiceVerificator.verifyLinkCreated(serviceReqDetails, getUser(), 3);
614     }
615
616     @Override
617     protected UserRoleEnum getRole() {
618         return UserRoleEnum.DESIGNER;
619     }
620 }
621
622