use of com.linkedin.data.transform.DataComplexProcessor in project rest.li by linkedin.
the class TestPatchGeneration method testRoundtripAddEscapedField.
@Test
void testRoundtripAddEscapedField() throws Exception {
Group g1 = new Group();
g1.setId(17);
g1.setDescription("Some description");
Group g2 = new Group(g1.data().copy());
g2.data().put("$foo", "value");
PatchTree update = PatchCreator.diff(g1, g2);
// "{$set={$foo=value}}"
final DataMap setMap = new DataMap();
final DataMap fooMap = new DataMap();
fooMap.put("$foo", "value");
setMap.put(PatchConstants.SET_COMMAND, fooMap);
assertEquals(update.getDataMap(), setMap, "PatchTree DataMap should be correct");
assertFalse(g1.equals(g2));
DataComplexProcessor processor = new DataComplexProcessor(new Patch(), update.getDataMap(), g1.data());
processor.run(false);
assertEquals(g1, g2);
}
use of com.linkedin.data.transform.DataComplexProcessor in project rest.li by linkedin.
the class TestPatchGeneration method testRoundtripAddFields.
@Test
void testRoundtripAddFields() throws Exception {
Group g1 = new Group();
g1.setId(17);
g1.setDescription("Some description");
Group g2 = new Group(g1.data().copy());
g2.setId(42);
g2.setName("Some Group");
PatchTree update = PatchCreator.diff(g1, g2);
// "{$set={id=42, name=Some Group}}"
final DataMap setMap = new DataMap();
final DataMap idNameMap = new DataMap();
idNameMap.put("id", 42);
idNameMap.put("name", "Some Group");
setMap.put(PatchConstants.SET_COMMAND, idNameMap);
assertEquals(update.getDataMap(), setMap, "PatchTree DataMap should be correct");
assertFalse(g1.equals(g2));
DataComplexProcessor processor = new DataComplexProcessor(new Patch(), update.getDataMap(), g1.data());
processor.run(false);
assertEquals(g1, g2);
}
Aggregations