Search in sources :

Example 26 with PatchTree

use of com.linkedin.data.transform.patch.request.PatchTree in project rest.li by linkedin.

the class TestRestLiMethodInvocation method testCustomCrudParamsCollectionPartialUpdate.

@Test(dataProvider = TestConstants.RESTLI_PROTOCOL_1_2_PREFIX + "paramCollectionPartialUpdate")
public void testCustomCrudParamsCollectionPartialUpdate(ProtocolVersion version, String uri, String body) throws Exception {
    ResourceModel model = buildResourceModel(CombinedResources.CollectionWithCustomCrudParams.class);
    ResourceMethodDescriptor methodDescriptor = model.findMethod(ResourceMethod.PARTIAL_UPDATE);
    CombinedResources.CollectionWithCustomCrudParams resource = getMockResource(CombinedResources.CollectionWithCustomCrudParams.class);
    PatchTree p = new PatchTree();
    p.addOperation(new PathSpec("foo"), PatchOpFactory.setFieldOp(Integer.valueOf(42)));
    PatchRequest<CombinedTestDataModels.Foo> expected = PatchRequest.createFromPatchDocument(p.getDataMap());
    EasyMock.expect(resource.myUpdate(eq("foo"), eq(expected), eq(1), eq("bar"))).andReturn(null).once();
    checkInvocation(resource, methodDescriptor, "POST", version, uri, body, buildPathKeys("testId", "foo"));
}
Also used : CombinedResources(com.linkedin.restli.server.combined.CombinedResources) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) PathSpec(com.linkedin.data.schema.PathSpec) PatchTree(com.linkedin.data.transform.patch.request.PatchTree) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 27 with PatchTree

use of com.linkedin.data.transform.patch.request.PatchTree 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());
}
Also used : CombinedResources(com.linkedin.restli.server.combined.CombinedResources) ResourceMethodDescriptor(com.linkedin.restli.internal.server.model.ResourceMethodDescriptor) ResourceModel(com.linkedin.restli.internal.server.model.ResourceModel) RestLiTestHelper.buildResourceModel(com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel) PathSpec(com.linkedin.data.schema.PathSpec) PatchTree(com.linkedin.data.transform.patch.request.PatchTree) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

PatchTree (com.linkedin.data.transform.patch.request.PatchTree)27 Test (org.testng.annotations.Test)27 DataMap (com.linkedin.data.DataMap)18 PathSpec (com.linkedin.data.schema.PathSpec)9 Group (com.linkedin.restli.examples.groups.api.Group)9 DataList (com.linkedin.data.DataList)5 PatchTreeTestModel (com.linkedin.restli.client.util.test.PatchTreeTestModel)5 ResourceMethodDescriptor (com.linkedin.restli.internal.server.model.ResourceMethodDescriptor)5 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)5 RestLiTestHelper.buildResourceModel (com.linkedin.restli.server.test.RestLiTestHelper.buildResourceModel)5 AfterTest (org.testng.annotations.AfterTest)5 BeforeTest (org.testng.annotations.BeforeTest)5 DataComplexProcessor (com.linkedin.data.transform.DataComplexProcessor)4 Patch (com.linkedin.data.transform.patch.Patch)4 RemoveFieldOp (com.linkedin.data.transform.patch.request.RemoveFieldOp)4 ByteString (com.linkedin.data.ByteString)3 HttpStatus (com.linkedin.restli.common.HttpStatus)3 CustomString (com.linkedin.restli.server.custom.types.CustomString)3 DiscoveredItem (com.linkedin.restli.server.twitter.TwitterTestDataModels.DiscoveredItem)3 DiscoveredItemKey (com.linkedin.restli.server.twitter.TwitterTestDataModels.DiscoveredItemKey)3