use of com.linkedin.data.transform.DataComplexProcessor in project rest.li by linkedin.
the class TestMaskComposition method testCompositionOfIncorrectRanges.
@Test
public void testCompositionOfIncorrectRanges() throws JsonParseException, IOException, DataProcessingException {
DataMap f1 = dataMapFromString("{ 'a': { '$start': -2, '$count': -3}}".replace('\'', '"'));
DataMap f2 = dataMapFromString("{ 'a': { '$start': 0}}".replace('\'', '"'));
DataComplexProcessor processor = new DataComplexProcessor(new MaskComposition(), f2, f1);
boolean thrown = false;
try {
processor.run(false);
} catch (DataProcessingException e) {
assertEquals(e.getMessages().size(), 2, "expected exactly 2 errors");
thrown = true;
}
assertEquals(thrown, true, "exception should have been thrown");
}
use of com.linkedin.data.transform.DataComplexProcessor in project rest.li by linkedin.
the class TestPatchOnData method testInvalidPatch.
@Test(dataProvider = "invalidPatch")
public void testInvalidPatch(String description, String data, String patch) throws IOException, DataProcessingException {
DataComplexProcessor processor = new DataComplexProcessor(new Patch(), dataMapFromString(patch), dataMapFromString(data));
boolean thrown = false;
try {
processor.run(false);
} catch (DataProcessingException e) {
thrown = true;
}
if (!thrown) {
fail(description + " - expected DataProcessingException to be thrown");
}
}
use of com.linkedin.data.transform.DataComplexProcessor in project rest.li by linkedin.
the class TestFilter method testFastFailError.
@Test
public void testFastFailError() throws JsonParseException, IOException, DataProcessingException {
DataMap data = dataMapFromString("{ 'a': { 'x': 'a'}, 'b': 'b'}".replace('\'', '"'));
DataMap filter = dataMapFromString("{ 'a': { 'x': { 'y': 1}}, 'b': { 'z': 1}}".replace('\'', '"'));
DataComplexProcessor processor = new DataComplexProcessor(new Filter(), filter, data);
boolean thrown = false;
try {
processor.run(true);
} catch (DataProcessingException e) {
assertEquals(e.getMessages().size(), 1, "expected exactly 1 error in fast fail mode");
thrown = true;
}
assertEquals(thrown, true, "exception should have been thrown");
}
use of com.linkedin.data.transform.DataComplexProcessor in project rest.li by linkedin.
the class TestFilter method testErrorMessagesForArraysNotFastFail.
@Test
public void testErrorMessagesForArraysNotFastFail() throws JsonParseException, IOException, DataProcessingException {
DataMap data = dataMapFromString("{ 'a': [1, 2, 3, 4, 5]}".replace('\'', '"'));
DataMap filter = dataMapFromString("{ 'a': { '$*': { 'y': 1}}}".replace('\'', '"'));
DataComplexProcessor processor = new DataComplexProcessor(new Filter(), filter, data);
boolean thrown = false;
try {
processor.run(false);
} catch (DataProcessingException e) {
assertEquals(e.getMessages().size(), 5, "expected exactly 5 errors in non fast fail mode");
thrown = true;
}
assertEquals(thrown, true, "exception should have been thrown");
}
use of com.linkedin.data.transform.DataComplexProcessor in project rest.li by linkedin.
the class TestFilter method testInvalidArrayRangeInFilter.
@Test
public void testInvalidArrayRangeInFilter() throws JsonParseException, IOException, DataProcessingException {
DataMap data = dataMapFromString("{ 'a': [1, 2, 3, 4, 5]}".replace('\'', '"'));
DataMap filter = dataMapFromString("{ 'a': { '$start': -2, '$count': -1}}".replace('\'', '"'));
DataComplexProcessor processor = new DataComplexProcessor(new Filter(), filter, data);
boolean thrown = false;
try {
processor.run(false);
} catch (DataProcessingException e) {
assertEquals(e.getMessages().size(), 2);
thrown = true;
}
assertEquals(thrown, true, "exception should have been thrown");
}
Aggregations