1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.main;
17
18 import org.apache.commons.lang3.StringUtils;
19 import org.junit.Test;
20 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
21 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
22 import org.kuali.rice.testtools.selenium.WebDriverUtils;
23 import org.openqa.selenium.Keys;
24
25
26
27
28
29
30 public class AgendaEditorAddRuleAft extends WebDriverLegacyITBase {
31
32 public static String KRAD_PORTAL_BASE = "/kr-krad/";
33 public static String AGENDA_EDITOR_BASE = "krmsAgendaEditor";
34
35 public static String NEW_DATA_OBJ_PATH = "document.newMaintainableObject.dataObject.";
36
37 public static final String BOOKMARK_URL =
38 AutomatedFunctionalTestUtils.PORTAL
39 + "?channelTitle=Agenda%20Lookup&channelUrl="
40 + WebDriverUtils.getBaseUrlString()
41 + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
42 + "org.kuali.rice.krms.impl.repository.AgendaBo"
43 + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS
44 + "&returnLocation="
45 + AutomatedFunctionalTestUtils.PORTAL_URL
46 + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK;
47
48 @Override
49 protected String getBookmarkUrl() {
50 return BOOKMARK_URL;
51 }
52
53 @Override
54 protected void navigate() throws Exception {
55 waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
56 waitForPageToLoad();
57 }
58
59 protected void testAgendaEditorAddRuleWithSimpleProposition() throws Exception {
60 String uniqId = AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits();
61 String agendaName = "AgendaEditorAddRuleAft " + uniqId;
62 String ruleName = "AgendaEditorAddRuleAft Rule " + "1" + " " + uniqId;
63
64 selectFrameIframePortlet();
65 waitAndClickLinkContainingText("Create New");
66
67
68 String docId = waitForAgendaDocId();
69 addNewAgendaInformation(agendaName, "Kuali Rules Test", "Context1");
70
71 Thread.sleep(500);
72 unfocusElement();
73 unfocusElement();
74 waitAndTypeByName(NEW_DATA_OBJ_PATH + "agenda.typeId", "Campus Agenda");
75 unfocusElement();
76 waitAndTypeByName(NEW_DATA_OBJ_PATH + "customAttributesMap[Campus]", "BL");
77 waitAndClickButtonByText("Add Rule");
78
79
80 waitForPageToLoad();
81 addNewAgendaRuleInformation("Validation Rule", "", ruleName);
82 waitAndClickButtonByExactText("Add");
83 addRulePropositionInfo("0", "Campus must have students", "", "Bloomington Campus Size", ">", "1");
84 addNewRuleActionInformation("KrmsActionResolverType", "test", "test");
85 waitAndClickButtonByText("Add Rule");
86
87
88 waitForTextPresent(ruleName);
89 waitAndClickSubmitByText();
90 waitAndClickConfirmationOk();
91 waitForTextPresent("Document was successfully submitted", WebDriverUtils.configuredImplicityWait() * 2);
92 assertDocSearch(docId, "FINAL");
93 passed();
94 }
95
96
97 protected void addNewAgendaInformation(String agendaName, String agendaNamespace, String agendaContext) throws Exception {
98 waitAndSelectByName(NEW_DATA_OBJ_PATH + "namespace", agendaNamespace);
99 waitAndTypeByName(NEW_DATA_OBJ_PATH + "agenda.name", agendaName);
100 waitAndTypeByName(NEW_DATA_OBJ_PATH + "contextName", agendaContext);
101 }
102
103 protected void addNewAgendaRuleInformation(String ruleType, String ruleTypeCode, String ruleName) throws Exception {
104 waitAndSelectByName(NEW_DATA_OBJ_PATH + "agendaItemLine.rule.typeId", ruleType);
105
106 if (StringUtils.isNotBlank(ruleTypeCode)) {
107 waitAndSelectByName(NEW_DATA_OBJ_PATH + "customRuleAttributesMap[ruleTypeCode]", ruleTypeCode);
108 }
109
110
111 assertTrue("Expected ruleTypeCode dropdown value not found ",isElementPresentByXpath(
112 "//option[@selected='selected' and @value='1002']"));
113
114 waitAndTypeByName(NEW_DATA_OBJ_PATH + "agendaItemLine.rule.name", ruleName);
115 }
116
117 protected void addRulePropositionInfo(String childIndex, String description, String category, String propTerm,
118 String propComparison, String propositionValue) throws Exception {
119 String propTreeRootPath = NEW_DATA_OBJ_PATH + "agendaItemLine.rule.propositionTree.rootElement.";
120 String propTreeChildPath = propTreeRootPath + "children[" + childIndex + "].";
121 String propositionPath = propTreeChildPath + "data.proposition.";
122
123 if (StringUtils.isNoneBlank(description)) {
124 waitAndTypeByName(propositionPath + "description", description);
125 }
126
127 if (StringUtils.isNoneBlank(category)) {
128 waitAndSelectByName(propositionPath + "categoryId", category);
129 }
130
131 if (StringUtils.isNoneBlank(propTerm)) {
132 waitAndSelectByName(propositionPath + "parameters[0].value", propTerm);
133 }
134
135 if (StringUtils.isNoneBlank(propComparison)) {
136 waitAndSelectByName(propositionPath + "parameters[2].value", propComparison);
137 unfocusElement();
138 Thread.sleep(8000);
139 }
140
141 if (StringUtils.isNoneBlank(propositionValue)) {
142 waitAndTypeByName(propositionPath + "parameters[1].value", propositionValue);
143 }
144 }
145
146 protected void addNewRuleActionInformation(String actionType, String actionName,
147 String actionDescription) throws Exception {
148
149 waitAndSelectByName(NEW_DATA_OBJ_PATH + "agendaItemLineRuleAction.typeId", actionType);
150 waitAndTypeByName(NEW_DATA_OBJ_PATH + "agendaItemLineRuleAction.name", actionName);
151 waitAndTypeByName(NEW_DATA_OBJ_PATH + "agendaItemLineRuleAction.description", actionDescription);
152 }
153
154
155 protected void unfocusElement() {
156 typeTab();
157 }
158
159
160
161
162 @Test
163 public void testAgendaEditorAddRuleNav() throws Exception {
164 testAgendaEditorAddRuleWithSimpleProposition();
165 }
166
167 }
168