-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSerializatorTest.java
More file actions
160 lines (121 loc) · 4.92 KB
/
SerializatorTest.java
File metadata and controls
160 lines (121 loc) · 4.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package com.aspose.html.tests;
import com.aspose.html.JSON;
import com.aspose.html.options.Options;
import com.aspose.html.options.ImageConversionOptions;
import com.aspose.html.options.MarkdownConversionOptions;
import com.aspose.html.options.PDFConversionOptions;
import com.aspose.html.options.XPSConversionOptions;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class SerializatorTest {
@Test
public void OptionalImageParamsAll(){
Options source = new ImageConversionOptions()
.setHeight(800)
.setWidth(1000)
.setLeftMargin(10)
.setRightMargin(10)
.setBottomMargin(10)
.setTopMargin(10);
String expected = "{\"width\":1000,\"height\":800,\"leftMargin\":10," +
"\"rightMargin\":10,\"topMargin\":10,\"bottomMargin\":10}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalImageParamsPart(){
Options source = new ImageConversionOptions()
.setHeight(800)
.setWidth(1000);
String expected = "{\"width\":1000,\"height\":800}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalImageParamsZero(){
Options source = new ImageConversionOptions();
String expected = "{}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalPDFParamsAll(){
Options source = new PDFConversionOptions()
.setWidth(5.8)
.setHeight(8.3)
.setTopMargin(0.5)
.setBottomMargin(0.5)
.setLeftMargin(0.5)
.setRightMargin(0.5)
.setQuality(95);
String expected = "{\"width\":5.8,\"height\":8.3,\"leftMargin\":0.5," +
"\"rightMargin\":0.5,\"topMargin\":0.5,\"bottomMargin\":0.5,\"jpegQuality\":95}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalPDFParamsPart(){
Options source = new PDFConversionOptions() .setQuality(95);
String expected = "{\"jpegQuality\":95}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalPDFParamsZero(){
Options source = new PDFConversionOptions();
String expected = "{}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalXPSParamsAll(){
Options source = new XPSConversionOptions()
.setWidth(5.8)
.setHeight(8.3)
.setTopMargin(0.5)
.setBottomMargin(0.5)
.setLeftMargin(0.5)
.setRightMargin(0.5);
String expected = "{\"width\":5.8,\"height\":8.3,\"leftMargin\":0.5," +
"\"rightMargin\":0.5,\"topMargin\":0.5,\"bottomMargin\":0.5}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalXPSParamsPart(){
Options source = new XPSConversionOptions()
.setHeight(800)
.setWidth(1000);
String expected = "{\"width\":1000.0,\"height\":800.0}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalXPSParamsZero(){
Options source = new XPSConversionOptions();
String expected = "{}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalMarkdownParamsAll(){
Options source = new MarkdownConversionOptions().setUseGit(true);
String expected = "{\"useGit\":true}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalMarkdownParamsPart(){
Options source = new MarkdownConversionOptions().setUseGit(false);
String expected = "{\"useGit\":false}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
@Test
public void OptionalMarkdownParamsZero(){
Options source = new XPSConversionOptions();
String expected = "{}";
String result = new JSON().getGson().toJson(source);
Assertions.assertEquals(expected,result);
}
}