@Test
    public void testCreateSubscriptions() 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"));
        final JID firstSubscriber = new JID("test-user-1", "example.org", null);
        final String firstSubscriptionId = "test-subscription-id-" + StringUtils.randomString(7);
        final NodeSubscription firstSubscription = new NodeSubscription(mockNode, firstSubscriber, firstSubscriber, NodeSubscription.State.subscribed, firstSubscriptionId);
        final JID secondSubscriber = new JID("test-user-2", "example.org", null); // Technically, the same user can be subscribed more than once, but lets keep things simple.
        final String secondSubscriptionId = "test-subscription-id-" + StringUtils.randomString(7);
        final NodeSubscription secondSubscription = new NodeSubscription(mockNode, secondSubscriber, secondSubscriber, NodeSubscription.State.subscribed, secondSubscriptionId);

        // Execute system under test.
        provider.createSubscription(mockNode, firstSubscription);
        provider.createSubscription(mockNode, secondSubscription);

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

        final CachingPubsubPersistenceProvider.NodeOperation firstNodeOperation = pending.get(0);
        assertEquals(mockNode.getUniqueIdentifier(), firstNodeOperation.node.getUniqueIdentifier());
        assertEquals(CachingPubsubPersistenceProvider.NodeOperation.Action.CREATE_SUBSCRIPTION, firstNodeOperation.action);
        assertEquals(firstSubscriptionId, firstNodeOperation.subscription.getID());
        assertEquals(firstSubscriber, firstNodeOperation.subscription.getJID());
        assertEquals(firstSubscriber, firstNodeOperation.subscription.getOwner());
        assertNull(firstNodeOperation.affiliate);

        final CachingPubsubPersistenceProvider.NodeOperation secondNodeOperation = pending.get(1);
        assertEquals(mockNode.getUniqueIdentifier(), secondNodeOperation.node.getUniqueIdentifier());
        assertEquals(CachingPubsubPersistenceProvider.NodeOperation.Action.CREATE_SUBSCRIPTION, secondNodeOperation.action);
        assertEquals(secondSubscriptionId, secondNodeOperation.subscription.getID());
        assertEquals(secondSubscriber, secondNodeOperation.subscription.getJID());
        assertEquals(secondSubscriber, secondNodeOperation.subscription.getOwner());
        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#createSubscription(Node, NodeSubscription)}
attempts to create the multiple, different subscriptions.

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