Search in sources :

Example 6 with PatchTreeTestModel

use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.

the class TestPatchTreeRecorder method testSetCoerceEnum.

@Test
public void testSetCoerceEnum() {
    PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
    pc.getRecordingProxy().setFooEnum(FooEnum.A);
    Assert.assertEquals(pc.generatePatchTree().getDataMap(), diffEmpty(new PatchTreeTestModel().setFooEnum(FooEnum.A)));
}
Also used : PatchTreeTestModel(com.linkedin.restli.client.util.test.PatchTreeTestModel) Test(org.testng.annotations.Test)

Example 7 with PatchTreeTestModel

use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.

the class TestPatchTreeRecorder method testSetBytes.

@Test
public void testSetBytes() {
    PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
    pc.getRecordingProxy().setFooByteString(ByteString.copyString("foo", "UTF-8"));
    Assert.assertEquals(pc.generatePatchTree().getDataMap(), diffEmpty(new PatchTreeTestModel().setFooByteString(ByteString.copyString("foo", "UTF-8"))));
}
Also used : PatchTreeTestModel(com.linkedin.restli.client.util.test.PatchTreeTestModel) Test(org.testng.annotations.Test)

Example 8 with PatchTreeTestModel

use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.

the class TestPatchTreeRecorder method testSimpleSetIgnoreNullSetMode.

@Test
public void testSimpleSetIgnoreNullSetMode() {
    PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
    pc.getRecordingProxy().setFooRequired(100).setFooOptional(null, SetMode.IGNORE_NULL);
    Assert.assertEquals(pc.generatePatchTree().getDataMap(), diffEmpty(new PatchTreeTestModel().setFooRequired(100)));
}
Also used : PatchTreeTestModel(com.linkedin.restli.client.util.test.PatchTreeTestModel) Test(org.testng.annotations.Test)

Example 9 with PatchTreeTestModel

use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.

the class TestPatchTreeRecorder method testSimpleSet.

@Test
public void testSimpleSet() {
    PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
    PatchTreeTestModel testModel = pc.getRecordingProxy();
    testModel.setFooOptional(10l);
    testModel.setFooRequired(20l);
    Assert.assertEquals(pc.generatePatchTree().getDataMap(), diffEmpty(new PatchTreeTestModel().setFooOptional(10l).setFooRequired(20l)));
}
Also used : PatchTreeTestModel(com.linkedin.restli.client.util.test.PatchTreeTestModel) Test(org.testng.annotations.Test)

Example 10 with PatchTreeTestModel

use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.

the class TestPatchTreeRecorder method testPatchGeneratesDeepCopiesOfInternalState.

@Test
public void testPatchGeneratesDeepCopiesOfInternalState() {
    PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
    PatchTreeTestModel restCommonTestModel = pc.getRecordingProxy();
    restCommonTestModel.setFooRecordTemplate(new FooRecordTemplate().setBar(10l));
    PatchTree pt1 = pc.generatePatchTree();
    restCommonTestModel.setFooRecordTemplate(new FooRecordTemplate().setBar(20l));
    PatchTree pt2 = pc.generatePatchTree();
    Assert.assertNotEquals(pt1.getDataMap(), pt2.getDataMap());
    Assert.assertEquals(pt1.getDataMap(), diffEmpty(new PatchTreeTestModel().setFooRecordTemplate(new FooRecordTemplate().setBar(10l))));
    Assert.assertEquals(pt2.getDataMap(), diffEmpty(new PatchTreeTestModel().setFooRecordTemplate(new FooRecordTemplate().setBar(20l))));
}
Also used : FooRecordTemplate(com.linkedin.restli.client.util.test.FooRecordTemplate) PatchTreeTestModel(com.linkedin.restli.client.util.test.PatchTreeTestModel) PatchTree(com.linkedin.data.transform.patch.request.PatchTree) Test(org.testng.annotations.Test)

Aggregations

PatchTreeTestModel (com.linkedin.restli.client.util.test.PatchTreeTestModel)14 Test (org.testng.annotations.Test)14 PatchTree (com.linkedin.data.transform.patch.request.PatchTree)5 RemoveFieldOp (com.linkedin.data.transform.patch.request.RemoveFieldOp)4 DataMap (com.linkedin.data.DataMap)3 FooRecordTemplate (com.linkedin.restli.client.util.test.FooRecordTemplate)2 SetFieldOp (com.linkedin.data.transform.patch.request.SetFieldOp)1