use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.
the class TestPatchTreeRecorder method testSimpleSetRemoveIfNullSetMode.
@Test
public void testSimpleSetRemoveIfNullSetMode() {
PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
PatchTreeTestModel testModel = pc.getRecordingProxy();
testModel.setFooOptional(null, SetMode.REMOVE_IF_NULL);
// Augment the patch request with the removes
PatchTree ptExpect = new PatchTree();
ptExpect.addOperation(PatchTreeTestModel.fields().fooOptional(), new RemoveFieldOp());
Assert.assertEquals(pc.generatePatchTree().getDataMap(), ptExpect.getDataMap());
}
use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.
the class TestPatchTreeRecorder method testSetRecordTemplate.
@Test
public void testSetRecordTemplate() {
PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
pc.getRecordingProxy().setFooRecordTemplate(new FooRecordTemplate().setBar(20));
PatchTreeTestModel expectModel = new PatchTreeTestModel().setFooRecordTemplate(new FooRecordTemplate().setBar(20));
Assert.assertEquals(pc.generatePatchTree().getDataMap(), diffEmpty(expectModel));
}
use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.
the class TestPatchTreeRecorder method testEmptyPatch.
@Test
public void testEmptyPatch() {
PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
Assert.assertEquals(pc.generatePatchTree().getDataMap(), new DataMap());
}
use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.
the class TestPatchTreeRecorder method testSimpleSetRemoveOptionalIfNullOnOptionalFieldPass.
@Test
public void testSimpleSetRemoveOptionalIfNullOnOptionalFieldPass() {
PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
PatchTreeTestModel restCommonTestModel = pc.getRecordingProxy();
restCommonTestModel.setFooOptional(null, SetMode.REMOVE_OPTIONAL_IF_NULL);
// Augment the patch request with the removes
PatchTree ptExpect = new PatchTree();
ptExpect.addOperation(PatchTreeTestModel.fields().fooOptional(), new RemoveFieldOp());
Assert.assertEquals(pc.generatePatchTree().getDataMap(), ptExpect.getDataMap());
}
use of com.linkedin.restli.client.util.test.PatchTreeTestModel in project rest.li by linkedin.
the class TestPatchTreeRecorder method testFluentSetWithRemove.
@Test
public void testFluentSetWithRemove() {
PatchTreeRecorder<PatchTreeTestModel> pc = makeOne();
PatchTreeTestModel testModel = pc.getRecordingProxy();
PatchTreeTestModel.FooUnion fooUnion = new PatchTreeTestModel.FooUnion();
fooUnion.setInt(10);
testModel.setFooRequired(100).setFooUnion(fooUnion).setFooRecordTemplate(null, SetMode.REMOVE_IF_NULL).removeFooOptional();
PatchTree ptExpect = PatchCreator.diff(new DataMap(), new PatchTreeTestModel().setFooRequired(100).setFooUnion(fooUnion).data());
// Augment the patch request with the removes
ptExpect.addOperation(PatchTreeTestModel.fields().fooRecordTemplate(), new RemoveFieldOp());
ptExpect.addOperation(PatchTreeTestModel.fields().fooOptional(), new RemoveFieldOp());
Assert.assertEquals(pc.generatePatchTree().getDataMap(), ptExpect.getDataMap());
}
Aggregations