forked from cdapio/cdap-e2e-tests
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCdfNameSpaceAdminActions.java
More file actions
119 lines (104 loc) · 4.56 KB
/
CdfNameSpaceAdminActions.java
File metadata and controls
119 lines (104 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright © 2023 Cask Data, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package io.cdap.e2e.pages.actions;
import io.cdap.e2e.pages.locators.CdfNameSpaceAdminLocators;
import io.cdap.e2e.pages.locators.CdfSysAdminLocators;
import io.cdap.e2e.utils.AssertionHelper;
import io.cdap.e2e.utils.ConstantsUtil;
import io.cdap.e2e.utils.ElementHelper;
import io.cdap.e2e.utils.JsonUtils;
import io.cdap.e2e.utils.PluginPropertyUtils;
import io.cdap.e2e.utils.SeleniumHelper;
import io.cdap.e2e.utils.WaitHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
/**
* Represents CdfNameSpaceAdminActions
*/
public class CdfNameSpaceAdminActions {
private static final Logger logger = LoggerFactory.getLogger(CdfNameSpaceAdminActions.class);
public static CdfNameSpaceAdminLocators cdfNameSpaceAdminLocators;
static {
cdfNameSpaceAdminLocators = SeleniumHelper.getPropertiesLocators(
CdfNameSpaceAdminLocators.class);
}
public static void clickOnNameSpaceAdminTabs(String tabName, String nameSpaceName) {
ElementHelper.clickOnElement(
CdfNameSpaceAdminLocators.nameSpaceModules(tabName, nameSpaceName));
}
public static void openNamespaceAdminPage() {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.namespaceAdminMenu);
}
public static void clickOnHamburgerMenu() {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.hamburgerMenu);
}
public static void switchToNameSpace(String nameSpaceName) {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.switchNameSpace(nameSpaceName));
}
public static void createProfileForNamespace(String nameSpaceName) {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.createProfile(nameSpaceName));
}
public static void openNamespaceDropdown() {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.namespaceDropdown);
}
public static void addNamespaceFromHamburgerMenu() {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.addNamespace);
}
/**
* Enter KeyValue Pairs For Preference Property
*
* @param preferenceProperty @data-cy attribute value of preference Property. If
* preferenceProperty is present in
* {@link ConstantsUtil#DEFAULT_DATACY_ATTRIBUTES_FILE} then its data-cy
* is fetched from it else preferenceProperty is used as it is.
* @param keyValuePair Actual json KeyValue Pairs string is fetched from
* {@link ConstantsUtil#DEFAULT_PLUGIN_PROPERTIES_FILE} with
* keyValuePair as key
*/
public static void enterKeyValuePreferences(String preferenceProperty, String keyValuePair) {
String dataCyAttribute = PluginPropertyUtils.getPluginPropertyDataCyAttribute(
preferenceProperty);
if (dataCyAttribute == null) {
dataCyAttribute = preferenceProperty;
}
Map<String, String> properties =
JsonUtils.convertKeyValueJsonArrayToMap(PluginPropertyUtils.pluginProp(keyValuePair));
int index = 0;
for (Map.Entry<String, String> entry : properties.entrySet()) {
if (index != 0) {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.locateAddRowButtonProperty(
dataCyAttribute, index - 1));
}
ElementHelper.sendKeys(CdfNameSpaceAdminLocators.locateKeyProperty(
dataCyAttribute, index), entry.getKey());
ElementHelper.sendKeys(CdfNameSpaceAdminLocators.locateValueProperty(
dataCyAttribute, index), entry.getValue());
index++;
}
}
public static void switchToNewNameSpace() {
ElementHelper.clickOnElement(CdfNameSpaceAdminLocators.switchToNameSpaceButton);
}
public static void verifySwitchToNewNamespace(String value) {
String expectedNameSpace = PluginPropertyUtils.pluginProp(value);
AssertionHelper.verifyElementContainsText(CdfNameSpaceAdminLocators.namespaceText,
expectedNameSpace);
}
public static void verifyElementIsDisplayed() {
ElementHelper.isElementDisplayed(CdfNameSpaceAdminLocators.pageHeaderNameSpaceAdmin);
}
}