1
2
3
4
5
6
7 package test.org.asyrinx.joey.gen.command.rdb;
8
9 import junit.framework.TestCase;
10
11 import org.asyrinx.joey.gen.command.rdb.StandardCommands;
12 import org.asyrinx.joey.gen.model.command.Command;
13 import org.asyrinx.joey.gen.model.rdb.Column;
14 import org.asyrinx.joey.gen.model.rdb.Database;
15 import org.asyrinx.joey.gen.model.rdb.Databases;
16 import org.asyrinx.joey.gen.model.rdb.Table;
17
18 /***
19 * @author takeshi
20 */
21 public class StandardCommandsTest extends TestCase {
22
23 public static void main(String[] args) {
24 junit.swingui.TestRunner.run(StandardCommandsTest.class);
25 }
26
27 public void testExecute() {
28 final Databases databases = new Databases();
29 final Database db1 = new Database(databases, "db1");
30 db1.getOptions().put("javaPackage", "org.asyrinx.joey.sample");
31
32 final Table t_party = new Table(db1, "party", "パーティ");
33 final Column c_party_party_id = new Column(t_party, "party_id", "BIGINT", "0", true, true, "0");
34 new Column(t_party, "name", "VARCHAR", "20", true, false, null);
35
36 final Table t_role = new Table(db1, "role", "ロール");
37 final Column c_role_role_id = new Column(t_role, "role_id", "BIGINT", "0", true, true, "0");
38 final Column colPartyId = new Column(t_role, "party_id", "BIGINT", "0", true, false, "0");
39 colPartyId.setFk("party.party_id");
40
41 final Table t_user = new Table(db1, "system_user", "システムユーザ");
42 t_user.setExtends("role");
43 final Column c_user_system_user_id = new Column(t_user, "system_user_id", "BIGINT", "0", true, true, "0");
44 new Column(t_user, "values", "VARCHAR", "20", true, false, null);
45
46 final Command command = new StandardCommands();
47 command.execute(databases);
48
49 assertEquals(2, t_party.getColumns().size());
50 assertEquals(1, t_party.getPrimaryKey().size());
51 assertEquals(c_party_party_id, t_party.getPrimaryKey().getEntry(0).getColumn());
52
53 assertEquals(2, t_role.getColumns().size());
54 assertEquals(1, t_role.getPrimaryKey().size());
55 assertEquals(c_role_role_id, t_role.getPrimaryKey().getEntry(0).getColumn());
56
57 assertEquals(3, t_user.getColumns().size());
58 assertEquals(1, t_user.getPrimaryKey().size());
59 assertEquals(c_user_system_user_id, t_user.getPrimaryKey().getEntry(0).getColumn());
60 }
61
62 }