1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.demo.uif.library.collections;
17
18 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
19 import org.apache.commons.lang.StringUtils;
20 import org.junit.Test;
21 import org.openqa.selenium.By;
22
23
24
25
26 public class DemoCollectionFeaturesColumnCalculationsAft extends WebDriverLegacyITBase {
27
28
29
30
31 public static final String BOOKMARK_URL =
32 "/kr-krad/kradsampleapp?viewId=Demo-TableLayoutTotalingView&methodToCall=start";
33
34 @Override
35 protected String getBookmarkUrl() {
36 return BOOKMARK_URL;
37 }
38
39 @Override
40 protected void navigate() throws Exception {
41 waitAndClickById("Demo-LibraryLink", "");
42 waitAndClickByLinkText("Collection Features");
43 waitAndClickByLinkText("Column Calculations");
44 }
45
46 protected void testCollectionFeaturesColumnCalculations() throws Exception {
47 String preValueString = waitAndGetText(By.xpath(
48 "//div[@id='Demo-TableLayoutTotaling-Section1']/div/table/tfoot/tr/th[2]/div/fieldset/div/div[@data-role='pageTotal']/p"))[0];
49 if (StringUtils.isBlank(preValueString)) {
50 jiraAwareFail("calculation column contains no text");
51 }
52 Integer preValue = Integer.parseInt(preValueString);
53 clearTextByName("collection1[0].field1");
54 waitAndTypeByName("collection1[0].field1", "0");
55 waitAndTypeByName("newCollectionLines['collection1'].field1", "");
56 Integer postValue = Integer.parseInt(getTextByXpath(
57 "//div[@id='Demo-TableLayoutTotaling-Section1']/div/table/tfoot/tr/th[2]/div/fieldset/div/div[@data-role='pageTotal']/p"));
58 if (postValue >= preValue) {
59 jiraAwareFail("Calculation Error !");
60 }
61 }
62
63 protected void testCollectionFeaturesColumnCalculationsOnKeyUp() throws Exception {
64 selectByName("exampleShown", "On Key Up");
65 Integer preValue = Integer.parseInt(waitAndGetText(By.xpath(
66 "//div[@id='Demo-TableLayoutTotaling-Section2']/div/table/tfoot/tr/th[2]/div/fieldset/div/div[@data-role='pageTotal']/p"))[0]);
67 clearTextByName("collection1_2[0].field1");
68 waitAndTypeByName("collection1_2[0].field1", "0");
69 Thread.sleep(2000);
70 Integer postValue = Integer.parseInt(getTextByXpath(
71 "//div[@id='Demo-TableLayoutTotaling-Section2']/div/table/tfoot/tr/th[2]/div/fieldset/div/div[@data-role='pageTotal']/p"));
72 if (postValue >= preValue) {
73 jiraAwareFail("Calculation Error !");
74
75 }
76 }
77
78 protected void testCollectionFeaturesColumnCalculationsSomeColumns() throws Exception {
79 selectByName("exampleShown", "Some Columns");
80 Integer preValue = Integer.parseInt(waitAndGetText(By.xpath(
81 "//div[@id='Demo-TableLayoutTotaling-Section3']/div/table/tfoot/tr/th[3]/div/fieldset/div/div[@data-role='pageTotal']/p"))[0]);
82 clearTextByName("collection1_3[0].field2");
83 waitAndTypeByName("collection1_3[0].field2", "0");
84 waitAndTypeByName("newCollectionLines['collection1_3'].field2", "");
85 Integer postValue = Integer.parseInt(getTextByXpath(
86 "//div[@id='Demo-TableLayoutTotaling-Section3']/div/table/tfoot/tr/th[3]/div/fieldset/div/div[@data-role='pageTotal']/p"));
87 if (postValue >= preValue) {
88 jiraAwareFail("Calculation Error !");
89
90 }
91 }
92
93 protected void testCollectionFeaturesColumnCalculationsLeftLabel() throws Exception {
94 selectByName("exampleShown", "Left Label");
95 assertElementPresentByXpath(
96 "//div[@id='Demo-TableLayoutTotaling-Section4']/div/table/tfoot/tr/th/div/label");
97 }
98
99 protected void testCollectionFeaturesColumnCalculationsMultipleOptions() throws Exception {
100 selectByName("exampleShown", "Multiple Options");
101 assertElementPresentByXpath(
102 "//div[@id='Demo-TableLayoutTotaling-Section5']/div/table/tfoot/tr/th/div/fieldset/div/div/p");
103 assertElementPresentByXpath(
104 "//div[@id='Demo-TableLayoutTotaling-Section5']/div/table/tfoot/tr/th/div/fieldset/div/div/label");
105 if (isElementPresentByXpath(
106 "//div[@id='Demo-TableLayoutTotaling-Section5']/div/table/tfoot/tr/th[2]/div/fieldset/div/div[@class='uif-verticalBoxLayout']/div/span/label")) {
107 jiraAwareFail("Multiple Options Failure !");
108 }
109 }
110
111 protected void testCollectionFeaturesColumnCalculationsMultipleCalculations() throws Exception {
112 selectByName("exampleShown", "Multiple Calculations");
113 assertElementPresentByXpath(
114 "//div[@id='Demo-TableLayoutTotaling-Section6']/div/table/tfoot/tr/th[5]/div/div/fieldset/div/div/p");
115 assertElementPresentByXpath(
116 "//div[@id='Demo-TableLayoutTotaling-Section6']/div/table/tfoot/tr/th[5]/div/div[2]/fieldset/div/div/p");
117 assertElementPresentByXpath(
118 "//div[@id='Demo-TableLayoutTotaling-Section6']/div/table/tfoot/tr/th[5]/div/div[3]/fieldset/div/div/p");
119 assertElementPresentByXpath(
120 "//div[@id='Demo-TableLayoutTotaling-Section6']/div/table/tfoot/tr/th[5]/div/div[4]/fieldset/div/div/p");
121 if (isElementPresentByXpath(
122 "//div[@id='Demo-TableLayoutTotaling-Section6']/div/table/tfoot/tr/th[2]/div/div[@class='uif-verticalBoxLayout clearfix']/div/fieldset/div/div[@class='uif-verticalBoxLayout']/div/p")) {
123 jiraAwareFail("Multiple Calculations Failure !");
124 }
125 }
126
127 protected void testCollectionFeaturesColumnCalculationsGroupingCalculations() throws Exception {
128 selectByName("exampleShown", "Grouping Calculations");
129 assertElementPresentByXpath(
130 "//div[@id='Demo-TableLayoutTotaling-Section7']/div/table/tbody/tr[7]/td/div/p");
131 assertElementPresentByXpath(
132 "//div[@id='Demo-TableLayoutTotaling-Section7']/div/table/tbody/tr[7]/td[2]/div/p");
133 assertElementPresentByXpath(
134 "//div[@id='Demo-TableLayoutTotaling-Section7']/div/table/tbody/tr[7]/td[3]/div/p");
135 }
136
137 protected void testCollectionFeaturesColumnCalculationsNonClientSide() throws Exception {
138 selectByName("exampleShown", "Non Client-side");
139 assertElementPresentByXpath(
140 "//div[@id='Demo-TableLayoutTotaling-Section8']/div/table/tfoot/tr/th[3]/div/fieldset/div/div/p[@data-role='totalValue']");
141 }
142
143 protected void testCollectionFeaturesColumnCalculationsCustomCalculation() throws Exception {
144 selectByName("exampleShown", "Custom Calculation");
145 assertTextPresent("Subtracted:");
146 }
147
148 private void testAllColumnCalculations() throws Exception {
149 testCollectionFeaturesColumnCalculations();
150 testCollectionFeaturesColumnCalculationsOnKeyUp();
151 testCollectionFeaturesColumnCalculationsSomeColumns();
152 testCollectionFeaturesColumnCalculationsGroupingCalculations();
153 testCollectionFeaturesColumnCalculationsNonClientSide();
154 testCollectionFeaturesColumnCalculationsCustomCalculation();
155 testCollectionFeaturesColumnCalculationsLeftLabel();
156 testCollectionFeaturesColumnCalculationsMultipleOptions();
157 testCollectionFeaturesColumnCalculationsMultipleCalculations();
158 }
159
160 @Test
161 public void testCollectionFeaturesColumnCalculationsBookmark() throws Exception {
162 testAllColumnCalculations();
163 passed();
164 }
165
166 @Test
167 public void testCollectionFeaturesColumnCalculationsNav() throws Exception {
168 testAllColumnCalculations();
169 passed();
170 }
171 }