use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class PackageSuffixTest method correct_imports.
@Test
public void correct_imports() throws IOException {
SimpleType type = new SimpleType(TypeCategory.ENTITY, "test.Entity", "test", "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("import test.Entity;"));
assertTrue(writer.toString().contains("public class QEntity extends EntityPathBase<Entity> {"));
}
use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class ProjectionSerializerTest method customGeneratedAnnotation.
@Test
public void customGeneratedAnnotation() throws IOException {
Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false);
EntityType type = new EntityType(typeModel);
Writer writer = new StringWriter();
ProjectionSerializer serializer = new DefaultProjectionSerializer(new JavaTypeMappings(), Generated.class);
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
String generatedSource = writer.toString();
assertThat(generatedSource, containsString("import com.querydsl.core.annotations.Generated"));
assertThat(generatedSource, containsString("@Generated(\"com.querydsl.codegen.DefaultProjectionSerializer\")\npublic class"));
}
use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class ProjectionSerializerTest method defaultGeneratedAnnotation.
@Test
public void defaultGeneratedAnnotation() throws IOException {
Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false);
EntityType type = new EntityType(typeModel);
Writer writer = new StringWriter();
ProjectionSerializer serializer = new DefaultProjectionSerializer(new JavaTypeMappings());
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
String generatedSource = writer.toString();
assertThat(generatedSource, containsString(String.format("import %s;", GeneratedAnnotationResolver.resolveDefault().getName())));
assertThat(generatedSource, containsString("@Generated(\"com.querydsl.codegen.DefaultProjectionSerializer\")\npublic class"));
}
use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class ProjectionSerializerTest method constructors.
@Test
public void constructors() throws IOException {
Type typeModel = new SimpleType(TypeCategory.ENTITY, "com.querydsl.DomainClass", "com.querydsl", "DomainClass", false, false);
EntityType type = new EntityType(typeModel);
// constructor
Parameter firstName = new Parameter("firstName", Types.STRING);
Parameter lastName = new Parameter("lastName", Types.STRING);
Parameter age = new Parameter("age", Types.INTEGER);
type.addConstructor(new Constructor(Arrays.asList(firstName, lastName, age)));
Writer writer = new StringWriter();
ProjectionSerializer serializer = new DefaultProjectionSerializer(new JavaTypeMappings());
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("Expression<String> firstName"));
assertTrue(writer.toString().contains("Expression<String> lastName"));
assertTrue(writer.toString().contains("Expression<Integer> age"));
}
use of com.querydsl.codegen.utils.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());
}
Aggregations