@Test
    public void testDeleteNodeDoesNotVoidNewerCreate() throws Exception
    {
        // Setup test fixture.
        final CachingPubsubPersistenceProvider provider = new CachingPubsubPersistenceProvider();
        final Node mockNode = Mockito.mock(Node.class);
        Mockito.lenient().when(mockNode.getUniqueIdentifier()).thenReturn(new Node.UniqueIdentifier("mock-service-1", "mock-node-a"));

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

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

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

        final CachingPubsubPersistenceProvider.NodeOperation secondOperation = pending.get(1);
        assertEquals(mockNode.getUniqueIdentifier(), secondOperation.node.getUniqueIdentifier());
        assertEquals(CachingPubsubPersistenceProvider.NodeOperation.Action.CREATE, secondOperation.action);
        assertNull(secondOperation.subscription);
        assertNull(secondOperation.affiliate);

        assertEquals(0, provider.itemsPending.size());
        assertEquals(0, provider.itemsToAdd.size());
        assertEquals(0, provider.itemsToDelete.size());
    }
Executes a test that, through {@link CachingPubsubPersistenceProvider#removeNode(Node)} and
{@link CachingPubsubPersistenceProvider#createNode(Node)} removes (a node that is thought to preexist) and then
recreate a node again.

This test asserts that after both invocations, two corresponding operation are scheduled in that order.
xmppserver/src/test/java/org/jivesoftware/openfire/pubsub/CachingPubsubPersistenceProviderNodeOperationsTest.java