Search in sources :

Example 1 with ScatterplotFacetConfig

use of com.google.refine.browsing.facets.ScatterplotFacet.ScatterplotFacetConfig in project OpenRefine by OpenRefine.

the class ScatterplotFacetTests method serializeScatterplotFacet.

@Test
public void serializeScatterplotFacet() throws JsonParseException, JsonMappingException, IOException {
    Project project = createCSVProject("my column,e\n" + "89.2,89.2\n" + "-45.9,-45.9\n" + "blah,blah\n" + "0.4,0.4\n");
    Engine engine = new Engine(project);
    project.rows.get(0).cells.set(0, new Cell(89.2, null));
    project.rows.get(0).cells.set(1, new Cell(89.2, null));
    project.rows.get(1).cells.set(0, new Cell(-45.9, null));
    project.rows.get(1).cells.set(1, new Cell(-45.9, null));
    project.rows.get(3).cells.set(0, new Cell(0.4, null));
    project.rows.get(3).cells.set(1, new Cell(0.4, null));
    ScatterplotFacetConfig config = ParsingUtilities.mapper.readValue(configJson, ScatterplotFacetConfig.class);
    ScatterplotFacet facet = config.apply(project);
    facet.computeChoices(project, engine.getAllFilteredRows());
    TestUtils.isSerializedTo(facet, facetJson);
    RowFilter filter = facet.getRowFilter(project);
    assertTrue(filter.filterRow(project, 0, project.rows.get(0)));
    assertFalse(filter.filterRow(project, 1, project.rows.get(1)));
    assertTrue(filter.filterRow(project, 3, project.rows.get(3)));
}
Also used : ScatterplotFacet(com.google.refine.browsing.facets.ScatterplotFacet) Project(com.google.refine.model.Project) RowFilter(com.google.refine.browsing.RowFilter) ScatterplotFacetConfig(com.google.refine.browsing.facets.ScatterplotFacet.ScatterplotFacetConfig) Cell(com.google.refine.model.Cell) Engine(com.google.refine.browsing.Engine) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test)

Example 2 with ScatterplotFacetConfig

use of com.google.refine.browsing.facets.ScatterplotFacet.ScatterplotFacetConfig in project OpenRefine by OpenRefine.

the class ScatterplotFacetTests method serializeScatterplotFacetConfig.

@Test
public void serializeScatterplotFacetConfig() throws JsonParseException, JsonMappingException, IOException {
    ScatterplotFacetConfig config = ParsingUtilities.mapper.readValue(configJson, ScatterplotFacetConfig.class);
    TestUtils.isSerializedTo(config, configJson);
}
Also used : ScatterplotFacetConfig(com.google.refine.browsing.facets.ScatterplotFacet.ScatterplotFacetConfig) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test)

Aggregations

RefineTest (com.google.refine.RefineTest)2 ScatterplotFacetConfig (com.google.refine.browsing.facets.ScatterplotFacet.ScatterplotFacetConfig)2 Test (org.testng.annotations.Test)2 Engine (com.google.refine.browsing.Engine)1 RowFilter (com.google.refine.browsing.RowFilter)1 ScatterplotFacet (com.google.refine.browsing.facets.ScatterplotFacet)1 Cell (com.google.refine.model.Cell)1 Project (com.google.refine.model.Project)1