package dk.statsbiblioteket.dpaviser.report.helpers;

import dk.statsbiblioteket.util.xml.XSLT;
import org.testng.annotations.Test;

import javax.xml.transform.TransformerException;
import java.util.List;

import static java.util.Arrays.asList;
import static org.testng.AssertJUnit.assertEquals;

@Test
public class XSLTHelperTest {

    public void testJhoveJyp1XSLT() throws TransformerException {

        String result = XSLT.transform(
                getClass().getResource("/pdf-process-jhove-output.xsl"),
                getClass().getResourceAsStream("/jhove-jyp-1.xml"),
                null
        ).toString();

        assertEquals("<!DOCTYPE html><html>\n" +
                        "<table>\n" +
                        "<tr>\n" +
                        "<td>./JYP/2015/06/05/JYP20150605L14%230022.pdf</td><td>PDF</td><td>1.3</td><td>21</td><td>1</td><td>21</td><td>0</td><td>3</td><td>1</td><td>4</td><td>3</td><td>\n" +
                        "       Font\n" +
                        "       \n" +
                        "       \n" +
                        "        BaseFont\n" +
                        "        \n" +
                        "         DEMPLL+Arial-BoldMT\n" +
                        "        \n" +
                        "       \n" +
                        "       \n" +
                        "        Encoding\n" +
                        "        \n" +
                        "         Identity-H\n" +
                        "        \n" +
                        "       \n" +
                        "       \n" +
                        "      </td><td>1</td>\n" +
                        "</tr>\n" +
                        "</table>\n" +
                        "</html>\n",
                result);

        List<List<String>> l = JSoupHelpers.getFirstTableFromHTML(result);
        assertEquals(asList(asList("./JYP/2015/06/05/JYP20150605L14%230022.pdf", "PDF", "1.3","21", "1", "21", "0", "3", "1", "4", "3", "Font BaseFont DEMPLL+Arial-BoldMT Encoding Identity-H", "1")), l);
    }

}


@@ -837,43 +837,258 @@
 %3Ctd%3E
-1.3%3C/td%3E%3Ctd%3E21%3C/td%3E%3Ctd%3E1%3C/td%3E%3Ctd%3E21
+411749%3C/td%3E%3Ctd%3EPDF%3C/td%3E%3Ctd%3E1.3%3C/td%3E%3Ctd%3EWell-Formed and valid%3C/td%3E%3Ctd%3ELinearized PDF%3C/td%3E%3Ctd%3Euntitled%3C/td%3E%3Ctd%3EAcrobat Distiller Server 8.1.0 (Pentium Linux, Built: 2007-09-07)%3C/td%3E%3Ctd%3EThu Jun 04 22:13:10 CEST 2015%3C/td%3E%3Ctd%3EThu Jun 04 22:13:10 CEST 2015
 %3C/td
@@ -1092,17 +1092,18 @@
 /td%3E%3Ctd%3E
-0
+21
 %3C/td%3E%3Ctd
@@ -1095,33 +1095,33 @@
 %3E%3Ctd%3E21%3C/td%3E%3Ctd%3E
-3
+1
 %3C/td%3E%3Ctd%3E1%3C/td%3E%3C
@@ -1105,32 +1105,33 @@
 d%3E%3Ctd%3E1%3C/td%3E%3Ctd%3E
+2
 1%3C/td%3E%3Ctd%3E4%3C/td%3E
@@ -1124,17 +1124,17 @@
 /td%3E%3Ctd%3E
-4
+0
 %3C/td%3E%3Ctd
@@ -1148,674 +1148,38 @@
 %3Ctd%3E
-%5Cn%22 +%0A                        %22       Font%5Cn%22 +%0A                        %22       %5Cn%22 +%0A                        %22       %5Cn%22 +%0A                        %22        BaseFont%5Cn%22 +%0A                        %22        %5Cn%22 +%0A                        %22         DEMPLL+Arial-BoldMT%5Cn%22 +%0A                        %22        %5Cn%22 +%0A                        %22       %5Cn%22 +%0A                        %22       %5Cn%22 +%0A                        %22        Encoding%5Cn%22 +%0A                        %22        %5Cn%22 +%0A                        %22         Identity-H%5Cn%22 +%0A                        %22        %5Cn%22 +%0A                        %22       %5Cn%22 +%0A                        %22       %5Cn%22 +%0A                        %22      
+1%3C/td%3E%3Ctd%3E4%3C/td%3E%3Ctd%3E3%3C/td%3E%3Ctd%3E
 %3C/td

Update test