Jackson deserialization for TextSearchFacetConfig
This commit is contained in:
parent
c4caf1eba7
commit
ae61368796
@ -36,13 +36,15 @@ package com.google.refine.tests.browsing.facets;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
|
||||||
import com.google.refine.browsing.RowFilter;
|
import com.google.refine.browsing.RowFilter;
|
||||||
import com.google.refine.browsing.facets.TextSearchFacet;
|
import com.google.refine.browsing.facets.TextSearchFacet;
|
||||||
import com.google.refine.browsing.facets.TextSearchFacet.TextSearchFacetConfig;
|
import com.google.refine.browsing.facets.TextSearchFacet.TextSearchFacetConfig;
|
||||||
@ -50,6 +52,7 @@ import com.google.refine.model.ModelException;
|
|||||||
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;
|
import com.google.refine.tests.util.TestUtils;
|
||||||
|
import com.google.refine.util.ParsingUtilities;
|
||||||
|
|
||||||
|
|
||||||
public class TextSearchFacetTests extends RefineTest {
|
public class TextSearchFacetTests extends RefineTest {
|
||||||
@ -89,10 +92,9 @@ public class TextSearchFacetTests extends RefineTest {
|
|||||||
+ "Abc\n");
|
+ "Abc\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureFilter(String filter) {
|
private void configureFilter(String filter) throws JsonParseException, JsonMappingException, IOException {
|
||||||
//Add the facet to the project and create a row filter
|
//Add the facet to the project and create a row filter
|
||||||
textfilterconfig = new TextSearchFacetConfig();
|
textfilterconfig = ParsingUtilities.mapper.readValue(filter, TextSearchFacetConfig.class);
|
||||||
textfilterconfig.initializeFromJSON(new JSONObject(filter));
|
|
||||||
textfilter = textfilterconfig.apply(project);
|
textfilter = textfilterconfig.apply(project);
|
||||||
rowfilter = textfilter.getRowFilter(project);
|
rowfilter = textfilter.getRowFilter(project);
|
||||||
}
|
}
|
||||||
@ -194,16 +196,14 @@ public class TextSearchFacetTests extends RefineTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void serializeTextSearchFacetConfig() {
|
public void serializeTextSearchFacetConfig() throws JsonParseException, JsonMappingException, IOException {
|
||||||
TextSearchFacetConfig config = new TextSearchFacetConfig();
|
TextSearchFacetConfig config = ParsingUtilities.mapper.readValue(sensitiveConfigJson, TextSearchFacetConfig.class);
|
||||||
config.initializeFromJSON(new JSONObject(sensitiveConfigJson));
|
|
||||||
TestUtils.isSerializedTo(config, sensitiveConfigJson);
|
TestUtils.isSerializedTo(config, sensitiveConfigJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void serializeTextSearchFacet() {
|
public void serializeTextSearchFacet() throws JsonParseException, JsonMappingException, IOException {
|
||||||
TextSearchFacetConfig config = new TextSearchFacetConfig();
|
TextSearchFacetConfig config = ParsingUtilities.mapper.readValue(sensitiveConfigJson, TextSearchFacetConfig.class);
|
||||||
config.initializeFromJSON(new JSONObject(sensitiveConfigJson));
|
|
||||||
TextSearchFacet facet = config.apply(project);
|
TextSearchFacet facet = config.apply(project);
|
||||||
TestUtils.isSerializedTo(facet, sensitiveFacetJson);
|
TestUtils.isSerializedTo(facet, sensitiveFacetJson);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user