Search in sources :

Example 1 with ParsingError

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"));
}
Also used : ParsingError(com.yahoo.bullet.parsing.ParsingError) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) Arrays.asList(java.util.Arrays.asList) Test(org.testng.annotations.Test)

Aggregations

ParsingError (com.yahoo.bullet.parsing.ParsingError)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 Test (org.testng.annotations.Test)1