Search in sources :

Example 1 with WrappedRow

use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.

the class CrossTests method crossFunctionBooleanArgumentTest1.

@Test
public void crossFunctionBooleanArgumentTest1() throws Exception {
    Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", "true", "My Address Book", "friend")).get(0)).row);
    String address = row.getCell(1).value.toString();
    Assert.assertEquals(address, "boolean");
}
Also used : HasFieldsListImpl(com.google.refine.expr.HasFieldsListImpl) WrappedRow(com.google.refine.expr.WrappedRow) Row(com.google.refine.model.Row) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with WrappedRow

use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.

the class CrossTests method crossFunctionDifferentColumnTest.

/**
 * The result shouldn't depend on the based column in "bindings" when the first argument is a WrappedCell instance.
 */
@Test
public void crossFunctionDifferentColumnTest() throws Exception {
    Project project = (Project) bindings.get("project");
    // change the based column
    bindings.put("columnName", "gift");
    Cell c = project.rows.get(0).cells.get(1);
    WrappedCell lookup = new WrappedCell(project, "recipient", c);
    Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", lookup, "My Address Book", "friend")).get(0)).row);
    String address = row.getCell(1).value.toString();
    Assert.assertEquals(address, "50 Broadway Ave.");
}
Also used : Project(com.google.refine.model.Project) WrappedCell(com.google.refine.expr.WrappedCell) HasFieldsListImpl(com.google.refine.expr.HasFieldsListImpl) WrappedRow(com.google.refine.expr.WrappedRow) Row(com.google.refine.model.Row) Cell(com.google.refine.model.Cell) WrappedCell(com.google.refine.expr.WrappedCell) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 3 with WrappedRow

use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.

the class CrossTests method crossFunctionLongArgumentTest.

@Test
public void crossFunctionLongArgumentTest() throws Exception {
    Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", 123456789123456789L, "My Address Book", "friend")).get(0)).row);
    String address = row.getCell(1).value.toString();
    Assert.assertEquals(address, "long");
}
Also used : HasFieldsListImpl(com.google.refine.expr.HasFieldsListImpl) WrappedRow(com.google.refine.expr.WrappedRow) Row(com.google.refine.model.Row) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 4 with WrappedRow

use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.

the class CrossTests method crossFunctionOneToManyTest.

/**
 * To demonstrate that the cross function can look up multiple rows.
 */
@Test
public void crossFunctionOneToManyTest() throws Exception {
    Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", "john", "My Address Book", "friend")).get(1)).row);
    String address = row.getCell(1).value.toString();
    Assert.assertEquals(address, "999 XXXXXX St.");
}
Also used : HasFieldsListImpl(com.google.refine.expr.HasFieldsListImpl) WrappedRow(com.google.refine.expr.WrappedRow) Row(com.google.refine.model.Row) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 5 with WrappedRow

use of com.google.refine.expr.WrappedRow in project OpenRefine by OpenRefine.

the class CrossTests method crossFunctionDoubleArgumentTest.

@Test
public void crossFunctionDoubleArgumentTest() throws Exception {
    Row row = (((WrappedRow) ((HasFieldsListImpl) invoke("cross", 3.14, "My Address Book", "friend")).get(0)).row);
    String address = row.getCell(1).value.toString();
    Assert.assertEquals(address, "double");
}
Also used : HasFieldsListImpl(com.google.refine.expr.HasFieldsListImpl) WrappedRow(com.google.refine.expr.WrappedRow) Row(com.google.refine.model.Row) RefineTest(com.google.refine.RefineTest) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

WrappedRow (com.google.refine.expr.WrappedRow)26 Row (com.google.refine.model.Row)26 RefineTest (com.google.refine.RefineTest)25 HasFieldsListImpl (com.google.refine.expr.HasFieldsListImpl)25 BeforeTest (org.testng.annotations.BeforeTest)25 Test (org.testng.annotations.Test)25 Project (com.google.refine.model.Project)6 WrappedCell (com.google.refine.expr.WrappedCell)5 Cell (com.google.refine.model.Cell)5 Column (com.google.refine.model.Column)1 LookupException (com.google.refine.util.LookupException)1