use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class BeanSerializerTest method annotated_property_not_serialized.
@Test
public void annotated_property_not_serialized() throws IOException {
Property property = new Property(type, "entityField", type);
property.addAnnotation(new QueryEntityImpl());
type.addProperty(property);
BeanSerializer serializer = new BeanSerializer(false);
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
String str = writer.toString();
assertFalse(str.contains("import com.querydsl.core.annotations.QueryEntity;"));
assertFalse(str.contains("@QueryEntity"));
}
use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EmbeddableSerializerTest method originalCategory.
@Test
public void originalCategory() throws IOException {
Map<TypeCategory, String> categoryToSuperClass = new EnumMap<TypeCategory, String>(TypeCategory.class);
categoryToSuperClass.put(TypeCategory.COMPARABLE, "ComparablePath<Entity>");
categoryToSuperClass.put(TypeCategory.ENUM, "EnumPath<Entity>");
categoryToSuperClass.put(TypeCategory.DATE, "DatePath<Entity>");
categoryToSuperClass.put(TypeCategory.DATETIME, "DateTimePath<Entity>");
categoryToSuperClass.put(TypeCategory.TIME, "TimePath<Entity>");
categoryToSuperClass.put(TypeCategory.NUMERIC, "NumberPath<Entity>");
categoryToSuperClass.put(TypeCategory.STRING, "StringPath");
categoryToSuperClass.put(TypeCategory.BOOLEAN, "BooleanPath");
for (Map.Entry<TypeCategory, String> entry : categoryToSuperClass.entrySet()) {
StringWriter w = new StringWriter();
SimpleType type = new SimpleType(entry.getKey(), "Entity", "", "Entity", false, false);
EntityType entityType = new EntityType(type);
typeMappings.register(entityType, queryTypeFactory.create(entityType));
serializer.serialize(entityType, SimpleSerializerConfig.DEFAULT, new JavaWriter(w));
assertTrue(entry.getValue() + " is missing from " + w, w.toString().contains("public class QEntity extends " + entry.getValue() + " {"));
}
}
use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EmbeddableSerializerTest method empty.
@Test
public void empty() 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));
CompileUtils.assertCompiles("QEntity", writer.toString());
}
use of com.mysema.codegen.JavaWriter in project querydsl by querydsl.
the class EmbeddableSerializerTest 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 EmbeddableSerializerTest 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 BeanPath<Locale> {"));
CompileUtils.assertCompiles("QLocale", writer.toString());
}
Aggregations