@Test public void testJSONSerializeInfinity() throws IOException { String expectedJson = UtilsForTesting.loadJson("src/test/resources/technology/tabula/json/schools.json"); Page page = UtilsForTesting.getAreaFromFirstPage( "src/test/resources/technology/tabula/schools.pdf", 53.74f, 16.97f, 548.74f, 762.3f); SpreadsheetExtractionAlgorithm sea = new SpreadsheetExtractionAlgorithm(); Table table = sea.extract(page).get(0); StringBuilder sb = new StringBuilder(); (new JSONWriter()).write(sb, table); String s = sb.toString(); assertEquals(expectedJson, s); }
@Test public void testJSONSerializeTwoTables() throws IOException { String expectedJson = UtilsForTesting.loadJson("src/test/resources/technology/tabula/json/twotables.json"); List<Table> tables = this.getTables(); StringBuilder sb = new StringBuilder(); (new JSONWriter()).write(sb, tables); String s = sb.toString(); assertEquals(expectedJson, s); }
@Test public void testJSONWriter() throws IOException { String expectedJson = UtilsForTesting.loadJson( "src/test/resources/technology/tabula/json/argentina_diputados_voting_record.json"); Table table = this.getTable(); StringBuilder sb = new StringBuilder(); (new JSONWriter()).write(sb, table); String s = sb.toString(); assertEquals(expectedJson, s); }
private Table getTable() throws IOException { Page page = UtilsForTesting.getAreaFromFirstPage( "src/test/resources/technology/tabula/argentina_diputados_voting_record.pdf", 269.875f, 12.75f, 790.5f, 561f); BasicExtractionAlgorithm bea = new BasicExtractionAlgorithm(); Table table = bea.extract(page).get(0); return table; }
private List<Table> getTables() throws IOException { Page page = UtilsForTesting.getPage("src/test/resources/technology/tabula/twotables.pdf", 1); SpreadsheetExtractionAlgorithm sea = new SpreadsheetExtractionAlgorithm(); return (List<Table>) sea.extract(page); }