Updating tests for List Facets

This commit is contained in:
Owen Stephens 2018-11-22 13:43:02 +00:00
parent e8f454afc7
commit 2ad0e76aca
2 changed files with 26 additions and 24 deletions

View File

@ -15,11 +15,14 @@ public class ListFacetTests extends RefineTest {
private static String jsonConfig = "{" private static String jsonConfig = "{"
+ "\"type\":\"list\"," + "\"type\":\"list\","
+ "\"name\":\"facet A\"," + "\"name\":\"facet A\","
+ "\"columnName\":\"Column A\","
+ "\"expression\":\"value+\\\"bar\\\"\"," + "\"expression\":\"value+\\\"bar\\\"\","
+ "\"columnName\":\"Column A\","
+ "\"omitBlank\":false," + "\"omitBlank\":false,"
+ "\"omitError\":false," + "\"omitError\":false,"
+ "\"selection\":[{\"v\":{\"v\":\"foobar\",\"l\":\"true\"}}]," + "\"selection\":[{\"v\":{\"v\":\"foobar\",\"l\":\"true\"}}],"
+ "\"selectNumber\":false,"
+ "\"selectDateTime\":false,"
+ "\"selectBoolean\":false,"
+ "\"selectBlank\":false," + "\"selectBlank\":false,"
+ "\"selectError\":false," + "\"selectError\":false,"
+ "\"invert\":false" + "\"invert\":false"

View File

@ -51,16 +51,15 @@ import org.testng.annotations.Test;
import com.google.refine.model.ModelException; import com.google.refine.model.ModelException;
import com.google.refine.model.Project; import com.google.refine.model.Project;
import com.google.refine.browsing.RowFilter; import com.google.refine.browsing.RowFilter;
import com.google.refine.browsing.facets.ListFacet; import com.google.refine.browsing.facets.Facet;
import com.google.refine.browsing.facets.ListFacet.ListFacetConfig;
import com.google.refine.tests.RefineTest; import com.google.refine.tests.RefineTest;
public class TextListFacetTests extends RefineTest { public class TextListFacetTests extends RefineTest {
// dependencies // dependencies
private Project project; private Project project;
private ListFacet facet;
private RowFilter rowfilter; private RowFilter rowfilter;
private JSONObject listfacetconfig;
// Variables // Variables
private static OffsetDateTime dateTimeValue = OffsetDateTime.parse("2017-05-12T05:45:00+00:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME); private static OffsetDateTime dateTimeValue = OffsetDateTime.parse("2017-05-12T05:45:00+00:00", DateTimeFormatter.ISO_OFFSET_DATE_TIME);
@ -118,7 +117,7 @@ public class TextListFacetTests extends RefineTest {
public void testTextSelection() throws Exception { public void testTextSelection() throws Exception {
//Need to work out the correct facet config for these tests to work //Need to work out the correct facet config for these tests to work
//Also need all rows in all tests so can check that rows aren't being selected when they shouldn't be //Also need all rows in all tests so can check that rows aren't being selected when they shouldn't be
String facetconfig = "{" String jsonConfig = "{"
+ "\"type\": \"list\"," + "\"type\": \"list\","
+ "\"name\": \"Value\"," + "\"name\": \"Value\","
+ "\"columnName\": \"" + columnName + "\"," + "\"columnName\": \"" + columnName + "\","
@ -142,9 +141,9 @@ public class TextListFacetTests extends RefineTest {
+ "}"; + "}";
//Add the facet to the project and create a row filter //Add the facet to the project and create a row filter
facet = new ListFacet(); ListFacetConfig facetConfig = new ListFacetConfig();
listfacetconfig = new JSONObject(facetconfig); facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
facet.initializeFromJSON(project,listfacetconfig); Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project); rowfilter = facet.getRowFilter(project);
//Check each row in the project against the filter //Check each row in the project against the filter
@ -188,7 +187,7 @@ public class TextListFacetTests extends RefineTest {
@Test @Test
public void testDateSelection() throws Exception { public void testDateSelection() throws Exception {
String facetconfig = "{" String jsonConfig = "{"
+ "\"type\": \"list\"," + "\"type\": \"list\","
+ "\"name\": \"Value\"," + "\"name\": \"Value\","
+ "\"columnName\": \"" + columnName + "\"," + "\"columnName\": \"" + columnName + "\","
@ -205,9 +204,9 @@ public class TextListFacetTests extends RefineTest {
+ "}"; + "}";
//Add the facet to the project and create a row filter //Add the facet to the project and create a row filter
facet = new ListFacet(); ListFacetConfig facetConfig = new ListFacetConfig();
listfacetconfig = new JSONObject(facetconfig); facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
facet.initializeFromJSON(project,listfacetconfig); Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project); rowfilter = facet.getRowFilter(project);
//Check each row in the project against the filter //Check each row in the project against the filter
@ -251,7 +250,7 @@ public class TextListFacetTests extends RefineTest {
@Test @Test
public void testIntegerSelection() throws Exception { public void testIntegerSelection() throws Exception {
String facetconfig = "{" String jsonConfig = "{"
+ "\"type\": \"list\"," + "\"type\": \"list\","
+ "\"name\": \"Value\"," + "\"name\": \"Value\","
+ "\"columnName\": \"" + columnName + "\"," + "\"columnName\": \"" + columnName + "\","
@ -268,9 +267,9 @@ public class TextListFacetTests extends RefineTest {
+ "}"; + "}";
//Add the facet to the project and create a row filter //Add the facet to the project and create a row filter
facet = new ListFacet(); ListFacetConfig facetConfig = new ListFacetConfig();
listfacetconfig = new JSONObject(facetconfig); facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
facet.initializeFromJSON(project,listfacetconfig); Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project); rowfilter = facet.getRowFilter(project);
//Check each row in the project against the filter //Check each row in the project against the filter
@ -314,7 +313,7 @@ public class TextListFacetTests extends RefineTest {
@Test @Test
public void testBooleanSelection() throws Exception { public void testBooleanSelection() throws Exception {
String facetconfig = "{" String jsonConfig = "{"
+ "\"type\": \"list\"," + "\"type\": \"list\","
+ "\"name\": \"Value\"," + "\"name\": \"Value\","
+ "\"columnName\": \"" + columnName + "\"," + "\"columnName\": \"" + columnName + "\","
@ -331,9 +330,9 @@ public class TextListFacetTests extends RefineTest {
+ "}"; + "}";
//Add the facet to the project and create a row filter //Add the facet to the project and create a row filter
facet = new ListFacet(); ListFacetConfig facetConfig = new ListFacetConfig();
listfacetconfig = new JSONObject(facetconfig); facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
facet.initializeFromJSON(project,listfacetconfig); Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project); rowfilter = facet.getRowFilter(project);
//Check each row in the project against the filter //Check each row in the project against the filter
@ -377,7 +376,7 @@ public class TextListFacetTests extends RefineTest {
@Test @Test
public void testBlankSelection() throws Exception { public void testBlankSelection() throws Exception {
String facetconfig = "{" String jsonConfig = "{"
+ "\"type\": \"list\"," + "\"type\": \"list\","
+ "\"name\": \"Value\"," + "\"name\": \"Value\","
+ "\"columnName\": \"" + columnName + "\"," + "\"columnName\": \"" + columnName + "\","
@ -394,9 +393,9 @@ public class TextListFacetTests extends RefineTest {
+ "}"; + "}";
//Add the facet to the project and create a row filter //Add the facet to the project and create a row filter
facet = new ListFacet(); ListFacetConfig facetConfig = new ListFacetConfig();
listfacetconfig = new JSONObject(facetconfig); facetConfig.initializeFromJSON(new JSONObject(jsonConfig));
facet.initializeFromJSON(project,listfacetconfig); Facet facet = facetConfig.apply(project);
rowfilter = facet.getRowFilter(project); rowfilter = facet.getRowFilter(project);
//Check each row in the project against the filter //Check each row in the project against the filter