use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EntitySerializerTest method include.
@Test
public void include() throws IOException {
SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false);
EntityType entityType = new EntityType(type);
entityType.addProperty(new Property(entityType, "b", new ClassType(TypeCategory.BOOLEAN, Boolean.class)));
entityType.addProperty(new Property(entityType, "c", new ClassType(TypeCategory.COMPARABLE, String.class)));
//entityType.addProperty(new Property(entityType, "cu", new ClassType(TypeCategory.CUSTOM, PropertyType.class)));
entityType.addProperty(new Property(entityType, "d", new ClassType(TypeCategory.DATE, Date.class)));
entityType.addProperty(new Property(entityType, "e", new ClassType(TypeCategory.ENUM, PropertyType.class)));
entityType.addProperty(new Property(entityType, "dt", new ClassType(TypeCategory.DATETIME, Date.class)));
entityType.addProperty(new Property(entityType, "i", new ClassType(TypeCategory.NUMERIC, Integer.class)));
entityType.addProperty(new Property(entityType, "s", new ClassType(TypeCategory.STRING, String.class)));
entityType.addProperty(new Property(entityType, "t", new ClassType(TypeCategory.TIME, Time.class)));
EntityType subType = new EntityType(new SimpleType(TypeCategory.ENTITY, "Entity2", "", "Entity2", false, false));
subType.include(new Supertype(type, entityType));
typeMappings.register(subType, queryTypeFactory.create(subType));
serializer.serialize(subType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
CompileUtils.assertCompiles("QEntity2", writer.toString());
}
use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EntitySerializerTest method superType.
@Test
public void superType() throws IOException {
EntityType superType = new EntityType(new SimpleType(TypeCategory.ENTITY, "Entity2", "", "Entity2", false, false));
SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false);
EntityType entityType = new EntityType(type, Collections.singleton(new Supertype(superType, superType)));
typeMappings.register(superType, queryTypeFactory.create(superType));
typeMappings.register(entityType, queryTypeFactory.create(entityType));
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("public final QEntity2 _super = new QEntity2(this);"));
//CompileUtils.assertCompiles("QEntity", writer.toString());
}
use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EntitySerializerTest method correct_superclass.
@Test
public void correct_superclass() throws IOException {
SimpleType type = new SimpleType(TypeCategory.ENTITY, "java.util.Locale", "java.util", "Locale", false, false);
EntityType entityType = new EntityType(type);
typeMappings.register(entityType, queryTypeFactory.create(entityType));
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("public class QLocale extends EntityPathBase<Locale> {"));
CompileUtils.assertCompiles("QLocale", writer.toString());
}
use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EntitySerializerTest method properties.
@Test
public void properties() throws IOException {
SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false);
EntityType entityType = new EntityType(type);
entityType.addProperty(new Property(entityType, "b", new ClassType(TypeCategory.BOOLEAN, Boolean.class)));
entityType.addProperty(new Property(entityType, "c", new ClassType(TypeCategory.COMPARABLE, String.class)));
//entityType.addProperty(new Property(entityType, "cu", new ClassType(TypeCategory.CUSTOM, PropertyType.class)));
entityType.addProperty(new Property(entityType, "d", new ClassType(TypeCategory.DATE, Date.class)));
entityType.addProperty(new Property(entityType, "e", new ClassType(TypeCategory.ENUM, PropertyType.class)));
entityType.addProperty(new Property(entityType, "dt", new ClassType(TypeCategory.DATETIME, Date.class)));
entityType.addProperty(new Property(entityType, "i", new ClassType(TypeCategory.NUMERIC, Integer.class)));
entityType.addProperty(new Property(entityType, "s", new ClassType(TypeCategory.STRING, String.class)));
entityType.addProperty(new Property(entityType, "t", new ClassType(TypeCategory.TIME, Time.class)));
typeMappings.register(entityType, queryTypeFactory.create(entityType));
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
CompileUtils.assertCompiles("QEntity", writer.toString());
}
use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EntitySerializerTest method javadocs_for_innerClass.
@Test
public void javadocs_for_innerClass() throws IOException {
EntityType entityType = new EntityType(new ClassType(Entity.class));
typeMappings.register(entityType, queryTypeFactory.create(entityType));
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("QEntitySerializerTest_Entity is a Querydsl query type for Entity"));
CompileUtils.assertCompiles("QEntitySerializerTest_Entity", writer.toString());
}
Aggregations