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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
/**
*
*/
package org.openiaml.model.tests.codegen.model0_4;

import org.eclipse.core.resources.IFile;
import org.openiaml.model.tests.CodegenTestCase;

import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;

/**
* Test the code generation of domain inheritance
* when editing. In particular, this test case does
* not set up an initial database.
*
* @example DomainType
* Creating a new {@model DomainInstance instance} of an inherited {@model DomainType}.
*
* @implementation DomainInstance,DomainIterator,DomainAttribute
* New {@model DomainInstance instance}s of {@model DomainType}s which {@model ExtendsEdge extend others} can be created;
* all of their inherited {@model DomainAttribute attributes} are accessible.
*
* @implementation DomainInstance,DomainIterator
* A new {@model DomainInstance instance} of an {@model ExtendsEdge inherited} {@model DomainType} with {@model DomainIterator#autosave}=false
* can have its {@model DomainAttribute attributes} modified before being saved.
*
* @implementation SyncWire,InputForm,ExtendsEdge
* A new {@model DomainType} with {@model ExtendsEdge inheritance}
* connected to an {@model InputForm} with
* a {@model SyncWire} will populate the InputForm with an
* {@model InputTextField}
* for all inherited {@model DomainAttribute}s.
*
* @example DomainInstance,DomainIterator,DomainType,Session
* Creating a new {@model DomainInstance instance} of an inherited {@model DomainType},
* accessible only within a {@model Session}.
*
* @implementation Session,DomainIterator
* If a new {@model DomainIterator instance} of an {@model ExtendsEdge inherited}
* {@model DomainType} is created within
* a {@model Session}, then the modification of this instance is limited to
* within the Session.
*
* @author jmwright
*
*/
public class DomainInheritanceEditing extends CodegenTestCase {

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

/**
* Just visiting the home page should not create a problem.
*
* @throws Exception
*/
public void testHome() throws Exception {
beginAtSitemapThenPage("Home");
assertNoProblem();
}

/**
* Since the initial database is empty,
* we cannot visit Person.
*
* @throws Exception
*/
public void testPersonError() throws Exception {
try {
beginAtSitemapThenPage("get person");
fail("Should not have been able to access 'person' page");
assertNoProblem();
} catch (FailingHttpStatusCodeException e) {
// expected
checkExceptionContains(e, "No results found for query 'name = ?'");
}
}

/**
* Since the initial database is empty,
* we cannot visit Student.
* Select student: enrolled = 'yesterday'
*
* @throws Exception
*/
public void testStudentError() throws Exception {
try {
beginAtSitemapThenPage("get student");
fail("Should not have been able to access 'student' page");
} catch (FailingHttpStatusCodeException e) {
// expected
checkExceptionContains(e, "No results found for query 'enrolled = ?'");
}
}

/**
* We create a new Person; we can then view this
* Person.
*
* @throws Exception
*/
public void testCreatePerson() throws Exception {
IFile sitemap = beginAtSitemapThenPage("create a new person");
assertNoProblem();

String newName = "Test Name";
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newName);
}
// this primary key is not rendered, because it's
// a primary key
assertHasNotLabelIDForText("id");

// it is autosave, so we can immediately view the person page
gotoSitemapThenPage(sitemap, "get person");
assertNoProblem();

String name = getLabelIDForText("name");
assertLabeledFieldEquals(name, newName);
}

/**
* We create a new person, but it does not
* have the correct name, so we cannot view it
* without an error.
*
* @throws Exception
*/
public void testCreatePersonInvalid() throws Exception {
IFile sitemap = beginAtSitemapThenPage("create a new person");
assertNoProblem();

String newName = "Test Name 2";
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newName);
}
// this primary key is not rendered, because it's
// a primary key
assertHasNotLabelIDForText("id");

// it is autosave, so we can immediately try to
// view the new person, but we will get an error
try {
gotoSitemapWithProblem(sitemap, "get person");
fail("Expected to not be able to go to 'person' page");
} catch (FailingHttpStatusCodeException e) {
// expected
checkExceptionContains(e, "No results found for query 'name = ?'");
}
}

