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:
parent
27f7cdc897
commit
c90fd31daf
@ -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;
|
||||
}
|
||||
|
@ -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\"}";
|
||||
|
Loading…
Reference in New Issue
Block a user