Added oparent to sdc main
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / verificator / PortMirroringVerificator.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.verificator;
22
23 import com.aventstack.extentreports.Status;
24 import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
25 import org.openecomp.sdc.ci.tests.datatypes.PortMirroringEnum;
26 import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
27 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
28 import org.openecomp.sdc.ci.tests.utilities.PortMirroringUtils;
29 import org.openqa.selenium.By;
30
31 import java.awt.datatransfer.UnsupportedFlavorException;
32 import java.io.IOException;
33
34 import static org.testng.Assert.assertTrue;
35
36 public class PortMirroringVerificator {
37
38     public static void checkProxyServiceName(String serviceName, String instanceId)
39     {
40         String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText();
41         String serviceExpectedName = PortMirroringUtils.createProxyInstanceServiceName(serviceName,instanceId);
42         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", serviceExpectedName));
43         assertTrue(serviceActualName.equalsIgnoreCase(serviceExpectedName));
44     }
45
46     public static void checkProxyServiceType()
47     {
48         String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText();
49         SetupCDTest.getExtendTest().log(Status.INFO, "Verifying the instance type is Service Proxy");
50         assertTrue(serviceActualName.equalsIgnoreCase(PortMirroringEnum.SERVICE_PROXY_TYPE.getValue()));
51     }
52
53     public static void validatingProxyServiceNameAndType(String serviceName, String instanceId)
54     {
55         checkProxyServiceName(serviceName, instanceId);
56         checkProxyServiceType();
57     }
58
59     public static void validateGeneralInfo()
60     {
61         String type = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.TYPE.getValue()).getText();
62         String resourceType = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.RESOURCE_TYPE.getValue()).getText();
63         String category = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.CATEGORY.getValue()).getText();
64         String subCategory = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel_GenerInfo.SUB_CATEGORY.getValue()).getText();
65
66         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the type equals %s", PortMirroringEnum.TYPE.getValue()));
67         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the resource type equals %s", PortMirroringEnum.RESOURCE_TYPE.getValue()));
68         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the category equals %s", PortMirroringEnum.CATEGORY.getValue()));
69         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the sub category equals %s", PortMirroringEnum.SUB_CATEGORY.getValue()));
70
71         assertTrue(type.equalsIgnoreCase(PortMirroringEnum.TYPE.getValue()));
72         assertTrue(resourceType.equalsIgnoreCase(PortMirroringEnum.RESOURCE_TYPE.getValue()));
73         assertTrue(category.equalsIgnoreCase(PortMirroringEnum.CATEGORY.getValue()));
74         assertTrue(subCategory.equalsIgnoreCase(PortMirroringEnum.SUB_CATEGORY.getValue()));
75     }
76
77     public static void validateReqsAndCapsTabExist()
78     {
79         SetupCDTest.getExtendTest().log(Status.INFO, "Verifying tab reqs and caps exist for PMC element");
80         GeneralUIUtils.getWebElementBy(By.xpath(DataTestIdEnum.CompositionRightPanel.REQS_AND_CAPS_TAB_XPATH.getValue())).click();
81     }
82
83     public static void validateElementName(String expectedName)
84     {
85         String serviceActualName = GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.CompositionRightPanel.COMPONENT_TITLE.getValue()).getText();
86         SetupCDTest.getExtendTest().log(Status.INFO, String.format("Verifying the instance name is %s", expectedName));
87         assertTrue(serviceActualName.equalsIgnoreCase(expectedName));
88     }
89
90     public static void validateLinkProperties() throws IOException, UnsupportedFlavorException {
91         SetupCDTest.getExtendTest().log(Status.INFO, "Validate Link properties values");
92         String actualNetworkRole = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NETWORK_ROLE_XPATH.getValue());
93         String actualNfcType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NFC_TYPE_XPATH.getValue());
94         String actualPpsCapacity = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.PPS_CAPACITY_XPATH.getValue());
95         String actualNfType = GeneralUIUtils.getTextValueFromWebElementByXpath(PortMirroringEnum.NF_TYPE_XPATH.getValue());
96
97         assertTrue(actualNetworkRole.equalsIgnoreCase(PortMirroringEnum.NETWORK_ROLE_VALUE.getValue()));
98         assertTrue(actualNfcType.equalsIgnoreCase(PortMirroringEnum.NFC_TYPE_VALUE.getValue()));
99         assertTrue(actualPpsCapacity.equalsIgnoreCase(PortMirroringEnum.PPS_CAPACITY_VALUE.getValue()));
100         assertTrue(actualNfType.equalsIgnoreCase(PortMirroringEnum.NF_TYPE_VALUE.getValue()));
101     }
102
103
104
105 }