|
6 | 6 | import com.itextpdf.html2pdf.attach.impl.DefaultTagWorkerFactory; |
7 | 7 | import com.itextpdf.html2pdf.attach.impl.tags.DivTagWorker; |
8 | 8 | import com.itextpdf.html2pdf.html.TagConstants; |
9 | | -import com.itextpdf.kernel.pdf.DocumentProperties; |
10 | 9 | import com.itextpdf.kernel.pdf.PdfDocument; |
11 | 10 | import com.itextpdf.kernel.pdf.PdfWriter; |
| 11 | +import com.itextpdf.layout.Document; |
12 | 12 | import com.itextpdf.layout.IPropertyContainer; |
13 | 13 | import com.itextpdf.layout.element.Div; |
14 | 14 | import com.itextpdf.layout.layout.LayoutContext; |
15 | 15 | import com.itextpdf.layout.layout.LayoutResult; |
16 | 16 | import com.itextpdf.layout.properties.Property; |
17 | 17 | import com.itextpdf.layout.renderer.DivRenderer; |
18 | 18 | import com.itextpdf.layout.renderer.IRenderer; |
| 19 | +import com.itextpdf.layout.renderer.MetaInfoContainer; |
19 | 20 | import com.itextpdf.styledxmlparser.node.IElementNode; |
20 | 21 | import com.itextpdf.test.ExtendedITextTest; |
21 | 22 | import com.itextpdf.test.annotations.type.UnitTest; |
|
29 | 30 | public class HtmlConverterMetaInfoTest extends ExtendedITextTest { |
30 | 31 |
|
31 | 32 | @Test |
32 | | - public void testMetaInfoShouldBePresent() { |
33 | | - DocumentProperties documentProperties = new DocumentProperties(); |
| 33 | + public void metaInfoShouldBePresentTest() { |
34 | 34 | IMetaInfo o = new IMetaInfo() {}; |
35 | | - documentProperties.setEventCountingMetaInfo(o); |
36 | 35 | ConverterProperties converterProperties = new ConverterProperties(); |
37 | 36 | converterProperties.setEventMetaInfo(o); |
38 | 37 | InvocationAssert invocationAssert = new InvocationAssert(); |
39 | 38 | converterProperties.setTagWorkerFactory(new AssertMetaInfoTagWorkerFactory(invocationAssert)); |
40 | | - // TODO DEVSIX-5790 fix assertion error - all assertions must pass |
41 | | - Assert.assertThrows(AssertionError.class, () -> { |
42 | | - HtmlConverter.convertToDocument("<!DOCTYPE html>\n" |
43 | | - + "<html>\n" |
44 | | - + "\n" |
45 | | - + "<body>\n" |
46 | | - + "<div>\n" |
47 | | - + "The content of the div\n" |
48 | | - + "</div>\n" |
49 | | - + "</body>\n" |
50 | | - + "\n" |
51 | | - + "</html>\n", |
52 | | - new PdfDocument(new PdfWriter(new ByteArrayOutputStream())), |
53 | | - converterProperties |
54 | | - ).close(); |
55 | | - }); |
56 | | - // TODO DEVSIX-5790 #isInvoked status must be true |
57 | | - Assert.assertFalse(invocationAssert.isInvoked()); |
| 39 | + |
| 40 | + Document document = HtmlConverter.convertToDocument("<!DOCTYPE html>\n" |
| 41 | + + "<html>\n" |
| 42 | + + "\n" |
| 43 | + + "<body>\n" |
| 44 | + + "<div>\n" |
| 45 | + + "The content of the div\n" |
| 46 | + + "</div>\n" |
| 47 | + + "</body>\n" |
| 48 | + + "\n" |
| 49 | + + "</html>\n", |
| 50 | + new PdfDocument(new PdfWriter(new ByteArrayOutputStream())), |
| 51 | + converterProperties |
| 52 | + ); |
| 53 | + |
| 54 | + document.close(); |
| 55 | + Assert.assertTrue(invocationAssert.isInvoked()); |
58 | 56 | } |
59 | 57 |
|
60 | 58 | private static class AssertMetaInfoTagWorkerFactory extends DefaultTagWorkerFactory { |
61 | 59 | private final InvocationAssert invocationAssert; |
62 | 60 |
|
63 | | - private AssertMetaInfoTagWorkerFactory(InvocationAssert invocationAssert) { |
| 61 | + public AssertMetaInfoTagWorkerFactory(InvocationAssert invocationAssert) { |
64 | 62 | this.invocationAssert = invocationAssert; |
65 | 63 | } |
66 | 64 |
|
@@ -99,7 +97,7 @@ public AssertMetaInfoDivTagRenderer(Div modelElement, InvocationAssert invocatio |
99 | 97 |
|
100 | 98 | @Override |
101 | 99 | public LayoutResult layout(LayoutContext layoutContext) { |
102 | | - Assert.assertNotNull(this.getProperty(Property.META_INFO)); |
| 100 | + Assert.assertNotNull(this.<MetaInfoContainer>getProperty(Property.META_INFO)); |
103 | 101 | invocationAssert.setInvoked(true); |
104 | 102 | return super.layout(layoutContext); |
105 | 103 | } |
|
0 commit comments