Search in sources :

Example 11 with JavaWriter

use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.

the class EmbeddableSerializerTest method no_package.

@Test
public void no_package() throws IOException {
    SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", 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 QEntity extends BeanPath<Entity> {"));
    CompileUtils.assertCompiles("QEntity", writer.toString());
}
Also used : JavaWriter(com.mysema.codegen.JavaWriter) Test(org.junit.Test)

Example 12 with JavaWriter

use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.

the class EmbeddableSerializerTest 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(entityType, queryTypeFactory.create(entityType));
    typeMappings.register(subType, queryTypeFactory.create(subType));
    serializer.serialize(subType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
    CompileUtils.assertCompiles("QEntity2", writer.toString());
}
Also used : JavaWriter(com.mysema.codegen.JavaWriter) Test(org.junit.Test)

Example 13 with JavaWriter

use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.

the class EmbeddableSerializerTest 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());
}
Also used : JavaWriter(com.mysema.codegen.JavaWriter) Test(org.junit.Test)

Example 14 with JavaWriter

use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.

the class EmbeddableSerializerTest method delegates.

@Test
public void delegates() throws IOException {
    SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", false, false);
    EntityType entityType = new EntityType(type);
    Delegate delegate = new Delegate(type, type, "test", Collections.<Parameter>emptyList(), Types.STRING);
    entityType.addDelegate(delegate);
    typeMappings.register(entityType, queryTypeFactory.create(entityType));
    serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
    assertTrue(writer.toString().contains("return Entity.test(this);"));
    CompileUtils.assertCompiles("QEntity", writer.toString());
}
Also used : JavaWriter(com.mysema.codegen.JavaWriter) Test(org.junit.Test)

Example 15 with JavaWriter

use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.

the class EntitySerializerTest method no_package.

@Test
public void no_package() throws IOException {
    SimpleType type = new SimpleType(TypeCategory.ENTITY, "Entity", "", "Entity", 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 QEntity extends EntityPathBase<Entity> {"));
    CompileUtils.assertCompiles("QEntity", writer.toString());
}
Also used : JavaWriter(com.mysema.codegen.JavaWriter) Test(org.junit.Test)

Aggregations

JavaWriter (com.mysema.codegen.JavaWriter)36 Test (org.junit.Test)32 CodeWriter (com.mysema.codegen.CodeWriter)3 StringWriter (java.io.StringWriter)3 ScalaWriter (com.mysema.codegen.ScalaWriter)2 SimpleType (com.mysema.codegen.model.SimpleType)2 Writer (java.io.Writer)2 EnumMap (java.util.EnumMap)2 Map (java.util.Map)2 ClassType (com.mysema.codegen.model.ClassType)1 Type (com.mysema.codegen.model.Type)1 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 DeclaredType (javax.lang.model.type.DeclaredType)1 NoType (javax.lang.model.type.NoType)1 JavaFileObject (javax.tools.JavaFileObject)1