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