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
/**
*
*/
package org.openiaml.model.tests.codegen.model0_6;

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

import org.openiaml.model.tests.codegen.DatabaseCodegenTestCase;


/**
* Tests {@issue 219}. The underlying DomainIterator has a limit
* of 7 set.
*
* @example DomainIterator,Event
* Using the {@event onIterate} {@model Event} along with
* the {@model DomainIterator#currentPointer} {@model Value}.
*
*/
public class IteratorCurrentPointer extends DatabaseCodegenTestCase {

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

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

/**
* The DomainIterator will select the first element from the
* database. Also tests the initial value of {@model DomainIterator#currentPointer}.
*
* @throws Exception
*/
public void testInitialValues() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();

assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");

// pagination buttons are present
assertButtonPresentWithText("Next");
assertButtonPresentWithText("Previous");
assertButtonPresentWithText("First");
assertButtonPresentWithText("Last");

// test current pointer
assertInputTextFieldEquals("current pointer", "0");

}

/**
* Tests that navigation updates the current pointer.
*
* @throws Exception
*/
public void testNavigation() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();

assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertInputTextFieldEquals("current pointer", "0");

// click Next button
clickButtonWithText("Next");

assertLabelTextExactlyPresent("Title 2");
assertLabelTextExactlyPresent("Content 2");
assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertInputTextFieldEquals("current pointer", "1");

// click Next button
clickButtonWithText("Next");

assertLabelTextExactlyPresent("Title 3");
assertLabelTextExactlyPresent("Content 3");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertLabelTextNotPresent("Title 4");
assertLabelTextNotPresent("Content 4");
assertInputTextFieldEquals("current pointer", "2");

// click Previous button
clickButtonWithText("Previous");

assertLabelTextExactlyPresent("Title 2");
assertLabelTextExactlyPresent("Content 2");
assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertLabelTextNotPresent("Title 3");
assertLabelTextNotPresent("Content 3");
assertInputTextFieldEquals("current pointer", "1");

}

/**
* Tests that going previous of the first post does not change the pointer.
*
* @throws Exception
*/
public void testBeforeFirst() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();

// click First button
clickButtonWithText("Previous");

assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertInputTextFieldEquals("current pointer", "0");

// click Previous button
clickButtonWithText("Previous");

// nothing has changed
assertLabelTextExactlyPresent("Title 1");
assertLabelTextExactlyPresent("Content 1");
assertLabelTextNotPresent("Title 2");
assertLabelTextNotPresent("Content 2");
assertInputTextFieldEquals("current pointer", "0");
}

/**
* Tests that going next of the last post does not change the pointer.
*
* @throws Exception
*/
public void testAfterLast() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();

clickButtonWithText("Last");

assertLabelTextExactlyPresent("Title 7");
assertLabelTextExactlyPresent("Content 7");
assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertInputTextFieldEquals("current pointer", "6");

// click Next button
clickButtonWithText("Next");

// nothing has changed
assertLabelTextExactlyPresent("Title 7");
assertLabelTextExactlyPresent("Content 7");
assertLabelTextNotPresent("Title 1");
assertLabelTextNotPresent("Content 1");
assertInputTextFieldEquals("current pointer", "6");
}

/**
* Populate the database with twenty blog posts.
*/
@Override
protected List<String> getDatabaseInitialisers() {
List<String> s = new ArrayList<String>();
s.add("CREATE TABLE Blog (generated_primary_key INTEGER PRIMARY KEY AUTOINCREMENT, title VARCHAR(64) NOT NULL, content VARCHAR(64) NOT NULL)");
for (int i = 1; i <= 20; i++) {
s.add("INSERT INTO Blog (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

r2694 by soundasleep on Apr 26, 2011   Diff
 issue 219 : adding codegen test case
for DomainIterator.currentPointer
property
All revisions of this file

File info

Size: 5375 bytes, 186 lines
Powered by Google Project Hosting