@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());