summaryrefslogtreecommitdiff
path: root/container-compiler-plugin/src/test/java/io
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-08-04 12:34:48 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-08-04 12:34:48 +0200
commit3d556bfcad3eb3face9db986aa570d6e2a059448 (patch)
tree6b1b47390c16edd24a6f23d5183f6a0301043dcb /container-compiler-plugin/src/test/java/io
parentc0c9c358e8703c1af917d7270adbb04160ad34b3 (diff)
downloadcontainer-playground-3d556bfcad3eb3face9db986aa570d6e2a059448.tar.gz
container-playground-3d556bfcad3eb3face9db986aa570d6e2a059448.tar.bz2
container-playground-3d556bfcad3eb3face9db986aa570d6e2a059448.tar.xz
container-playground-3d556bfcad3eb3face9db986aa570d6e2a059448.zip
wip
Diffstat (limited to 'container-compiler-plugin/src/test/java/io')
-rw-r--r--container-compiler-plugin/src/test/java/io/trygvis/container/compiler/ProcessorTest.java1
-rw-r--r--container-compiler-plugin/src/test/java/io/trygvis/persistence/EntityMirrorTest.java23
2 files changed, 12 insertions, 12 deletions
diff --git a/container-compiler-plugin/src/test/java/io/trygvis/container/compiler/ProcessorTest.java b/container-compiler-plugin/src/test/java/io/trygvis/container/compiler/ProcessorTest.java
index b8d022d..c661f8b 100644
--- a/container-compiler-plugin/src/test/java/io/trygvis/container/compiler/ProcessorTest.java
+++ b/container-compiler-plugin/src/test/java/io/trygvis/container/compiler/ProcessorTest.java
@@ -57,6 +57,7 @@ public class ProcessorTest {
}
assertThat(fileManager.codes.keySet()).containsOnly(
+ "io.trygvis.persistence.test.Sequences",
"io.trygvis.persistence.test.Session",
"io.trygvis.persistence.test.PersonDao");
assertThat(collector.getDiagnostics()).isEmpty();
diff --git a/container-compiler-plugin/src/test/java/io/trygvis/persistence/EntityMirrorTest.java b/container-compiler-plugin/src/test/java/io/trygvis/persistence/EntityMirrorTest.java
index 3f0f345..4eead41 100644
--- a/container-compiler-plugin/src/test/java/io/trygvis/persistence/EntityMirrorTest.java
+++ b/container-compiler-plugin/src/test/java/io/trygvis/persistence/EntityMirrorTest.java
@@ -28,21 +28,21 @@ public class EntityMirrorTest {
return new Object[][]{
new Object[]{
new FieldMirror[]{idString},
- "INSERT INTO my_table(id) VALUES(?);",
+ "INSERT INTO my_table(id) VALUES(nextval('id_seq'));",
"DELETE FROM my_table WHERE id=?;", format(
"CREATE TABLE my_table(%n" +
" id VARCHAR(1000) PRIMARY KEY%n" +
");")},
new Object[]{
new FieldMirror[]{idLong},
- "INSERT INTO my_table(id) VALUES(?);",
+ "INSERT INTO my_table(id) VALUES(nextval('id_seq'));",
"DELETE FROM my_table WHERE id=?;", format(
"CREATE TABLE my_table(%n" +
" id BIGINT PRIMARY KEY%n" +
");")},
new Object[]{
new FieldMirror[]{idLong, name},
- "INSERT INTO my_table(id, name) VALUES(?, ?);",
+ "INSERT INTO my_table(id, name) VALUES(nextval('id_seq'), ?);",
"DELETE FROM my_table WHERE id=?;", format(
"CREATE TABLE my_table(%n" +
" id BIGINT PRIMARY KEY,%n" +
@@ -50,7 +50,7 @@ public class EntityMirrorTest {
");")},
new Object[]{
new FieldMirror[]{idLong, ref},
- "INSERT INTO my_table(id, parent) VALUES(?, ?);",
+ "INSERT INTO my_table(id, parent) VALUES(nextval('id_seq'), ?);",
"DELETE FROM my_table WHERE id=?;", format(
"CREATE TABLE my_table(%n" +
" id BIGINT PRIMARY KEY,%n" +
@@ -66,22 +66,22 @@ public class EntityMirrorTest {
myTable.add(field);
}
- SqlUnitModel unit = new SqlUnitModel().add(myTable);
+ SqlUnitModel unit = new SqlUnitModel().add(myTable).add(new SequenceMirror("id_seq"));
- assertEquals(myTable.insertIntoSql(), insert);
+ assertEquals(myTable.insertIntoSql(unit), insert);
assertEquals(myTable.deleteFromSql(), delete);
assertEquals(myTable.createTableSql(unit), create);
}
@Test
public void testInsertIntoMethod() {
- eq(insertInto(idString),
+ eq(insertInto(name),
"try(java.sql.PreparedStatement stmt = con.prepareStatement(insertIntoSql)) {",
- " java.lang.String id = o.id;",
- " if(id == null) {",
+ " java.lang.String name = o.name;",
+ " if(name == null) {",
" stmt.setNull(1, java.sql.Types.VARCHAR);",
" } else {",
- " stmt.setString(1, o.id);",
+ " stmt.setString(1, o.name);",
" }",
" stmt.executeUpdate();",
"}");
@@ -110,8 +110,7 @@ public class EntityMirrorTest {
private MethodRef fromResultSet(FieldMirror... fields) {
EntityMirror myTable = new EntityMirror(new GeneratorConfiguration(), entityType, "my_table");
myTable.add(fields);
- SqlUnitModel unit = new SqlUnitModel().add(myTable);
- return myTable.fromResultSet(unit, new Imports());
+ return myTable.fromResultSet(new Imports());
}
private void eq(MethodRef m, String... expected) {