use of com.linkedin.restli.examples.groups.api.Group in project rest.li by linkedin.
the class TestPatchGeneration method testRoundtripModifyEscapedField.
@Test(groups = { TestConstants.TESTNG_GROUP_KNOWN_ISSUE })
void testRoundtripModifyEscapedField() throws Exception {
Group g1 = new Group();
g1.data().put("$foo", new DataMap());
Group g2 = new Group(g1.data().copy());
((DataMap) g2.data().get("$foo")).put("bar", 42);
PatchTree update = PatchCreator.diff(g1, g2);
// "{$$foo={$set={bar=42}}}"
final DataMap setMap = new DataMap();
final DataMap barMap = new DataMap();
barMap.put("bar", 42);
setMap.put(PatchConstants.SET_COMMAND, barMap);
final DataMap fooMap = new DataMap();
fooMap.put("$$foo", setMap);
assertEquals(update.getDataMap(), fooMap, "PatchTree DataMap must 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.restli.examples.groups.api.Group 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.restli.examples.groups.api.Group in project rest.li by linkedin.
the class TestPatchGeneration method testDiffRemove.
@Test
void testDiffRemove() throws Exception {
Group g1 = new Group();
g1.setId(17);
g1.setDescription("Some description");
Group g2 = new Group(g1.data().copy());
g2.removeDescription();
PatchTree update = PatchCreator.diff(g1, g2);
// "{$delete=[description]}"
final DataMap deleteMap = new DataMap();
final DataList descriptionList = new DataList();
descriptionList.add("description");
deleteMap.put(PatchConstants.DELETE_COMMAND, descriptionList);
assertEquals(update.getDataMap(), deleteMap, "PatchTree DataMap should be correct");
}
use of com.linkedin.restli.examples.groups.api.Group in project rest.li by linkedin.
the class TestPatchGeneration method testDiffFromNull.
@Test
public void testDiffFromNull() throws Exception {
Group g1 = new Group();
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 internalSetMap = new DataMap();
internalSetMap.put("id", 42);
internalSetMap.put("name", "Some Group");
final DataMap setMap = new DataMap();
setMap.put(PatchConstants.SET_COMMAND, internalSetMap);
assertEquals(update.getDataMap(), setMap, "PatchTree DataMap should be correct");
}
use of com.linkedin.restli.examples.groups.api.Group in project rest.li by linkedin.
the class TestPatchGeneration method testDiffFromNonNull.
@Test
void testDiffFromNonNull() 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 internalSetMap = new DataMap();
internalSetMap.put("id", 42);
internalSetMap.put("name", "Some Group");
final DataMap setMap = new DataMap();
setMap.put(PatchConstants.SET_COMMAND, internalSetMap);
assertEquals(update.getDataMap(), setMap, "PatchTree DataMap should be correct");
}
Aggregations