Migrate recent PRs to Jackson
This commit is contained in:
parent
f26d62dc4d
commit
f667a78657
@ -4,12 +4,12 @@ import java.io.IOException;
|
|||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.json.JSONWriter;
|
|
||||||
import org.openrefine.wikidata.schema.WikibaseSchema;
|
import org.openrefine.wikidata.schema.WikibaseSchema;
|
||||||
|
|
||||||
import com.google.refine.browsing.Engine;
|
import com.google.refine.browsing.Engine;
|
||||||
import com.google.refine.exporters.WriterExporter;
|
import com.google.refine.exporters.WriterExporter;
|
||||||
import com.google.refine.model.Project;
|
import com.google.refine.model.Project;
|
||||||
|
import com.google.refine.util.ParsingUtilities;
|
||||||
|
|
||||||
public class SchemaExporter implements WriterExporter {
|
public class SchemaExporter implements WriterExporter {
|
||||||
|
|
||||||
@ -24,8 +24,7 @@ public class SchemaExporter implements WriterExporter {
|
|||||||
if (schema == null) {
|
if (schema == null) {
|
||||||
schema = new WikibaseSchema();
|
schema = new WikibaseSchema();
|
||||||
}
|
}
|
||||||
JSONWriter jsonWriter = new JSONWriter(writer);
|
ParsingUtilities.mapper.writeValue(writer, schema);
|
||||||
schema.write(jsonWriter, new Properties());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.openrefine.wikidata.exporters;
|
package org.openrefine.wikidata.exporters;
|
||||||
|
|
||||||
import static org.openrefine.wikidata.testing.JacksonSerializationTest.assertJsonEquals;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -11,6 +9,7 @@ import org.testng.annotations.Test;
|
|||||||
import com.google.refine.browsing.Engine;
|
import com.google.refine.browsing.Engine;
|
||||||
import com.google.refine.model.Project;
|
import com.google.refine.model.Project;
|
||||||
import com.google.refine.tests.RefineTest;
|
import com.google.refine.tests.RefineTest;
|
||||||
|
import com.google.refine.tests.util.TestUtils;
|
||||||
|
|
||||||
public class SchemaExporterTest extends RefineTest {
|
public class SchemaExporterTest extends RefineTest {
|
||||||
|
|
||||||
@ -24,7 +23,7 @@ public class SchemaExporterTest extends RefineTest {
|
|||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
exporter.export(project, properties, engine, writer);
|
exporter.export(project, properties, engine, writer);
|
||||||
assertJsonEquals("{\"itemDocuments\":[]}", writer.toString());
|
TestUtils.assertEqualAsJson("{\"itemDocuments\":[]}", writer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,15 +95,14 @@ public class ListFacetTests extends RefineTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSelectedEmptyChoice() {
|
public void testSelectedEmptyChoice() throws IOException {
|
||||||
Project project = createCSVProject("Column A\n" +
|
Project project = createCSVProject("Column A\n" +
|
||||||
"a\n" +
|
"a\n" +
|
||||||
"c\n" +
|
"c\n" +
|
||||||
"e");
|
"e");
|
||||||
Engine engine = new Engine(project);
|
Engine engine = new Engine(project);
|
||||||
|
|
||||||
ListFacetConfig facetConfig = new ListFacetConfig();
|
ListFacetConfig facetConfig = ParsingUtilities.mapper.readValue(jsonConfig, ListFacetConfig.class);
|
||||||
facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
|
|
||||||
Facet facet = facetConfig.apply(project);
|
Facet facet = facetConfig.apply(project);
|
||||||
facet.computeChoices(project, engine.getAllFilteredRows());
|
facet.computeChoices(project, engine.getAllFilteredRows());
|
||||||
TestUtils.isSerializedTo(facet, selectedEmptyChoiceFacet);
|
TestUtils.isSerializedTo(facet, selectedEmptyChoiceFacet);
|
||||||
|
@ -101,7 +101,7 @@ public class BlankDownTests extends RefineTest {
|
|||||||
project.columnModel.update();
|
project.columnModel.update();
|
||||||
|
|
||||||
AbstractOperation op = new BlankDownOperation(
|
AbstractOperation op = new BlankDownOperation(
|
||||||
EngineConfig.reconstruct(new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}")),
|
EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"),
|
||||||
"second");
|
"second");
|
||||||
Process process = op.createProcess(project, new Properties());
|
Process process = op.createProcess(project, new Properties());
|
||||||
process.performImmediate();
|
process.performImmediate();
|
||||||
|
@ -117,7 +117,7 @@ public class FillDownTests extends RefineTest {
|
|||||||
project.columnModel.update();
|
project.columnModel.update();
|
||||||
|
|
||||||
AbstractOperation op = new FillDownOperation(
|
AbstractOperation op = new FillDownOperation(
|
||||||
EngineConfig.reconstruct(new JSONObject("{\"mode\":\"record-based\",\"facets\":[]}")),
|
EngineConfig.reconstruct("{\"mode\":\"record-based\",\"facets\":[]}"),
|
||||||
"second");
|
"second");
|
||||||
Process process = op.createProcess(project, new Properties());
|
Process process = op.createProcess(project, new Properties());
|
||||||
process.performImmediate();
|
process.performImmediate();
|
||||||
|
@ -273,8 +273,8 @@ public class ExtendDataOperationTests extends RefineTest {
|
|||||||
Assert.assertFalse(process.isRunning(), "The data extension process took longer than expected.");
|
Assert.assertFalse(process.isRunning(), "The data extension process took longer than expected.");
|
||||||
|
|
||||||
// Test to be updated as countries change currencies!
|
// Test to be updated as countries change currencies!
|
||||||
Assert.assertTrue(Math.round((float)project.rows.get(2).getCellValue(1)) == 2, "Incorrect number of currencies returned for Tajikistan.");
|
Assert.assertTrue(Math.round((double)project.rows.get(2).getCellValue(1)) == 2, "Incorrect number of currencies returned for Tajikistan.");
|
||||||
Assert.assertTrue(Math.round((float)project.rows.get(3).getCellValue(1)) == 1, "Incorrect number of currencies returned for United States.");
|
Assert.assertTrue(Math.round((double)project.rows.get(3).getCellValue(1)) == 1, "Incorrect number of currencies returned for United States.");
|
||||||
|
|
||||||
// Make sure we did not create any recon stats for that column (no reconciled value)
|
// Make sure we did not create any recon stats for that column (no reconciled value)
|
||||||
Assert.assertTrue(project.columnModel.getColumnByName("currency").getReconStats() == null);
|
Assert.assertTrue(project.columnModel.getColumnByName("currency").getReconStats() == null);
|
||||||
|
Loading…
Reference in New Issue
Block a user