Add drop down Source subscriber name on the PMC instantiation form
[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.Constants.ConfigurationCreation;
8 import vid.automation.test.Constants.ViewEdit;
9 import vid.automation.test.infra.SelectOption;
10
11 import static org.hamcrest.core.Is.is;
12
13 public class ServiceProxyPage extends VidBasePage {
14
15     public ServiceProxyPage chooseSource(String source){
16         SelectOption.byTestIdAndVisibleText(source, Constants.ConfigurationCreation.SOURCE_DROPDOWN_TEST_ID);
17         return this;
18     }
19
20     public ServiceProxyPage chooseSourceSubscriberName(String subscriberName){
21         SelectOption.byTestIdAndVisibleText(subscriberName, "sourceSubscriberName");
22         GeneralUIUtils.ultimateWait();
23       return this;
24     };
25
26     public ServiceProxyPage chooseSourceServiceType(String sourceServiceType){
27         SelectOption.byTestIdAndVisibleText(sourceServiceType, "sourceServiceType");
28         GeneralUIUtils.ultimateWait();
29         return this;
30     }
31     public ServiceProxyPage chooseCollectorServiceType(String collectorServiceType){
32         SelectOption.byTestIdAndVisibleText(collectorServiceType, "collectorServiceType");
33         GeneralUIUtils.ultimateWait();
34         return this;
35     }
36
37     public void assertSourceSubscriberName(String sourceSubscriberName){
38         String displayedSubscriberName = SelectOption.getSelectedOption(ConfigurationCreation.SOURCE_SUBSCRIBER_NAME);
39         Assert.assertEquals("The displayed source subscriber name is not correct", sourceSubscriberName, displayedSubscriberName);
40     }
41
42     public void assertCollectorServiceType(String collectorServiceType) {
43         String displayedCollectorServiceType = SelectOption.getSelectedOption("collectorServiceType");
44         Assert.assertEquals("The displayed collector service type is incorrect", collectorServiceType, displayedCollectorServiceType);
45     }
46
47     public ServiceProxyPage chooseCollector(String collector){
48         GeneralUIUtils.ultimateWait();
49         SelectOption.byTestIdAndVisibleText(collector, Constants.ConfigurationCreation.COLLECTOR_DROPDOWN_TEST_ID);
50         return this;
51     }
52     public ServiceProxyPage clickCreateButton() {
53         GeneralUIUtils.clickOnElementByTestId(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID, 60);
54         return this;
55     }
56
57     public ServiceProxyPage clickDeleteConfigurationButton() {
58         GeneralUIUtils.clickOnElementByTestId(deleteConfigurationButtonTestId(), 60);
59         return this;
60     }
61
62     private String configurationInstanceName() {
63         return "dummy_instance";
64     }
65
66     private String deleteConfigurationButtonTestId() {
67         return Constants.DELETE_CONFIGURATION_BUTTON + "-" + configurationInstanceName();
68     }
69
70     private String activateDeactivateButtonTestId() {
71         return Constants.ACTIVATE_DEACTIVATE_BUTTON + "-" + configurationInstanceName();
72     }
73
74     private String enableDisableButtonTestId(String portName) {
75         return Constants.ENABLE_DISABLE_BUTTON + "-" + configurationInstanceName() + "-" + portName;
76     }
77
78     public ServiceProxyPage assertDeleteConfigurationButtonExists(boolean shouldExist){
79
80         if (shouldExist) {
81             WebElement selectedV = GeneralUIUtils.getWebElementByTestID(deleteConfigurationButtonTestId(), 3);
82             Assert.assertThat(selectedV != null, is(shouldExist));
83             Assert.assertThat(selectedV.isDisplayed(), is(shouldExist));
84         } else {
85             boolean webElementExistByTestId = GeneralUIUtils.isWebElementExistByTestId(deleteConfigurationButtonTestId());
86             Assert.assertThat(webElementExistByTestId, is(shouldExist));
87         }
88         return this;
89     }
90
91     public void assertSourceModelName(String sourceName){
92         String displayedSourceName= getTextByTestID(Constants.ConfigurationCreation.SOURCE_INSTANCE_NAME_TEST_ID);
93         Assert.assertEquals("The displayed source name is not correct", sourceName+" i", displayedSourceName);
94     }
95
96     public void assertCollectorModelName(String collectorName) {
97         String displayedCollectorName = getTextByTestID(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_NAME_TEST_ID);
98         Assert.assertEquals("The displayed collector name is not correct", collectorName+"i", displayedCollectorName);
99     }
100
101     public void assertNoResultRequirementsDropDown(String msgTestId, String resourceType){
102         String noResultText = GeneralUIUtils.getWebElementByTestID(msgTestId, 60).getText();
103         Assert.assertEquals("The error message no instance in DropDown is not match","No "+resourceType+" instances found.",noResultText);
104     }
105     public ServiceProxyPage clickInfoButton(String infoButtonTestId) {
106         GeneralUIUtils.clickOnElementByTestId(infoButtonTestId, 90);
107         return this;
108     }
109
110
111     public ServiceProxyPage assertSelectedInstanceIcon(String SelectedIconTestId){
112         WebElement selectedV = GeneralUIUtils.getWebElementByTestID(SelectedIconTestId, 90);
113         Assert.assertTrue(selectedV != null);
114         String selectedVClass = selectedV.getAttribute("class");
115         Assert.assertTrue(selectedVClass.contains("valid-large"));
116         return this;
117     }
118
119     public ServiceProxyPage clickActivateDeactivateButton() {
120         GeneralUIUtils.clickOnElementByTestId(activateDeactivateButtonTestId(), 60);
121         return this;
122     }
123
124     public ServiceProxyPage clickEnableDisableButton(){
125         GeneralUIUtils.clickOnElementByTestId(enableDisableButtonTestId(ViewEdit.COMMON_PORT_MIRRORING_PORT_NAME), 60);
126         return this;
127     }
128 }