Add cell.error field for error messages (#2363)

* Add case for querying cell.error for error messages

* Add testing file

* Refactor test case for cell with error

* Reformat spaces
This commit is contained in:
zengchu2 2020-03-10 06:14:15 -04:00 committed by GitHub
parent 27f7cdc897
commit c90fd31daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -73,6 +73,8 @@ public class Cell implements HasFields {
return value;
} else if ("recon".equals(name)) {
return recon;
} else if ("error".equals(name)) {
return getErrorMessage();
}
return null;
}

View File

@ -30,12 +30,14 @@ import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.testng.annotations.Test;
import com.google.refine.expr.EvalError;
import com.google.refine.model.Cell;
import com.google.refine.model.Recon;
import com.google.refine.util.Pool;
@ -93,7 +95,16 @@ public class CellTests {
Cell c = Cell.loadStreaming(json, pool);
TestUtils.isSerializedTo(c, json);
}
@Test
public void getMessageFromErrorCell() throws Exception {
String errorMessage = "Sample error message";
EvalError err = new EvalError(errorMessage);
Cell c = new Cell(err, null);
assertEquals(c.getField("error", null), errorMessage);
assertEquals(c.getField("value", null), err);
}
@Test
public void serializeDateCell() throws Exception {
String json = "{\"v\":\"2018-03-04T08:09:10Z\",\"t\":\"date\"}";