summaryrefslogtreecommitdiff
path: root/container-compiler-plugin/src/test/java/io
diff options
context:
space:
mode:
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) {