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

        // Execute system under test.
        provider.createNode(mockOrigNode);
        provider.createNode(mockReplaceNode);

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

        final CachingPubsubPersistenceProvider.NodeOperation firstNodeOperation = pending.get(0);
        assertEquals(mockOrigNode.getUniqueIdentifier(), firstNodeOperation.node.getUniqueIdentifier());
        assertEquals(new Date(0), firstNodeOperation.node.getCreationDate());
        assertEquals(CachingPubsubPersistenceProvider.NodeOperation.Action.CREATE, firstNodeOperation.action);
        assertNull(firstNodeOperation.subscription);
        assertNull(firstNodeOperation.affiliate);

        final CachingPubsubPersistenceProvider.NodeOperation secondNodeOperation = pending.get(1);
        assertEquals(mockOrigNode.getUniqueIdentifier(), secondNodeOperation.node.getUniqueIdentifier());
        assertNotEquals(new Date(0), secondNodeOperation.node.getCreationDate());
        assertEquals(CachingPubsubPersistenceProvider.NodeOperation.Action.CREATE, secondNodeOperation.action);
        assertNull(secondNodeOperation.subscription);
        assertNull(secondNodeOperation.affiliate);

        assertEquals(0, provider.itemsPending.size());
        assertEquals(0, provider.itemsToAdd.size());
        assertEquals(0, provider.itemsToDelete.size());
    }
Executes a test that, through {@link CachingPubsubPersistenceProvider#createNode(Node)} attempts to create the
same node 'twice'.

This tests an erroneous invocation. The design of the caching provider is such that it shouldn't try to 'clean up'
such misbehavior. Instead, it should pass this through to the delegate, which is expected to generate an
appropriate error response.

Therefor, this test asserts that for each invocation, a corresponding operation is scheduled.
xmppserver/src/test/java/org/jivesoftware/openfire/pubsub/CachingPubsubPersistenceProviderNodeOperationsTest.java