moved json serialisation for freemarker template to individual class
improved GSON handling updated GSON to 2.7
This commit is contained in:
@ -27,7 +27,7 @@ public class DefaultTableRowTest {
|
||||
" }";
|
||||
|
||||
|
||||
TableRow tableRow = GsonUtil.getGsonInstance().fromJson(jsonString, TableRow.class);
|
||||
TableRow tableRow = GsonUtil.getInstance().fromJson(jsonString, TableRow.class);
|
||||
assertNotNull ("tableRowObject", tableRow);
|
||||
assertEquals ("column count", 2, tableRow.getColumnCount());
|
||||
assertFalse ("isList", tableRow.isList());
|
||||
|
||||
24
pdf/src/test/java/de/muehlencord/shared/pdf/PDFFontTest.java
Normal file
24
pdf/src/test/java/de/muehlencord/shared/pdf/PDFFontTest.java
Normal file
@ -0,0 +1,24 @@
|
||||
package de.muehlencord.shared.pdf;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern.muehlencord
|
||||
*/
|
||||
public class PDFFontTest {
|
||||
|
||||
public PDFFontTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateSerialisation() {
|
||||
PDFFont font = new PDFFont("Test", 12, 0);
|
||||
String gsonString = GsonUtil.getInstance().toJson(font);
|
||||
String templateString = font.getTemplateJsonString();
|
||||
System.out.println(templateString);
|
||||
assertEquals(gsonString, templateString);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package de.muehlencord.shared.pdf;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern.muehlencord
|
||||
*/
|
||||
public class PDFImageContentTest {
|
||||
|
||||
public PDFImageContentTest() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImage() throws IOException {
|
||||
|
||||
PDFDocument doc = new PDFDocument(PDFPaperSize.A4);
|
||||
PDFImageContent logoContent = new PDFImageContent(doc, 400F, 700F, 0.6F, new File("c:/temp/logo-verkehrsverein-hoevelh.jpg"));
|
||||
|
||||
System.out.println(GsonUtil.getInstance().toJson(logoContent));
|
||||
System.out.println(GsonUtil.getInstance().toJson(logoContent));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
package de.muehlencord.shared.pdf;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author joern.muehlencord
|
||||
*/
|
||||
public class PDFTextContentTest {
|
||||
|
||||
@Test
|
||||
public void testSomeMethod() {
|
||||
PDFDocument doc = new PDFDocument(PDFPaperSize.A4);
|
||||
PDFTextContent informationContent = new PDFTextContent(doc, 400F, 662F);
|
||||
informationContent.addLine("Anzeigenabrechnung", "bold");
|
||||
informationContent.addLine("Veronika Mühlencord", "helv12");
|
||||
informationContent.addLine("Telefon: 05257/940154", "helv12");
|
||||
informationContent.addLine("Telefax: 05257/940156", "helv12");
|
||||
informationContent.addLine();
|
||||
informationContent.addLine("Hövelhof, den ${invoice.invoiceDate?date}", "bold");
|
||||
doc.addContent(informationContent);
|
||||
|
||||
// System.out.println (informationContent.getTemplateJsonString());
|
||||
// System.out.println ("*****");
|
||||
// System.out.println (GsonUtil.getGsonInstance().toJson(informationContent));
|
||||
System.out.println("*****");
|
||||
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapterFactory(new PDFImageContentTypeAdapterFactory())
|
||||
.setPrettyPrinting()
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
|
||||
System.out.println(gson.toJson(informationContent, PDFTextContent.class));
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,7 +18,7 @@ public class TextTest {
|
||||
+ "\"text\": \"Rechnungs-Nr.:\"\n"
|
||||
+ "}";
|
||||
|
||||
TextElement text = GsonUtil.getGsonInstance().fromJson(jsonString, TextElement.class);
|
||||
TextElement text = GsonUtil.getInstance().fromJson(jsonString, TextElement.class);
|
||||
assertNotNull ("text object", text);
|
||||
assertEquals ("text value", "Rechnungs-Nr.:", text.getText());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user