diff options
Diffstat (limited to 'container-compiler-plugin/src/test')
4 files changed, 25 insertions, 17 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 4fa9e87..e7affa3 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 @@ -41,7 +41,6 @@ public class ProcessorTest { "io.trygvis.persistence.test.basic.ChildEntity", }, new String[]{ - "io.trygvis.persistence.test.basic.Sequences", "io.trygvis.persistence.test.basic.BasicSqlSession", "io.trygvis.persistence.test.basic.BasicSqlSessionFactory", "io.trygvis.persistence.test.basic.PersonDao", @@ -52,9 +51,9 @@ public class ProcessorTest { }, new Object[]{ new String[]{ "io.trygvis.persistence.test.inheritance.package-info", - "io.trygvis.persistence.test.inheritance.A",}, + "io.trygvis.persistence.test.inheritance.A", + }, new String[]{ - "io.trygvis.persistence.test.inheritance.Sequences", "io.trygvis.persistence.test.inheritance.InheritanceSqlSession", "io.trygvis.persistence.test.inheritance.InheritanceSqlSessionFactory", "io.trygvis.persistence.test.inheritance.DDao", 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 c978ec9..a76c640 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 @@ -11,13 +11,14 @@ import org.testng.annotations.Test; import java.io.CharArrayWriter; import java.io.PrintWriter; +import java.util.Collections; import static io.trygvis.container.compiler.Utils.EOL; import static io.trygvis.persistence.FieldMirror.FieldType.PRIMITIVE; import static io.trygvis.persistence.FieldMirror.FieldType.REFERENCE; -import static io.trygvis.persistence.FieldMirror.GetterType; -import static io.trygvis.persistence.FieldMirror.SetterType; import static java.lang.String.format; +import static javax.persistence.AccessType.FIELD; +import static javax.persistence.AccessType.PROPERTY; import static org.testng.Assert.assertEquals; public class EntityMirrorTest { @@ -25,19 +26,19 @@ public class EntityMirrorTest { GeneratorConfiguration generatorConfiguration = new GeneratorConfiguration(); static TypeRef entityType = new TypeRef("Wat"); - static FieldMirror idLong = new FieldMirror(PRIMITIVE, SetterType.CONSTRUCTOR, GetterType.FIELD, + static FieldMirror idLong = new FieldMirror(PRIMITIVE, true, FIELD, FIELD, new TypeRef(Long.class), "id", "id", true, false, true); - static FieldMirror idString = new FieldMirror(PRIMITIVE, SetterType.CONSTRUCTOR, GetterType.FIELD, + static FieldMirror idString = new FieldMirror(PRIMITIVE, true, FIELD, FIELD, new TypeRef(String.class), "id", "id", true, false, true); - static FieldMirror idMethod = new FieldMirror(PRIMITIVE, SetterType.CONSTRUCTOR, GetterType.METHOD, + static FieldMirror idMethod = new FieldMirror(PRIMITIVE, true, PROPERTY, PROPERTY, new TypeRef(Long.class), "id", "id", true, false, true); - static FieldMirror name = new FieldMirror(PRIMITIVE, SetterType.CONSTRUCTOR, GetterType.FIELD, + static FieldMirror name = new FieldMirror(PRIMITIVE, true, FIELD, FIELD, new TypeRef(String.class), "name", "name", false, false, false); - static FieldMirror age = new FieldMirror(PRIMITIVE, SetterType.CONSTRUCTOR, GetterType.FIELD, + static FieldMirror age = new FieldMirror(PRIMITIVE, true, FIELD, FIELD, new TypeRef(Integer.class), "age", "age", false, true, false); - static FieldMirror year = new FieldMirror(PRIMITIVE, SetterType.CONSTRUCTOR, GetterType.METHOD, + static FieldMirror year = new FieldMirror(PRIMITIVE, true, PROPERTY, PROPERTY, new TypeRef(Integer.class), "year", "year", false, true, false); - static FieldMirror ref = new FieldMirror(REFERENCE, SetterType.CONSTRUCTOR, GetterType.FIELD, + static FieldMirror ref = new FieldMirror(REFERENCE, true, FIELD, FIELD, entityType, "parent", "parent", false, false, false); @DataProvider(name = "insertIntoSql", parallel = true) @@ -78,7 +79,8 @@ public class EntityMirrorTest { @Test(dataProvider = "insertIntoSql") public void testInsertIntoSql(FieldMirror[] fields, String insert, String delete, String create) throws Exception { - EntityMirror myTable = new EntityMirror(new GeneratorConfiguration(), entityType, true, null, "my_table"); + EntityMirror myTable = new EntityMirror(new GeneratorConfiguration(), entityType, true, null, null, + Collections.<String>emptyList(), "my_table"); for (FieldMirror field : fields) { myTable.add(field); } @@ -127,7 +129,8 @@ public class EntityMirrorTest { } private MethodRef insertInto(FieldMirror... fields) { - EntityMirror myTable = new EntityMirror(generatorConfiguration, entityType, true, null, "my_table"); + EntityMirror myTable = new EntityMirror(generatorConfiguration, entityType, true, null, null, + Collections.<String>emptyList(), "my_table"); myTable.add(fields); SqlUnitModel unit = new SqlUnitModel().add(myTable); return new DaoUtilsGenerator(unit, generatorConfiguration, myTable).insertInto(new Imports()); @@ -151,7 +154,8 @@ public class EntityMirrorTest { } private MethodRef delete(FieldMirror... fields) { - EntityMirror myTable = new EntityMirror(new GeneratorConfiguration(), entityType, true, null, "my_table"); + EntityMirror myTable = new EntityMirror(new GeneratorConfiguration(), entityType, true, null, null, + Collections.<String>emptyList(), "my_table"); myTable.add(fields); SqlUnitModel unit = new SqlUnitModel().add(myTable); return new DaoUtilsGenerator(unit, generatorConfiguration, myTable).delete(new Imports()); @@ -181,7 +185,8 @@ public class EntityMirrorTest { } private MethodRef deleteById(FieldMirror... fields) { - EntityMirror myTable = new EntityMirror(new GeneratorConfiguration(), entityType, true, null, "my_table"); + EntityMirror myTable = new EntityMirror(new GeneratorConfiguration(), entityType, true, null, null, + Collections.<String>emptyList(), "my_table"); myTable.add(fields); SqlUnitModel unit = new SqlUnitModel().add(myTable); return new DaoUtilsGenerator(unit, generatorConfiguration, myTable).deleteById(new Imports()); diff --git a/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/ChildEntity.java b/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/ChildEntity.java index 208ee9a..29ce1b2 100644 --- a/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/ChildEntity.java +++ b/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/ChildEntity.java @@ -1,5 +1,7 @@ package io.trygvis.persistence.test.basic; +import io.trygvis.persistence.sql.SqlConstructor; + import javax.persistence.Entity; @Entity @@ -8,6 +10,7 @@ public class ChildEntity extends ParentEntity { public final int favoriteNumber; + @SqlConstructor public ChildEntity(Long id, String name, int favoriteNumber) { super(id); this.name = name; diff --git a/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/Person.java b/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/Person.java index 3cbdb84..6b1efb5 100644 --- a/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/Person.java +++ b/container-compiler-plugin/src/test/resources/io/trygvis/persistence/test/basic/Person.java @@ -30,7 +30,8 @@ public class Person { // @OrderBy("birthDate asc") // private List<Person> children = new ArrayList<>(); - public Person(Long id, Date birthDate, Person mother, Gender gender) { + // The parameters is not in the same order as the fields. + public Person(Long id, Person mother, Date birthDate, Gender gender) { this.id = id; this.birthDate = birthDate; this.mother = mother; |