Search in sources :

Example 21 with Cell

use of com.google.refine.model.Cell in project OpenRefine by OpenRefine.

the class TsvExporterTests method exportTsvWithComma.

@Test
public void exportTsvWithComma() {
    CreateGrid(3, 3);
    project.rows.get(1).cells.set(1, new Cell("with\t tab", null));
    try {
        SUT.export(project, options, engine, writer);
    } catch (IOException e) {
        Assert.fail();
    }
    Assert.assertEquals(writer.toString(), "column0\tcolumn1\tcolumn2\n" + "row0cell0\trow0cell1\trow0cell2\n" + "row1cell0\t\"with\t tab\"\trow1cell2\n" + "row2cell0\trow2cell1\trow2cell2\n");
}
Also used : IOException(java.io.IOException) Cell(com.google.refine.model.Cell) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Example 22 with Cell

use of com.google.refine.model.Cell in project OpenRefine by OpenRefine.

the class TsvExporterTests method CreateGrid.

protected void CreateGrid(int noOfRows, int noOfColumns) {
    CreateColumns(noOfColumns);
    for (int i = 0; i < noOfRows; i++) {
        Row row = new Row(noOfColumns);
        for (int j = 0; j < noOfColumns; j++) {
            row.cells.add(new Cell("row" + i + "cell" + j, null));
        }
        project.rows.add(row);
    }
}
Also used : Row(com.google.refine.model.Row) Cell(com.google.refine.model.Cell)

Example 23 with Cell

use of com.google.refine.model.Cell in project OpenRefine by OpenRefine.

the class TsvExporterTests method exportTsvWithLineBreaks.

@Test
public void exportTsvWithLineBreaks() {
    CreateGrid(3, 3);
    project.rows.get(1).cells.set(1, new Cell("line\n\n\nbreak", null));
    try {
        SUT.export(project, options, engine, writer);
    } catch (IOException e) {
        Assert.fail();
    }
    Assert.assertEquals(writer.toString(), "column0\tcolumn1\tcolumn2\n" + "row0cell0\trow0cell1\trow0cell2\n" + "row1cell0\t\"line\n\n\nbreak\"\trow1cell2\n" + "row2cell0\trow2cell1\trow2cell2\n");
}
Also used : IOException(java.io.IOException) Cell(com.google.refine.model.Cell) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Example 24 with Cell

use of com.google.refine.model.Cell in project OpenRefine by OpenRefine.

the class ImporterUtilitiesTests method ensureColumnsInRowExistDoesExpand.

@Test
public void ensureColumnsInRowExistDoesExpand() {
    Row row = new Row(4);
    for (int i = 1; i < 5; i++) {
        row.cells.add(new Cell("value" + i, null));
    }
    ArrayList<String> columnNames = new ArrayList<String>(2);
    ImporterUtilities.ensureColumnsInRowExist(columnNames, row);
    Assert.assertEquals(row.cells.size(), 4);
    Assert.assertEquals(columnNames.size(), 4);
}
Also used : ArrayList(java.util.ArrayList) Row(com.google.refine.model.Row) Cell(com.google.refine.model.Cell) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Example 25 with Cell

use of com.google.refine.model.Cell in project OpenRefine by OpenRefine.

the class RowTests method nonBlankCell.

@Test
public void nonBlankCell() {
    Row row = new Row(5);
    row.setCell(0, new Cell("I'm not empty", null));
    Assert.assertFalse(row.isCellBlank(0));
    row.setCell(3, new Cell("I'm not empty", null));
    Assert.assertFalse(row.isCellBlank(3));
}
Also used : Row(com.google.refine.model.Row) Cell(com.google.refine.model.Cell) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) RefineTest(com.google.refine.tests.RefineTest)

Aggregations

Cell (com.google.refine.model.Cell)58 Row (com.google.refine.model.Row)36 Column (com.google.refine.model.Column)19 Test (org.testng.annotations.Test)16 RefineTest (com.google.refine.tests.RefineTest)15 BeforeTest (org.testng.annotations.BeforeTest)15 JSONObject (org.json.JSONObject)13 ArrayList (java.util.ArrayList)12 Project (com.google.refine.model.Project)11 IOException (java.io.IOException)11 Properties (java.util.Properties)11 JSONException (org.json.JSONException)9 RowVisitor (com.google.refine.browsing.RowVisitor)7 HistoryEntry (com.google.refine.history.HistoryEntry)7 Serializable (java.io.Serializable)7 Recon (com.google.refine.model.Recon)6 CellChange (com.google.refine.model.changes.CellChange)6 HashMap (java.util.HashMap)6 Evaluable (com.google.refine.expr.Evaluable)5 JSONArray (org.json.JSONArray)4