@Test
  @MongoDbAvailable
  public void testMessageGroupMarkingMessage() throws Exception {
    MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
    MongoDbMessageStore store = new MongoDbMessageStore(mongoDbFactory);

    MessageGroup messageGroup = store.getMessageGroup(1);
    Message<?> messageA = new GenericMessage<String>("A");
    Message<?> messageB = new GenericMessage<String>("B");
    store.addMessageToGroup(1, messageA);
    messageGroup = store.addMessageToGroup(1, messageB);
    assertEquals(0, messageGroup.getMarked().size());
    assertEquals(2, messageGroup.getUnmarked().size());

    messageGroup = store.markMessageFromGroup(1, messageA);
    assertEquals(1, messageGroup.getMarked().size());
    assertEquals(1, messageGroup.getUnmarked().size());

    // validate that the updates were propagated to Mongo as well
    store = new MongoDbMessageStore(mongoDbFactory);

    messageGroup = store.getMessageGroup(1);
    assertEquals(1, messageGroup.getMarked().size());
    assertEquals(1, messageGroup.getUnmarked().size());
  }
  @Test
  @MongoDbAvailable
  public void testMarkAllMessagesInMessageGroup() throws Exception {
    MongoDbFactory mongoDbFactory = this.prepareMongoFactory();
    MongoDbMessageStore store = new MongoDbMessageStore(mongoDbFactory);

    MessageGroup messageGroup = store.getMessageGroup(1);

    store.addMessageToGroup(1, new GenericMessage<String>("1"));
    store.addMessageToGroup(1, new GenericMessage<String>("2"));
    messageGroup = store.addMessageToGroup(1, new GenericMessage<String>("3"));

    assertEquals(3, messageGroup.getUnmarked().size());
    assertEquals(0, messageGroup.getMarked().size());

    messageGroup = store.markMessageGroup(messageGroup);

    assertEquals(0, messageGroup.getUnmarked().size());
    assertEquals(3, messageGroup.getMarked().size());

    store = new MongoDbMessageStore(mongoDbFactory);

    messageGroup = store.getMessageGroup(1);
    assertEquals(0, messageGroup.getUnmarked().size());
    assertEquals(3, messageGroup.getMarked().size());
  }