use of com.linkedin.restli.examples.groups.api.Group in project rest.li by linkedin.
the class TestPatchGeneration method testDiffFromOverwrittenNested.
@Test
public void testDiffFromOverwrittenNested() throws Exception {
Group g1 = new Group();
Location loc1 = new Location();
loc1.setLatitude(0.0f);
loc1.setLongitude(0.0f);
g1.setLocation(loc1);
Group g2 = new Group(g1.data().copy());
Location loc2 = new Location();
loc2.setLatitude(42.0f);
loc2.setLongitude(17.0f);
g2.setLocation(loc2);
PatchTree update = PatchCreator.diff(g1, g2);
// "{location={$set={longitude=17.0, latitude=42.0}}}"
final DataMap setMap = new DataMap();
final DataMap longLatMap = new DataMap();
longLatMap.put("longitude", 17.0f);
longLatMap.put("latitude", 42.0f);
setMap.put(PatchConstants.SET_COMMAND, longLatMap);
final DataMap locationMap = new DataMap();
locationMap.put("location", setMap);
Assert.assertEquals(update.getDataMap(), locationMap, "PatchTree DataMap should be correct");
}
use of com.linkedin.restli.examples.groups.api.Group 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);
}
use of com.linkedin.restli.examples.groups.api.Group in project rest.li by linkedin.
the class TestGroupsRequestBuilders method testEntityUpdate.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "requestGroupsBuilderDataProviderEntity")
public void testEntityUpdate(RootBuilderWrapper<Integer, Group> builders, URIDetails expectedURIDetails) throws IOException, RestException {
Request<EmptyRecord> request = builders.partialUpdate().id(1).input(new PatchRequest<>()).build();
checkRequestBuilder(request, ResourceMethod.PARTIAL_UPDATE, EmptyResponseDecoder.class, expectedURIDetails, new Group());
}
Aggregations