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