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

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

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

/**
* We can use a QueryParameter as a Parameter to a DomainIterator, in order
* to select an instance from a domain store.
*
* @example QueryParameter,DomainIterator
* Using a {@model QueryParameter} from
* the current request URI to select
* an {@model DomainIterator object instance}.
* @author jmwright
*
*/
public class QueryParameterAsParameter extends DatabaseCodegenTestCase {

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

@Override
protected List<String> getDatabaseInitialisers() {
List<String> s = new ArrayList<String>();
s.add("CREATE TABLE User (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(64) NOT NULL, email VARCHAR(64) NOT NULL, password VARCHAR(64) NOT NULL)");
s.add("INSERT INTO User (id, name, email, password) VALUES (1, 'User Default', 'default@jevon.org', 'test1')");
s.add("INSERT INTO User (id, name, email, password) VALUES (2, 'User Two', 'target@jevon.org', 'test2')");
s.add("INSERT INTO User (id, name, email, password) VALUES (4, 'User Three', 'test3@jevon.org', 'test3')");
s.add("INSERT INTO User (id, name, email, password) VALUES (8, 'User Four', 'test4@jevon.org', 'test4')");
return s;
}

/**
* By default, it will select ID = 1.
*/
public void testDefault() throws Exception {
beginAtSitemapThenPage("Home");

{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "User Default");
}

{
String field = getLabelIDForText("email");
assertLabeledFieldEquals(field, "default@jevon.org");
}
}

/**
* Select a particular user.
*/
public void testSelect() throws Exception {
beginAtSitemapThenPageQuery("Home", "user_id=4");

{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "User Three");
}

{
String field = getLabelIDForText("email");
assertLabeledFieldEquals(field, "test3@jevon.org");
}
}

/**
* We can select a user, edit the fields, and reload
* with the same parameter, and the database object will not
* have changed (because autosave is false)
*
* @implementation If a {@model InputForm} representing a selected
* {@model DomainInstance} changes, the changes will be saved.
*/
public void testChangable() throws Exception {
beginAtSitemapThenPageQuery("Home", "user_id=8");

{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "User Four");

// change it
setLabeledFormElementField(field, "a changed value");
assertLabeledFieldEquals(field, "a changed value");
}

// reload
beginAtSitemapThenPageQuery("Home", "user_id=8");

// hasn't changed
{
String field = getLabelIDForText("name");
assertLabeledFieldEquals(field, "User Four");
}

}

}

Change log

r3068 by soundasleep on Aug 8, 2011   Diff
improving modeldoc documentation across
inference rules, codegen templates, ecore,
and additional documentation includes
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)
r1584 by soundasleep on Feb 23, 2010   Diff
adding missing @Override annotations
r1561 by soundasleep on Feb 22, 2010   Diff
replacing '@operational' modeldoc tag
with '@implementation'
fixing some broken '@link' javadoc
tags, which were causing problems with
generated modeldoc
...
All revisions of this file

File info

Size: 3108 bytes, 107 lines
Powered by Google Project Hosting