use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestRestLiMethodInvocation method testCustomCrudParamsSimplePartialUpdate.
@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "paramSimple")
public void testCustomCrudParamsSimplePartialUpdate(ProtocolVersion version, String uri) throws Exception {
ResourceModel model = buildResourceModel(CombinedResources.SimpleResourceWithCustomCrudParams.class);
ResourceMethodDescriptor methodDescriptor = model.findMethod(ResourceMethod.PARTIAL_UPDATE);
CombinedResources.SimpleResourceWithCustomCrudParams resource = getMockResource(CombinedResources.SimpleResourceWithCustomCrudParams.class);
PatchTree p = new PatchTree();
p.addOperation(new PathSpec("foo"), PatchOpFactory.setFieldOp(Integer.valueOf(51)));
PatchRequest<CombinedTestDataModels.Foo> expected = PatchRequest.createFromPatchDocument(p.getDataMap());
EasyMock.expect(resource.myPartialUpdate(eq(expected), eq(1), eq("bar"))).andReturn(null).once();
checkInvocation(resource, methodDescriptor, "POST", version, uri, "{\"patch\":{\"$set\":{\"foo\":51}}}", buildBatchPathKeys());
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestRestUtils method testOverrideMask.
@Test
public void testOverrideMask() throws CloneNotSupportedException {
RecordBar bar = new RecordBar();
bar.setLocation("mountain view");
bar.data().put("SF", "CA");
RecordBar expected = bar.clone();
MaskTree maskTree = new MaskTree();
maskTree.addOperation(new PathSpec("SF"), MaskOperation.POSITIVE_MASK_OP);
RestUtils.trimRecordTemplate(bar, maskTree, false);
Assert.assertEquals(bar, expected);
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestRestUtils method testOverrideMaskNestedWithMap.
@Test
public void testOverrideMaskNestedWithMap() throws CloneNotSupportedException {
TyperefTest test = new TyperefTest();
RecordBar bar = new RecordBar();
bar.setLocation("foo");
bar.data().put("bar", "keep me");
RecordBar expected = bar.clone();
test.setBarRefMap(new RecordBarMap());
test.getBarRefMap().put("foo", bar);
MaskTree maskTree = new MaskTree();
maskTree.addOperation(new PathSpec("barRefMap", PathSpec.WILDCARD, "location"), MaskOperation.POSITIVE_MASK_OP);
maskTree.addOperation(new PathSpec("barRefMap", PathSpec.WILDCARD, "bar"), MaskOperation.POSITIVE_MASK_OP);
RestUtils.trimRecordTemplate(test, maskTree, false);
Assert.assertEquals(test.getBarRefMap().get("foo"), expected);
}
use of com.linkedin.data.schema.PathSpec in project rest.li by linkedin.
the class TestRestUtils method testOverrideMaskNestedRecord.
@Test
public void testOverrideMaskNestedRecord() throws CloneNotSupportedException {
LinkedListNode node1 = new LinkedListNode();
node1.setIntField(1);
LinkedListNode node2 = new LinkedListNode();
node2.setIntField(2);
node1.setNext(node2);
node2.data().put("keep me", "foo");
MaskTree maskTree = new MaskTree();
maskTree.addOperation(new PathSpec("next", "keep me"), MaskOperation.POSITIVE_MASK_OP);
maskTree.addOperation(new PathSpec("next", "intField"), MaskOperation.POSITIVE_MASK_OP);
LinkedListNode expected = node2.clone();
RestUtils.trimRecordTemplate(node1, maskTree, false);
Assert.assertEquals(node1.getNext(), expected);
}
Aggregations