Merge automation from ECOMP's repository
[vid.git] / vid-automation / src / main / java / vid / automation / test / sections / ServiceProxyPage.java
1 package vid.automation.test.sections;
2
3 import org.junit.Assert;
4 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
5 import org.openqa.selenium.WebElement;
6 import vid.automation.test.Constants;
7 import vid.automation.test.infra.SelectOption;
8
9 import static org.hamcrest.core.Is.is;
10
11 public class ServiceProxyPage extends VidBasePage {
12
13     public ServiceProxyPage chooseSource(String source){
14         SelectOption.byTestIdAndVisibleText(source, Constants.ConfigurationCreation.SOURCE_DROPDOWN_TEST_ID);
15         return this;
16     }
17     public ServiceProxyPage chooseSourceServiceType(String sourceServiceType){
18         SelectOption.byTestIdAndVisibleText(sourceServiceType, "sourceServiceType");
19         GeneralUIUtils.ultimateWait();
20         return this;
21     }
22     public ServiceProxyPage chooseCollectorServiceType(String collectorServiceType){
23         SelectOption.byTestIdAndVisibleText(collectorServiceType, "collectorServiceType");
24         GeneralUIUtils.ultimateWait();
25         return this;
26     }
27     public void assertCollectorServiceType(String collectorServiceType) {
28         String displayedCollectorServiceType = SelectOption.getSelectedOption("collectorServiceType");
29         Assert.assertEquals("The displayed collector service type is incorrect", collectorServiceType, displayedCollectorServiceType);
30     }
31
32     public ServiceProxyPage chooseCollector(String collector){
33         GeneralUIUtils.ultimateWait();
34         SelectOption.byTestIdAndVisibleText(collector, Constants.ConfigurationCreation.COLLECTOR_DROPDOWN_TEST_ID);
35         return this;
36     }
37     public ServiceProxyPage clickCreateButton() {
38         GeneralUIUtils.clickOnElementByTestId(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID, 60);
39         return this;
40     }
41
42     public ServiceProxyPage clickDeleteConfigurationButton() {
43         GeneralUIUtils.clickOnElementByTestId(Constants.DELETE_CONFIGURATION_BUTTON, 60);
44         return this;
45     }
46
47     public ServiceProxyPage assertDeleteConfigurationButtonExists(boolean shouldExist){
48
49         if (shouldExist) {
50             WebElement selectedV = GeneralUIUtils.getWebElementByTestID(Constants.DELETE_CONFIGURATION_BUTTON, 3);
51             Assert.assertThat(selectedV != null, is(shouldExist));
52             Assert.assertThat(selectedV.isDisplayed(), is(shouldExist));
53         } else {
54             boolean webElementExistByTestId = GeneralUIUtils.isWebElementExistByTestId(Constants.DELETE_CONFIGURATION_BUTTON);
55             Assert.assertThat(webElementExistByTestId, is(shouldExist));
56         }
57         return this;
58     }
59
60     public void assertSourceModelName(String sourceName){
61         String displayedSourceName= getTextByTestID(Constants.ConfigurationCreation.SOURCE_INSTANCE_NAME_TEST_ID);
62         Assert.assertEquals("The displayed source name is not correct", sourceName+" i", displayedSourceName);
63     }
64
65     public void assertCollectorModelName(String collectorName) {
66         String displayedCollectorName = getTextByTestID(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_NAME_TEST_ID);
67         Assert.assertEquals("The displayed collector name is not correct", collectorName+"i", displayedCollectorName);
68     }
69
70     public void assertNoResultRequirementsDropDown(String msgTestId, String resourceType){
71         String noResultText = GeneralUIUtils.getWebElementByTestID(msgTestId, 60).getText();
72         Assert.assertEquals("The error message no instance in DropDown is not match","No "+resourceType+" instances found.",noResultText);
73     }
74     public ServiceProxyPage clickInfoButton(String infoButtonTestId) {
75         GeneralUIUtils.clickOnElementByTestId(infoButtonTestId, 90);
76         return this;
77     }
78
79
80     public ServiceProxyPage assertSelectedInstanceIcon(String SelectedIconTestId){
81         WebElement selectedV = GeneralUIUtils.getWebElementByTestID(SelectedIconTestId, 90);
82         Assert.assertTrue(selectedV != null);
83         String selectedVClass = selectedV.getAttribute("class");
84         Assert.assertTrue(selectedVClass.contains("valid-large"));
85         return this;
86     }
87
88     public ServiceProxyPage clickActivateDeactivateButton() {
89         GeneralUIUtils.clickOnElementByTestId(Constants.ACTIVATE_DEACTIVATE_BUTTON, 60);
90         return this;
91     }
92
93     public ServiceProxyPage clickEnableDisableButton(){
94         GeneralUIUtils.clickOnElementByTestId(Constants.ENABLE_DISABLE_BUTTON, 60);
95         return this;
96     }
97 }