Sync Integ to Master
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / verificator / PortMirroringVerificator.java
1 package org.openecomp.sdc.ci.tests.verificator;
2
3 import com.aventstack.extentreports.Status;
4 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
5 import org.openecomp.sdc.ci.tests.datatypes.PortMirroringEnum;
6 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
7 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
8 import org.openecomp.sdc.ci.tests.utilities.PortMirroringUtils;
9 import org.openqa.selenium.By;
10
11 import java.awt.datatransfer.UnsupportedFlavorException;
12 import java.io.IOException;
13
14 import static org.testng.Assert.assertTrue;
15
16 public class PortMirroringVerificator {
17
18     public static void checkProxyServiceName(String serviceName, String instanceId)
19     {
20         String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText();
21         String serviceExpectedName = PortMirroringUtils.createProxyInstanceServiceName(serviceName,instanceId);
22         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", serviceExpectedName));
23         assertTrue(serviceActualName.equalsIgnoreCase(serviceExpectedName));
24     }
25
26     public static void checkProxyServiceType()
27     {
28         String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText();
29         SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the instance type is Service Proxy");
30         assertTrue(serviceActualName.equalsIgnoreCase(PortMirroringEnum.SERVICE_PROXY_TYPE.getValue()));
31     }
32
33     public static void validatingProxyServiceNameAndType(String serviceName, String instanceId)
34     {
35         checkProxyServiceName(serviceName, instanceId);
36         checkProxyServiceType();
37     }
38
39     public static void validateGeneralInfo()
40     {
41         String type = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText();
42         String resourceType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.RESOURCE_TYPE.getValue()).getText();
43         String category = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.CATEGORY.getValue()).getText();
44         String subCategory = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.SUB_CATEGORY.getValue()).getText();
45
46         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the type equals %s", PortMirroringEnum.TYPE.getValue()));
47         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the resource type equals %s", PortMirroringEnum.RESOURCE_TYPE.getValue()));
48         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the category equals %s", PortMirroringEnum.CATEGORY.getValue()));
49         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the sub category equals %s", PortMirroringEnum.SUB_CATEGORY.getValue()));
50
51         assertTrue(type.equalsIgnoreCase(PortMirroringEnum.TYPE.getValue()));
52         assertTrue(resourceType.equalsIgnoreCase(PortMirroringEnum.RESOURCE_TYPE.getValue()));
53         assertTrue(category.equalsIgnoreCase(PortMirroringEnum.CATEGORY.getValue()));
54         assertTrue(subCategory.equalsIgnoreCase(PortMirroringEnum.SUB_CATEGORY.getValue()));
55     }
56
57     public static void validateReqsAndCapsTabExist()
58     {
59         SetupCDTest.getExtendTest().log(Status.INFO, "Verifying tab reqs and caps exist for PMC element");
60         GeneralUIUtils.getWebElementBy(By.xpath(DataTestIdEnum.CompositionRightPanel.REQS_AND_CAPS_TAB_XPATH.getValue())).click();
61     }
62
63     public static void validateElementName(String expectedName)
64     {
65         String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText();
66         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", expectedName));
67         assertTrue(serviceActualName.equalsIgnoreCase(expectedName));
68     }
69
70     public static void validateLinkProperties() throws IOException, UnsupportedFlavorException {
71         SetupCDTest.getExtendTest().log(Status.INFO, "Validate Link properties values");
72         String actualNetworkRole = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NETWORK_ROLE_XPATH.getValue());
73         String actualNfcType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NFC_TYPE_XPATH.getValue());
74         String actualPpsCapacity = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.PPS_CAPACITY_XPATH.getValue());
75         String actualNfType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NF_TYPE_XPATH.getValue());
76
77         assertTrue(actualNetworkRole.equalsIgnoreCase(PortMirroringEnum.NETWORK_ROLE_VALUE.getValue()));
78         assertTrue(actualNfcType.equalsIgnoreCase(PortMirroringEnum.NFC_TYPE_VALUE.getValue()));
79         assertTrue(actualPpsCapacity.equalsIgnoreCase(PortMirroringEnum.PPS_CAPACITY_VALUE.getValue()));
80         assertTrue(actualNfType.equalsIgnoreCase(PortMirroringEnum.NF_TYPE_VALUE.getValue()));
81     }
82
83
84
85 }