re base code
[sdc.git] / ui-ci / src / main / java / org / openecomp / sdc / ci / tests / verificator / PropertiesAssignmentVerificator.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.execute.setup.SetupCDTest;
6 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
7
8 import static org.testng.Assert.assertNull;
9 import static org.testng.Assert.assertTrue;
10
11 public class PropertiesAssignmentVerificator {
12         
13         public static void validateFilteredPropertiesCount(int propertiesCount, String propertyLocation){
14                 int actualPropertiesCount = GeneralUIUtils.getWebElementsListByContainsClassName(propertyLocation).size();
15                 SetupCDTest.getExtendTest().log(Status.INFO, String.format("Validating. Expected properties count: %s , Actual: %s", propertiesCount, actualPropertiesCount));
16                 String errMsg = String.format("Properties amount not as expected, expected: %s ,Actual: %s", propertiesCount, actualPropertiesCount);
17                 assertTrue(actualPropertiesCount == propertiesCount, errMsg);
18         }
19
20         public static void validatePropertyValue(String expectedPropertyName, String expectedPropertyValue){
21                 String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value");
22                 assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property/input %s. Expected: %s, Actual: %s ",  expectedPropertyName, expectedPropertyValue, actualPropertyValue));
23         }
24
25         public static void validatePropertyValueIsNull(String expectedPropertyName){
26                 String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(expectedPropertyName).getAttribute("value");
27                 assertNull(actualPropertyValue, String.format("Validating the value of property/input %s. Expected: empty, Actual: %s ",  expectedPropertyName, actualPropertyValue));
28         }
29
30         public static void validateListPropertyValue(DataTestIdEnum.PropertiesAssignmentScreen prefix, String expectedPropertyName, String expectedPropertyValue, int index){
31                 String listElement = prefix.getValue() + expectedPropertyName + "." + String.valueOf(index);
32                 String actualPropertyValue = GeneralUIUtils.getWebElementByTestID(listElement).getAttribute("value");
33                 assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the %s list element value of property %s. Expected: %s, Actual: %s ",  index, expectedPropertyName, expectedPropertyValue, actualPropertyValue));
34         }
35
36         public static void validateBooleanPropertyValue(String expectedPropertyName, String expectedPropertyValue){
37                 String actualPropertyValue = GeneralUIUtils.getSelectedElementFromDropDown(expectedPropertyName).getText();
38                 assertTrue(expectedPropertyValue.equals(actualPropertyValue), String.format("Validating the value of property %s. Expected: %s, Actual: %s ",  expectedPropertyName, expectedPropertyValue, actualPropertyValue));
39         }
40 }