use of com.linkedin.data.transform.DataProcessingException in project rest.li by linkedin.
the class TestPatchOnData method testMergingSimpleTypeValueWithComplexPatchNotSupported.
@Test
public void testMergingSimpleTypeValueWithComplexPatchNotSupported() throws JsonParseException, IOException, DataProcessingException {
DataComplexProcessor processor = new DataComplexProcessor(new Patch(), //command $set should be used
dataMapFromString("{ \"a\": { \"b\": 1} }"), dataMapFromString("{\"a\": 1}"));
boolean thrown = false;
try {
processor.run(false);
} catch (DataProcessingException e) {
thrown = true;
}
if (!thrown)
fail("expected DataProcessingException to be thrown");
}
use of com.linkedin.data.transform.DataProcessingException in project rest.li by linkedin.
the class TestPatchOnData method testSetAndBeBranchAtSameTime.
@Test
public void testSetAndBeBranchAtSameTime() throws JsonParseException, IOException, DataProcessingException {
DataComplexProcessor processor = new DataComplexProcessor(new Patch(), dataMapFromString(//command $set should be used
"{ \"b\": { \"$set\": { \"b\": 1} }, \"$set\": {\"b\": 1} }"), dataMapFromString("{\"a\": 1}"));
boolean thrown = false;
try {
processor.run(false);
} catch (DataProcessingException e) {
thrown = true;
}
if (!thrown)
fail("expected DataProcessingException to be thrown");
}
use of com.linkedin.data.transform.DataProcessingException in project rest.li by linkedin.
the class AbstractFilter method compose.
/**
* Returns composition of two masks. This method does not modify any of the parameters
* and returned mask is new object. Composition is achieved by invoking separate data
* processing. If there was an error during mask composition, then null is returned.
*
* @param mask1 first mask
* @param mask2 second mask
* @return composed masks or null if there was an error during composition fast-fail
* mode
*/
private DataMap compose(String fieldName, DataMap mask1, DataMap mask2) {
// precondition:
assert mask2 != null;
assert mask1 != null;
try {
final DataMap clone = mask1.copy();
new DataComplexProcessor(new MaskComposition(), mask2, clone).run(true);
return clone;
} catch (CloneNotSupportedException e) {
onError(fieldName, "could not clone mask: %1$s, exception: %2$s", mask1, e);
} catch (DataProcessingException e) {
onError(fieldName, "error composing mask %1$s with %2$s, exception: %3$s", mask1, mask2, e);
}
return null;
}
use of com.linkedin.data.transform.DataProcessingException in project rest.li by linkedin.
the class TestFilter method testPathIncludedInError.
@Test
public void testPathIncludedInError() throws JsonParseException, IOException, DataProcessingException {
DataMap data = dataMapFromString("{ 'a': { 'x': 'a'}}".replace('\'', '"'));
DataMap filter = dataMapFromString("{ 'a': { 'x': { 'y': 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");
Message m = e.getMessages().get(0);
assertNotNull(m.getPath(), "path should be set on a message");
assertEquals(m.getPath(), new Object[] { "a", "x" });
thrown = true;
}
assertEquals(thrown, true, "exception should have been thrown");
}
use of com.linkedin.data.transform.DataProcessingException 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");
}
Aggregations