/**
* We create a new Student; but without explicitly
* saving the new instance, we cannot view it
* until it is saved.
*
* @throws Exception
*/
public void testCreateStudent() throws Exception {
IFile sitemap = beginAtSitemapThenPage("create a new student without autosave");
assertNoProblem();

String newName = "Test Student";
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newName);
}

String newEnrolled = "yesterday";
{
String field = getLabelIDForText("enrolled");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newEnrolled);
}

// autosave is off, so this page will not be saved
try {
gotoSitemapWithProblem(sitemap, "get student");
fail("Expected to not be able to go to 'student' page");
} catch (FailingHttpStatusCodeException e) {
// expected
checkExceptionContains(e, "No results found for query 'enrolled = ?'");
}

// but we can go back and continue editing
gotoSitemapThenPage(sitemap, "create a new student without autosave");
assertNoProblem();

// the fields are still filled in
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, newName);
}
{
String field = getLabelIDForText("enrolled");
assertLabeledFieldEquals(field, newEnrolled);
}
assertButtonPresentWithText("save student");
clickButtonWithText("save student");
assertNoProblem();

// we can now view the student
gotoSitemapThenPage(sitemap, "get student");
assertNoProblem();

{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, newName);
}
{
String field = getLabelIDForText("enrolled");
assertLabeledFieldEquals(field, newEnrolled);
}
}

/**
* We can create a Doctoral and view it.
*
* @throws Exception
*/
public void testCreateDoctoral() throws Exception {
IFile sitemap = beginAtSitemapThenPage("create a new doctoral");
assertNoProblem();

String newName = "Test Student";
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newName);
}

String newEnrolled = "yesterday";
{
String field = getLabelIDForText("enrolled");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newEnrolled);
}

String newQualification = "bsc";
{
String field = getLabelIDForText("qualification");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newQualification);
}

String newDegree = "science";
{
String field = getLabelIDForText("degree");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newDegree);
}

// autosave is on, so we can immediately visit it
gotoSitemapThenPage(sitemap, "get doctoral");
assertNoProblem();

checkDoctoralForm();

}

/**
* A specific Doctoral instance we are checking for.
*
* @throws Exception
*/
private void checkDoctoralForm() throws Exception {
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "Test Student");
}

{
String field = getLabelIDForText("enrolled");
assertLabeledFieldEquals(field, "yesterday");
}

{
String field = getLabelIDForText("qualification");
assertLabeledFieldEquals(field, "bsc");
}

{
String field = getLabelIDForText("degree");
assertLabeledFieldEquals(field, "science");
}
}

/**
* If we create a new Doctoral, we can reset the session
* and create a new Doctoral student.
* @throws Exception
*/
public void testCreateDoctoralSession() throws Exception {
testCreateDoctoral();

// this will also reset the session
IFile sitemap = beginAtSitemapThenPage("create a new doctoral");
assertNoProblem();

String newName = "a new student";
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newName);
}

String newEnrolled = "tomorrow";
{
String field = getLabelIDForText("enrolled");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newEnrolled);
}

String newQualification = "ba";
{
String field = getLabelIDForText("qualification");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newQualification);
}

String newDegree = "environmental studies";
{
String field = getLabelIDForText("degree");
assertLabeledFieldEquals(field, "");
setLabeledFormElementField(field, newDegree);
}

// we can immediately visit the doctoral page, but the
// old doctoral object will still be rendered
gotoSitemapThenPage(sitemap, "get doctoral");
assertNoProblem();

checkDoctoralForm();
}

}

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

r3068 by soundasleep on Aug 8, 2011   Diff
improving modeldoc documentation
across inference rules, codegen
templates, ecore, and additional
documentation includes
r2127 by soundasleep on May 6, 2010   Diff
removing a test that is no longer
necessary
r2054 by soundasleep on Apr 27, 2010   Diff
 issue 180 : merging 'exists?' into
'empty' Condition: updating inference
rules and test cases
All revisions of this file

File info

Size: 9896 bytes, 344 lines
Powered by Google Project Hosting