use of com.yahoo.bullet.parsing.ParsingError in project bullet-core by yahoo.
the class MetaTest method testErrorsAddition.
@Test
public void testErrorsAddition() {
ParsingError errorA = new ParsingError("foo", asList("1", "2"));
ParsingError errorB = new ParsingError("bar", asList("3", "4"));
Meta meta = Meta.of(errorA, errorB);
Map<String, Object> actual = meta.asMap();
Assert.assertEquals(actual.size(), 1);
List<ParsingError> actualErrors = (List<ParsingError>) actual.get(Meta.ERROR_KEY);
Assert.assertEquals(actualErrors.size(), 2);
Assert.assertEquals(actualErrors.get(0).getError(), "foo");
Assert.assertEquals(actualErrors.get(0).getResolutions(), asList("1", "2"));
Assert.assertEquals(actualErrors.get(1).getError(), "bar");
Assert.assertEquals(actualErrors.get(1).getResolutions(), asList("3", "4"));
ParsingError errorC = new ParsingError("baz", asList("5", "6"));
ParsingError errorD = new ParsingError("qux", singletonList("7"));
meta.addErrors(Arrays.asList(errorC, errorD));
Assert.assertEquals(actualErrors.size(), 4);
Assert.assertEquals(actualErrors.get(0).getError(), "foo");
Assert.assertEquals(actualErrors.get(0).getResolutions(), asList("1", "2"));
Assert.assertEquals(actualErrors.get(1).getError(), "bar");
Assert.assertEquals(actualErrors.get(1).getResolutions(), asList("3", "4"));
Assert.assertEquals(actualErrors.get(2).getError(), "baz");
Assert.assertEquals(actualErrors.get(2).getResolutions(), asList("5", "6"));
Assert.assertEquals(actualErrors.get(3).getError(), "qux");
Assert.assertEquals(actualErrors.get(3).getResolutions(), singletonList("7"));
}
Aggregations