@Test
    public void testDeleteNodeVoidsRemovePublishedItem() throws Exception
    {
        // Setup test fixture.
        final CachingPubsubPersistenceProvider provider = new CachingPubsubPersistenceProvider();
        final PubSubPersistenceProvider mockDelegate = Mockito.mock(PubSubPersistenceProvider.class);
        provider.delegate = mockDelegate;
        final LeafNode mockNode = Mockito.mock(LeafNode.class);
        Mockito.lenient().when(mockNode.getUniqueIdentifier()).thenReturn(new Node.UniqueIdentifier("mock-service-1", "mock-node-a"));
        final JID publisher = new JID("test-user-1", "example.org", null);
        final PublishedItem item = new PublishedItem(mockNode, publisher, UUID.randomUUID().toString(), new Date());

        // Execute system under test.
        provider.removePublishedItem(item);
        provider.removeNode(mockNode);

        // Verify results.
        final List<CachingPubsubPersistenceProvider.NodeOperation> pending = provider.nodesToProcess.computeIfAbsent(mockNode.getUniqueIdentifier(), id -> new ArrayList<>());
        assertEquals(1, pending.size());

        final CachingPubsubPersistenceProvider.NodeOperation nodeOperation = pending.get(0);
        assertEquals(mockNode.getUniqueIdentifier(), nodeOperation.node.getUniqueIdentifier());
        assertEquals(CachingPubsubPersistenceProvider.NodeOperation.Action.REMOVE, nodeOperation.action);
        assertNull(nodeOperation.affiliate);
        assertNull(nodeOperation.subscription);

        assertEquals(0, provider.itemsToAdd.size());
        assertEquals(0, provider.itemsToDelete.size());
    }
Executes a test that, through {@link CachingPubsubPersistenceProvider#removePublishedItem(PublishedItem)}
and {@link CachingPubsubPersistenceProvider#removeNode(Node)} attempts to remove an item from a node, after
which the node is removed.

When a node is deleted, all its associated data (including items, affiliations and affiliations) are removed.
Any pending operations on that node can thus be removed.

The caching provider can optimize the operations, where the 'net effect' of them is to have only the remove-node
operation.

Therefor, this test asserts that after both invocations, one operation is scheduled.
xmppserver/src/test/java/org/jivesoftware/openfire/pubsub/CachingPubsubPersistenceProviderItemOperationsTest.java