My favorites | Sign in
Project Home Wiki Issues Source
Checkout   Browse   Changes    
 
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/**
*
*/
package org.openiaml.model.tests.codegen.model0_5;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.openiaml.model.tests.codegen.DatabaseCodegenTestCase;

/**
* If we select multiple results and connect the resulting
* {@model DomainIterator} to a {@model InputForm} with a
* {@model SetWire}, the InputForm will be populated with buttons
* and conditions necessary for navigating over the result set.
*
* @example DomainIterator
* Using a {@model DomainIterator} that selects {@model DomainIterator#limit many results}
* to transform an {@model InputForm} into a paginated browser over that iterator.
*/
public class SelectWireManyPaginate extends DatabaseCodegenTestCase {

@Override
protected void setUp() throws Exception {
super.setUp();
root = loadAndCodegen(SelectWireManyPaginate.class);
initialiseDatabase();
}

/**
* The home page can be accessed.
*
* @throws Exception
*/
public void testHome() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();
}

/**
* Test the initial contents of the form.
*
* @throws Exception
*/
public void testContentsOfForm() throws Exception {

beginAtSitemapThenPage("Home");

assertContent("Title 1", "Content 1");

assertButtonPresentWithText("Next");
assertButtonPresentWithText("Previous");
assertButtonPresentWithText("First");
assertButtonPresentWithText("Last");

assertNoResults("10"); // we do not get the full 10 results
assertResults("5");

}

/**
* We can navigate through it.
*
* @throws Exception
*/
public void testNavigateThrough() throws Exception {

beginAtSitemapThenPage("Home");

// initial
assertContent("Title 1", "Content 1");

// navigate
for (int i = 2; i <= 5; i++) {
clickButtonWithText("Next");
assertContent("Title " + i, "Content " + i);
}

// if we click 'next', we won't fail
assertNoProblem();
clickButtonWithText("Next");
assertNoProblem();
assertContent("Title 5", "Content 5");

// we can cycle backwards
for (int i = 4; i >= 1; i--) {
clickButtonWithText("Previous");
assertContent("Title " + i, "Content " + i);
}

// if we click 'previous', we won't fail
assertNoProblem();
clickButtonWithText("Previous");
assertNoProblem();
assertContent("Title 1", "Content 1");

}

/**
* We can navigate through it, then press reset.
*
* @throws Exception
*/
public void testNavigateThroughThenReset() throws Exception {

beginAtSitemapThenPage("Home");

// initial
assertContent("Title 1", "Content 1");

// navigate
for (int i = 2; i <= 5; i++) {
clickButtonWithText("Next");
assertContent("Title " + i, "Content " + i);
}

// click reset
assertNoProblem();
clickButtonWithText("First");
assertNoProblem();
assertContent("Title 1", "Content 1");

// if we click 'previous', we won't fail
clickButtonWithText("Previous");
assertNoProblem();
assertContent("Title 1", "Content 1");

}

/**
* We can navigate through it, then reload the page; the
* results will remain.
*
* @throws Exception
*/
public void testNavigateThroughThenReload() throws Exception {

IFile sitemap = beginAtSitemapThenPage("Home");

// initial
assertContent("Title 1", "Content 1");

// navigate
for (int i = 2; i <= 5; i++) {
clickButtonWithText("Next");
assertContent("Title " + i, "Content " + i);
}

// reload the page
reloadPage(sitemap, "Home");

// still on the same page
assertContent("Title 5", "Content 5");

// restart the session
restartSession(sitemap, "Home");

// still on the same page
assertContent("Title 5", "Content 5");

}

/**
* Test 'Last' then 'First'
*
* @throws Exception
*/
public void testLastFirst() throws Exception {

beginAtSitemapThenPage("Home");

// initial
assertContent("Title 1", "Content 1");

// last
clickButtonWithText("Last");
assertNoProblem();
assertContent("Title 5", "Content 5");

// first
clickButtonWithText("First");
assertNoProblem();
assertContent("Title 1", "Content 1");

// first
clickButtonWithText("First");
assertNoProblem();
assertContent("Title 1", "Content 1");

}

/**
* Check the given content on the page.
*
* <p>Because we are using a SetWire, we cannot select by TextField;
* we can only search for labels containing the given text.
*/
private void assertContent(String title, String content) {
assertLabelTextPresent(title);
assertLabelTextPresent(content);
}

private void assertResults(String results) {
assertLabelTextPresent(results);
}
private void assertNoResults(String results) {
assertLabelTextNotPresent(results);
}

/**
* Populate the database with ten news items. The SelectWire
* only selects the first 5.
*
* @param size
* @return
*/
@Override
protected List<String> getDatabaseInitialisers() {
List<String> s = new ArrayList<String>();
s.add("CREATE TABLE News_Item (generated_primary_key INTEGER PRIMARY KEY AUTOINCREMENT, title VARCHAR(64) NOT NULL, content VARCHAR(64) NOT NULL)");
for (int i = 1; i <= 10; i++) {
s.add("INSERT INTO News_Item (generated_primary_key, title, content) VALUES (" + i + ", 'Title " + i + "', 'Content " + i + "')");
}
return s;
}

}

Change log

r3072 by soundasleep on Aug 8, 2011   Diff
fixing references to old metamodel
elements across project documentation
Go to: 
Project members, sign in to write a code review

Older revisions

r2154 by soundasleep on May 10, 2010   Diff
removing all explicit definitions of
getDatabaseName(), since 'default.db'
is now used by default (r2152)
r1884 by soundasleep on Apr 11, 2010   Diff
adding definition of 'jump'
PrimitiveOperation
adding support for cached client-side
arbitrary Properties
implementing 'limit' argument of
...
r1882 by soundasleep on Apr 11, 2010   Diff
progress in implementing codegen test
case SelectWireManyPaginate
DomainObjectInstance.onChange events
are now fired when the SelectWire is
re-evaluated
...
All revisions of this file

File info

Size: 5515 bytes, 228 lines
Powered by Google Project Hosting