@Override
    public Iterator<MessageProcessor> iterator() {
        return sortedProcessors.get().iterator();
    }
@Test
    public void testIterator() throws Exception {
        final Iterator<MessageProcessor> iterator = orderedMessageProcessors.iterator();
        assertEquals("A is first", A.class, iterator.next().getClass());
        assertEquals("B is last", B.class, iterator.next().getClass());
        assertFalse("Iterator exhausted", iterator.hasNext());

        when(clusterConfigService.get(MessageProcessorsConfig.class)).thenReturn(
                MessageProcessorsConfig.create(Lists.newArrayList(B.class.getCanonicalName(),
                                                                  A.class.getCanonicalName())));

        orderedMessageProcessors.handleOrderingUpdate(getClusterConfigChangedEvent());

        final Iterator<MessageProcessor> it2 = orderedMessageProcessors.iterator();
        assertEquals("B is first", B.class, it2.next().getClass());
        assertEquals("A is last", A.class, it2.next().getClass());
        assertFalse("Iterator exhausted", it2.hasNext());


        when(clusterConfigService.get(MessageProcessorsConfig.class)).thenReturn(
                MessageProcessorsConfig.create(Lists.newArrayList(B.class.getCanonicalName(),
                                                                  A.class.getCanonicalName()),
                                               Sets.newHashSet(B.class.getCanonicalName())));

        orderedMessageProcessors.handleOrderingUpdate(getClusterConfigChangedEvent());

        final Iterator<MessageProcessor> it3 = orderedMessageProcessors.iterator();
        assertEquals("A is only element", A.class, it3.next().getClass());
        assertFalse("Iterator exhausted", it3.hasNext());
    }