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.CheckIndexEntry;
12 import org.asyrinx.joey.gen.model.command.ValidationError;
13 import org.asyrinx.joey.gen.model.rdb.Column;
14 import org.asyrinx.joey.gen.model.rdb.Index;
15 import org.asyrinx.joey.gen.model.rdb.IndexEntry;
16 import org.asyrinx.joey.gen.model.rdb.Table;
17
18 /***
19 * @author akima
20 */
21 public class CheckIndexEntryTest extends TestCase {
22
23 public static void main(String[] args) {
24 junit.swingui.TestRunner.run(CheckIndexEntryTest.class);
25 }
26
27 public void testNormal() {
28 final Table table1 = new Table("table1");
29 new Column(table1, "col1-1", "int");
30 new Column(table1, "col1-2", "int");
31 new Column(table1, "col1-3", "int");
32 final Index index1_1 = new Index(table1, "named_index_1");
33 final IndexEntry entry1_1_1 = new IndexEntry(index1_1, "col1");
34 final Index index1_2 = new Index(table1);
35 final IndexEntry entry1_2_1 = new IndexEntry(index1_2, "");
36 final IndexEntry entry1_2_2 = new IndexEntry(index1_2, "col1-1");
37
38 try {
39 new CheckIndexEntry().execute(table1);
40
41
42 fail();
43 } catch (ValidationError e) {
44 assertEquals(entry1_1_1, e.getElement());
45 } catch (Throwable e) {
46 e.printStackTrace();
47 fail();
48 }
49
50 entry1_1_1.setName("col1-2");
51 try {
52 new CheckIndexEntry().execute(table1);
53 fail();
54 } catch (ValidationError e) {
55 assertEquals(entry1_2_1, e.getElement());
56 } catch (Throwable e) {
57 e.printStackTrace();
58 fail();
59 }
60
61 entry1_2_1.setName("col1-3");
62 try {
63 new CheckIndexEntry().execute(table1);
64 } catch (Throwable e) {
65 e.printStackTrace();
66 fail();
67 }
68
69 }
70
71 }