CancelableDiff implements NodeStateDiff { @Override public final boolean childNodeDeleted(String name, NodeState before) { if (canceled.get()) { return false; } return delegate.childNodeDeleted(name, before); } CancelableDiff(NodeStateDiff delegate, Supplier<Boolean> canceled); @Override final boolean propertyAdded(PropertyState after); @Override final boolean propertyChanged(PropertyState before, PropertyState after); @Override final boolean propertyDeleted(PropertyState before); @Override final boolean childNodeAdded(String name, NodeState after); @Override final boolean childNodeChanged(String name, NodeState before, NodeState after); @Override final boolean childNodeDeleted(String name, NodeState before);  }
@Test public void testChildNodeDeletedInterruptible() throws Throwable { NodeState before = mock(NodeState.class); NodeStateDiff wrapped = mock(NodeStateDiff.class); doReturn(true).when(wrapped).childNodeDeleted("name", before); assertTrue(newCancelableDiff(wrapped, false).childNodeDeleted("name", before)); assertFalse(newCancelableDiff(wrapped, true).childNodeDeleted("name", before)); }