|
1 | 1 | package org.dflib.jjava.jupyter.kernel.display;
|
2 | 2 |
|
3 | 3 | import org.dflib.jjava.jupyter.kernel.display.mime.MIMEType;
|
4 |
| -import org.junit.jupiter.api.Assertions; |
5 | 4 | import org.junit.jupiter.api.BeforeEach;
|
6 | 5 | import org.junit.jupiter.api.Test;
|
7 | 6 |
|
|
10 | 9 | import java.util.LinkedHashSet;
|
11 | 10 | import java.util.Set;
|
12 | 11 |
|
| 12 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 13 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 14 | + |
13 | 15 | class RendererTest {
|
14 | 16 | private Renderer renderer;
|
15 | 17 |
|
@@ -51,227 +53,227 @@ public void setUp() {
|
51 | 53 | void rendersPlainText() {
|
52 | 54 | DisplayData data = this.renderer.render(new A());
|
53 | 55 |
|
54 |
| - Assertions.assertEquals("A", data.getData(MIMEType.TEXT_PLAIN)); |
| 56 | + assertEquals("A", data.getData(MIMEType.TEXT_PLAIN)); |
55 | 57 | }
|
56 | 58 |
|
57 | 59 | @Test
|
58 | 60 | void alwaysRendersPlainText() {
|
59 | 61 | DisplayData data = this.renderer.render(new B());
|
60 | 62 |
|
61 |
| - Assertions.assertEquals("B", data.getData(MIMEType.TEXT_PLAIN)); |
| 63 | + assertEquals("B", data.getData(MIMEType.TEXT_PLAIN)); |
62 | 64 | }
|
63 | 65 |
|
64 | 66 | @Test
|
65 | 67 | void rendersPreferred() {
|
66 | 68 | DisplayData data = this.renderer.render(new B());
|
67 | 69 |
|
68 |
| - Assertions.assertEquals("**B**", data.getData(MIMEType.TEXT_MARKDOWN)); |
| 70 | + assertEquals("**B**", data.getData(MIMEType.TEXT_MARKDOWN)); |
69 | 71 | }
|
70 | 72 |
|
71 | 73 | @Test
|
72 | 74 | void rendersJustPreferred() {
|
73 | 75 | DisplayData data = this.renderer.render(new C());
|
74 | 76 |
|
75 |
| - Assertions.assertEquals(".c{}", data.getData(MIMEType.TEXT_CSS)); |
76 |
| - Assertions.assertEquals("C", data.getData(MIMEType.TEXT_PLAIN)); |
77 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_MARKDOWN)); |
| 77 | + assertEquals(".c{}", data.getData(MIMEType.TEXT_CSS)); |
| 78 | + assertEquals("C", data.getData(MIMEType.TEXT_PLAIN)); |
| 79 | + assertNull(data.getData(MIMEType.TEXT_MARKDOWN)); |
78 | 80 | }
|
79 | 81 |
|
80 | 82 | @Test
|
81 | 83 | void rendersExternal() {
|
82 | 84 | DisplayData data = this.renderer.render(new D());
|
83 | 85 |
|
84 |
| - Assertions.assertEquals("<d></d>", data.getData(MIMEType.TEXT_HTML)); |
85 |
| - Assertions.assertEquals("D", data.getData(MIMEType.TEXT_PLAIN)); |
86 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_LATEX)); |
| 86 | + assertEquals("<d></d>", data.getData(MIMEType.TEXT_HTML)); |
| 87 | + assertEquals("D", data.getData(MIMEType.TEXT_PLAIN)); |
| 88 | + assertNull(data.getData(MIMEType.TEXT_LATEX)); |
87 | 89 | }
|
88 | 90 |
|
89 | 91 | @Test
|
90 | 92 | void rendersAs() {
|
91 | 93 | DisplayData data = this.renderer.renderAs(new C(), "text/markdown");
|
92 | 94 |
|
93 |
| - Assertions.assertEquals("**C**", data.getData(MIMEType.TEXT_MARKDOWN)); |
94 |
| - Assertions.assertEquals("C", data.getData(MIMEType.TEXT_PLAIN)); |
95 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_CSS)); |
| 95 | + assertEquals("**C**", data.getData(MIMEType.TEXT_MARKDOWN)); |
| 96 | + assertEquals("C", data.getData(MIMEType.TEXT_PLAIN)); |
| 97 | + assertNull(data.getData(MIMEType.TEXT_CSS)); |
96 | 98 | }
|
97 | 99 |
|
98 | 100 | @Test
|
99 | 101 | void rendersAsExternal() {
|
100 | 102 | DisplayData data = this.renderer.renderAs(new D(), "text/latex");
|
101 | 103 |
|
102 |
| - Assertions.assertEquals("\\d", data.getData(MIMEType.TEXT_LATEX)); |
103 |
| - Assertions.assertEquals("D", data.getData(MIMEType.TEXT_PLAIN)); |
104 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_HTML)); |
| 104 | + assertEquals("\\d", data.getData(MIMEType.TEXT_LATEX)); |
| 105 | + assertEquals("D", data.getData(MIMEType.TEXT_PLAIN)); |
| 106 | + assertNull(data.getData(MIMEType.TEXT_HTML)); |
105 | 107 | }
|
106 | 108 |
|
107 | 109 | @Test
|
108 | 110 | void supportsPreferringAll() {
|
109 | 111 | DisplayData data = this.renderer.render(new E());
|
110 | 112 |
|
111 |
| - Assertions.assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
112 |
| - Assertions.assertEquals(".e{}", data.getData(MIMEType.TEXT_CSS)); |
113 |
| - Assertions.assertEquals("e();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
114 |
| - Assertions.assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
| 113 | + assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
| 114 | + assertEquals(".e{}", data.getData(MIMEType.TEXT_CSS)); |
| 115 | + assertEquals("e();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 116 | + assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
115 | 117 | }
|
116 | 118 |
|
117 | 119 | @Test
|
118 | 120 | void supportsPreferringAllExternal() {
|
119 | 121 | DisplayData data = this.renderer.render(new F());
|
120 | 122 |
|
121 |
| - Assertions.assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
122 |
| - Assertions.assertEquals(".f{}", data.getData(MIMEType.TEXT_CSS)); |
123 |
| - Assertions.assertEquals("f();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
124 |
| - Assertions.assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
| 123 | + assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
| 124 | + assertEquals(".f{}", data.getData(MIMEType.TEXT_CSS)); |
| 125 | + assertEquals("f();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 126 | + assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
125 | 127 | }
|
126 | 128 |
|
127 | 129 | @Test
|
128 | 130 | void supportsPreferringAllRequestingAll() {
|
129 | 131 | DisplayData data = this.renderer.renderAs(new E(), "*");
|
130 | 132 |
|
131 |
| - Assertions.assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
132 |
| - Assertions.assertEquals(".e{}", data.getData(MIMEType.TEXT_CSS)); |
133 |
| - Assertions.assertEquals("e();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
134 |
| - Assertions.assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
| 133 | + assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
| 134 | + assertEquals(".e{}", data.getData(MIMEType.TEXT_CSS)); |
| 135 | + assertEquals("e();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 136 | + assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
135 | 137 | }
|
136 | 138 |
|
137 | 139 | @Test
|
138 | 140 | void supportsPreferringAllRequestingAllExternal() {
|
139 | 141 | DisplayData data = this.renderer.renderAs(new F(), "*");
|
140 | 142 |
|
141 |
| - Assertions.assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
142 |
| - Assertions.assertEquals(".f{}", data.getData(MIMEType.TEXT_CSS)); |
143 |
| - Assertions.assertEquals("f();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
144 |
| - Assertions.assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
| 143 | + assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
| 144 | + assertEquals(".f{}", data.getData(MIMEType.TEXT_CSS)); |
| 145 | + assertEquals("f();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 146 | + assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
145 | 147 | }
|
146 | 148 |
|
147 | 149 | @Test
|
148 | 150 | void supportsPreferringAllRequestingSome() {
|
149 | 151 | DisplayData data = this.renderer.renderAs(new E(), "text/html");
|
150 | 152 |
|
151 |
| - Assertions.assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
152 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_CSS)); |
153 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
154 |
| - Assertions.assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
| 153 | + assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
| 154 | + assertNull(data.getData(MIMEType.TEXT_CSS)); |
| 155 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 156 | + assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
155 | 157 | }
|
156 | 158 |
|
157 | 159 | @Test
|
158 | 160 | void supportsPreferringAllRequestingSomeExternal() {
|
159 | 161 | DisplayData data = this.renderer.renderAs(new F(), "text/html");
|
160 | 162 |
|
161 |
| - Assertions.assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
162 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_CSS)); |
163 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
164 |
| - Assertions.assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
| 163 | + assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
| 164 | + assertNull(data.getData(MIMEType.TEXT_CSS)); |
| 165 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 166 | + assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
165 | 167 | }
|
166 | 168 |
|
167 | 169 | @Test
|
168 | 170 | void supportsPreferringAllRequestingGroup() {
|
169 | 171 | DisplayData data = this.renderer.renderAs(new E(), "text/*");
|
170 | 172 |
|
171 |
| - Assertions.assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
172 |
| - Assertions.assertEquals(".e{}", data.getData(MIMEType.TEXT_CSS)); |
173 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
174 |
| - Assertions.assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
| 173 | + assertEquals("<e></e>", data.getData(MIMEType.TEXT_HTML)); |
| 174 | + assertEquals(".e{}", data.getData(MIMEType.TEXT_CSS)); |
| 175 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 176 | + assertEquals("E", data.getData(MIMEType.TEXT_PLAIN)); |
175 | 177 | }
|
176 | 178 |
|
177 | 179 | @Test
|
178 | 180 | void supportsPreferringAllRequestingGroupExternal() {
|
179 | 181 | DisplayData data = this.renderer.renderAs(new F(), "text/*");
|
180 | 182 |
|
181 |
| - Assertions.assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
182 |
| - Assertions.assertEquals(".f{}", data.getData(MIMEType.TEXT_CSS)); |
183 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
184 |
| - Assertions.assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
| 183 | + assertEquals("<f></f>", data.getData(MIMEType.TEXT_HTML)); |
| 184 | + assertEquals(".f{}", data.getData(MIMEType.TEXT_CSS)); |
| 185 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 186 | + assertEquals("F", data.getData(MIMEType.TEXT_PLAIN)); |
185 | 187 | }
|
186 | 188 |
|
187 | 189 | @Test
|
188 | 190 | void supportsPreferringGroup() {
|
189 | 191 | DisplayData data = this.renderer.render(new G());
|
190 | 192 |
|
191 |
| - Assertions.assertEquals("<g></g>", data.getData(MIMEType.TEXT_HTML)); |
192 |
| - Assertions.assertEquals(".g{}", data.getData(MIMEType.TEXT_CSS)); |
193 |
| - Assertions.assertEquals("g();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
194 |
| - Assertions.assertEquals("G", data.getData(MIMEType.TEXT_PLAIN)); |
| 193 | + assertEquals("<g></g>", data.getData(MIMEType.TEXT_HTML)); |
| 194 | + assertEquals(".g{}", data.getData(MIMEType.TEXT_CSS)); |
| 195 | + assertEquals("g();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 196 | + assertEquals("G", data.getData(MIMEType.TEXT_PLAIN)); |
195 | 197 | }
|
196 | 198 |
|
197 | 199 | @Test
|
198 | 200 | void supportsPreferringGroupExternal() {
|
199 | 201 | DisplayData data = this.renderer.render(new H());
|
200 | 202 |
|
201 |
| - Assertions.assertEquals("<h></h>", data.getData(MIMEType.TEXT_HTML)); |
202 |
| - Assertions.assertEquals(".h{}", data.getData(MIMEType.TEXT_CSS)); |
203 |
| - Assertions.assertEquals("h();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
204 |
| - Assertions.assertEquals("H", data.getData(MIMEType.TEXT_PLAIN)); |
| 203 | + assertEquals("<h></h>", data.getData(MIMEType.TEXT_HTML)); |
| 204 | + assertEquals(".h{}", data.getData(MIMEType.TEXT_CSS)); |
| 205 | + assertEquals("h();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 206 | + assertEquals("H", data.getData(MIMEType.TEXT_PLAIN)); |
205 | 207 | }
|
206 | 208 |
|
207 | 209 | @Test
|
208 | 210 | void supportsPreferringGroupRequestingSome() {
|
209 | 211 | DisplayData data = this.renderer.renderAs(new G(), "text/html");
|
210 | 212 |
|
211 |
| - Assertions.assertEquals("<g></g>", data.getData(MIMEType.TEXT_HTML)); |
212 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_CSS)); |
213 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
214 |
| - Assertions.assertEquals("G", data.getData(MIMEType.TEXT_PLAIN)); |
| 213 | + assertEquals("<g></g>", data.getData(MIMEType.TEXT_HTML)); |
| 214 | + assertNull(data.getData(MIMEType.TEXT_CSS)); |
| 215 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 216 | + assertEquals("G", data.getData(MIMEType.TEXT_PLAIN)); |
215 | 217 | }
|
216 | 218 |
|
217 | 219 | @Test
|
218 | 220 | void supportsPreferringGroupRequestingSomeExternal() {
|
219 | 221 | DisplayData data = this.renderer.renderAs(new H(), "text/html");
|
220 | 222 |
|
221 |
| - Assertions.assertEquals("<h></h>", data.getData(MIMEType.TEXT_HTML)); |
222 |
| - Assertions.assertNull(data.getData(MIMEType.TEXT_CSS)); |
223 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
224 |
| - Assertions.assertEquals("H", data.getData(MIMEType.TEXT_PLAIN)); |
| 223 | + assertEquals("<h></h>", data.getData(MIMEType.TEXT_HTML)); |
| 224 | + assertNull(data.getData(MIMEType.TEXT_CSS)); |
| 225 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 226 | + assertEquals("H", data.getData(MIMEType.TEXT_PLAIN)); |
225 | 227 | }
|
226 | 228 |
|
227 | 229 | @Test
|
228 | 230 | void supportsPreferringGroupRequestingGroup() {
|
229 | 231 | DisplayData data = this.renderer.renderAs(new G(), "text/*");
|
230 | 232 |
|
231 |
| - Assertions.assertEquals("<g></g>", data.getData(MIMEType.TEXT_HTML)); |
232 |
| - Assertions.assertEquals(".g{}", data.getData(MIMEType.TEXT_CSS)); |
233 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
234 |
| - Assertions.assertEquals("G", data.getData(MIMEType.TEXT_PLAIN)); |
| 233 | + assertEquals("<g></g>", data.getData(MIMEType.TEXT_HTML)); |
| 234 | + assertEquals(".g{}", data.getData(MIMEType.TEXT_CSS)); |
| 235 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 236 | + assertEquals("G", data.getData(MIMEType.TEXT_PLAIN)); |
235 | 237 | }
|
236 | 238 |
|
237 | 239 | @Test
|
238 | 240 | void supportsPreferringGroupRequestingGroupExternal() {
|
239 | 241 | DisplayData data = this.renderer.renderAs(new H(), "text/*");
|
240 | 242 |
|
241 |
| - Assertions.assertEquals("<h></h>", data.getData(MIMEType.TEXT_HTML)); |
242 |
| - Assertions.assertEquals(".h{}", data.getData(MIMEType.TEXT_CSS)); |
243 |
| - Assertions.assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
244 |
| - Assertions.assertEquals("H", data.getData(MIMEType.TEXT_PLAIN)); |
| 243 | + assertEquals("<h></h>", data.getData(MIMEType.TEXT_HTML)); |
| 244 | + assertEquals(".h{}", data.getData(MIMEType.TEXT_CSS)); |
| 245 | + assertNull(data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 246 | + assertEquals("H", data.getData(MIMEType.TEXT_PLAIN)); |
245 | 247 | }
|
246 | 248 |
|
247 | 249 | @Test
|
248 | 250 | void supportsOverridingTextRepresentation() {
|
249 | 251 | DisplayData data = this.renderer.render(new I());
|
250 | 252 |
|
251 |
| - Assertions.assertEquals("I!", data.getData(MIMEType.TEXT_PLAIN)); |
| 253 | + assertEquals("I!", data.getData(MIMEType.TEXT_PLAIN)); |
252 | 254 | }
|
253 | 255 |
|
254 | 256 | @Test
|
255 | 257 | void supportsOverridingTextRepresentationExternal() {
|
256 | 258 | DisplayData data = this.renderer.render(new J());
|
257 | 259 |
|
258 |
| - Assertions.assertEquals("J!", data.getData(MIMEType.TEXT_PLAIN)); |
| 260 | + assertEquals("J!", data.getData(MIMEType.TEXT_PLAIN)); |
259 | 261 | }
|
260 | 262 |
|
261 | 263 | @Test
|
262 | 264 | void supportsOverridingTextRepresentationWhenNotRequested() {
|
263 | 265 | DisplayData data = this.renderer.renderAs(new I(), "application/javascript");
|
264 | 266 |
|
265 |
| - Assertions.assertEquals("i();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
266 |
| - Assertions.assertEquals("I!", data.getData(MIMEType.TEXT_PLAIN)); |
| 267 | + assertEquals("i();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 268 | + assertEquals("I!", data.getData(MIMEType.TEXT_PLAIN)); |
267 | 269 | }
|
268 | 270 |
|
269 | 271 | @Test
|
270 | 272 | void supportsOverridingTextRepresentationWhenNotRequestedExternal() {
|
271 | 273 | DisplayData data = this.renderer.renderAs(new J(), "application/javascript");
|
272 | 274 |
|
273 |
| - Assertions.assertEquals("j();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
274 |
| - Assertions.assertEquals("J!", data.getData(MIMEType.TEXT_PLAIN)); |
| 275 | + assertEquals("j();", data.getData(MIMEType.APPLICATION_JAVASCRIPT)); |
| 276 | + assertEquals("J!", data.getData(MIMEType.TEXT_PLAIN)); |
275 | 277 | }
|
276 | 278 |
|
277 | 279 | class A {
|
|
0 commit comments