@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 {")); }
Set<String> importedClasses = getAnnotationTypes(model); for (Type iface : interfaces) { importedClasses.add(iface.getFullName()); bodyStart(model, writer); addFullConstructor(model, writer); addToString(model, writer); bodyEnd(model, writer);
@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() {")); }
@Test public void fullConstructor() 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))); BeanSerializer serializer = new BeanSerializer(); serializer.setAddFullConstructor(true); serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer)); //System.out.println(writer.toString()); }
@Test public void toString_() 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))); BeanSerializer serializer = new BeanSerializer(); serializer.setAddToString(true); serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer)); assertTrue(String.valueOf(writer).contains( " @Override\n" + " public String toString()")); }
int sepIndex = iface.lastIndexOf('.'); if (sepIndex < 0) { serializer.addInterface(new SimpleType(iface)); } else { String packageName = iface.substring(0, sepIndex); String simpleName = iface.substring(sepIndex + 1); serializer.addInterface(new SimpleType(iface, packageName, simpleName)); serializer.setAddFullConstructor(beanAddFullConstructor); serializer.setAddToString(beanAddToString); serializer.setPrintSupertype(beanPrintSupertype); exporter.setBeanSerializer(serializer);
smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("","student"),Student.class, null, new BeanSerializer()); smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("","matricule"),Integer.class, null, new IntDeserializer()); smr.mapTypes(Constants.NS_URI_SOAP_ENC,new QName("","name"),Integer.class, null, new StringDeserializer());
@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")); }
@Test public void fullConstructor() 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))); BeanSerializer serializer = new BeanSerializer(); serializer.setAddFullConstructor(true); serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer)); //System.out.println(writer.toString()); }
@Test public void toString_() 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))); BeanSerializer serializer = new BeanSerializer(); serializer.setAddToString(true); serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer)); assertTrue(String.valueOf(writer).contains( " @Override\n" + " public String toString()")); }
@Test public void interfaces() throws IOException { BeanSerializer serializer = new BeanSerializer(); serializer.addInterface(new ClassType(Serializable.class)); serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer)); assertTrue(writer.toString().contains("public class DomainClass implements Serializable {")); }
@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")); }
@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 {")); }
@Test public void annotated_property() throws IOException { Property property = new Property(type, "entityField", type); property.addAnnotation(new QueryEntityImpl()); type.addProperty(property); 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")); }
@Test public void interfaces() throws IOException { BeanSerializer serializer = new BeanSerializer(); serializer.addInterface(new ClassType(Serializable.class)); serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer)); assertTrue(writer.toString().contains("public class DomainClass implements Serializable {")); }
BeanSerializer serializer = new BeanSerializer(); serializer.serialize(type, SimpleSerializerConfig.DEFAULT, new JavaWriter(writer)); String str = writer.toString();
@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")); }
@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() {")); }
@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")); }
@Test public void annotated_property() throws IOException { Property property = new Property(type, "entityField", type); property.addAnnotation(new QueryEntityImpl()); type.addProperty(property); 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")); }