Added oparent to sdc main
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / verificator / PropertiesAssignmentVerificator.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.execute.setup.SetupCDTest;
26 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
27
28 import static org.testng.Assert.assertNull;
29 import static org.testng.Assert.assertTrue;
30
31 public class PropertiesAssignmentVerificator {
32         
33         public static void validateFilteredPropertiesCount(int propertiesCount, String propertyLocation){
34                 int actualPropertiesCount = GeneralUIUtils.getWebElementsListByContainsClassName(propertyLocation).size();
35                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating. Expected properties count: %s , Actual: %s", propertiesCount, actualPropertiesCount));
36                 String errMsg = String.format("Properties amount not as expected, expected: %s ,Actual: %s", propertiesCount, actualPropertiesCount);
37                 assertTrue(actualPropertiesCount == propertiesCount, errMsg);
38         }
39
40         public static void validatePropertyValue(String expectedPropertyName, String expectedPropertyValue){
41                 String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value");
42                 assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property/input %s. Expected: %s, Actual: %s ",  expectedPropertyName, expectedPropertyValue, actualPropertyValue));
43         }
44
45         public static void validatePropertyValueIsNull(String expectedPropertyName){
46                 String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value");
47                 assertNull(actualPropertyValue, String.format("Validating the value of property/input %s. Expected: empty, Actual: %s ",  expectedPropertyName, actualPropertyValue));
48         }
49
50         public static void validateListPropertyValue(DataTestIdEnum.PropertiesAssignmentScreen prefix, String expectedPropertyName, String expectedPropertyValue, int index){
51                 String listElement = prefix.getValue() + expectedPropertyName + "." + String.valueOf(index);
52                 String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(listElement).getAttribute("value");
53                 assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the %s list element value of property %s. Expected: %s, Actual: %s ",  index, expectedPropertyName, expectedPropertyValue, actualPropertyValue));
54         }
55
56         public static void validateBooleanPropertyValue(String expectedPropertyName, String expectedPropertyValue){
57                 String actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(expectedPropertyName).getText();
58                 assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property %s. Expected: %s, Actual: %s ",  expectedPropertyName, expectedPropertyValue, actualPropertyValue));
59         }
60 }