use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class BeanSerializerTest method customGeneratedAnnotation.
@Test
public void customGeneratedAnnotation() throws IOException {
Serializer serializer = new BeanSerializer(BeanSerializer.DEFAULT_JAVADOC_SUFFIX, Generated.class);
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
String generatedSource = String.valueOf(writer);
assertThat(generatedSource, containsString("import com.querydsl.core.annotations.Generated;"));
assertThat(generatedSource, containsString("@Generated(\"com.querydsl.codegen.BeanSerializer\")\npublic class"));
}
use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class BeanSerializerTest method capitalization.
@Test
public void capitalization() throws IOException {
// property
type.addProperty(new Property(type, "cId", type));
BeanSerializer serializer = new BeanSerializer();
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("public DomainClass getcId() {"));
}
use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class BeanSerializerTest method annotations.
@Test
public void annotations() throws IOException {
type.addAnnotation(new QueryEntityImpl());
BeanSerializer serializer = new BeanSerializer();
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
String str = writer.toString();
assertTrue(str.contains("import com.querydsl.core.annotations.QueryEntity;"));
assertTrue(str.contains("@QueryEntity"));
}
use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class BeanSerializerTest method properties.
@Test
public void properties() throws IOException {
// property
type.addProperty(new Property(type, "entityField", type));
type.addProperty(new Property(type, "collection", new SimpleType(Types.COLLECTION, typeModel)));
type.addProperty(new Property(type, "listField", new SimpleType(Types.LIST, typeModel)));
type.addProperty(new Property(type, "setField", new SimpleType(Types.SET, typeModel)));
type.addProperty(new Property(type, "arrayField", new ClassType(TypeCategory.ARRAY, String[].class)));
type.addProperty(new Property(type, "mapField", new SimpleType(Types.MAP, typeModel, typeModel)));
for (Class<?> cl : Arrays.<Class<?>>asList(Boolean.class, Comparable.class, Integer.class, Date.class, java.sql.Date.class, java.sql.Time.class)) {
Type classType = new ClassType(TypeCategory.get(cl.getName()), cl);
type.addProperty(new Property(type, StringUtils.uncapitalize(cl.getSimpleName()), classType));
}
BeanSerializer serializer = new BeanSerializer();
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
String str = writer.toString();
// System.err.println(str);
for (String prop : Arrays.asList("String[] arrayField;", "Boolean boolean$;", "Collection<DomainClass> collection;", "Comparable comparable;", "java.util.Date date;", "DomainClass entityField;", "Integer integer;", "List<DomainClass> listField;", "Map<DomainClass, DomainClass> mapField;", "Set<DomainClass> setField;", "java.sql.Time time;")) {
assertTrue(prop + " was not contained", str.contains(prop));
}
}
use of com.querydsl.codegen.utils.JavaWriter in project querydsl by querydsl.
the class BeanSerializerTest method interfaces2.
@Test
public void interfaces2() throws IOException {
BeanSerializer serializer = new BeanSerializer();
serializer.addInterface(Serializable.class);
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer));
assertTrue(writer.toString().contains("public class DomainClass implements Serializable {"));
}
Aggregations