}
@Test
public void testStaleMessageIdRemoval() throws IOException, OverQuotaException
{
Mailbox mailbox = new Mailbox(MAILBOX);
Message message = getDummyMessage();
message.addLabel(ReservedLabels.NOTIFICATIONS.getId());
MessageDAO messageDAO = dao.getMessageDAO();
List<UUID> validMessageIds = new ArrayList<UUID>();
List<UUID> invalidMessageIds = new ArrayList<UUID>();
// save message under different message ids, and store message ids
for (int i=0; i<5; i++) {
UUID messageId = new MessageIdBuilder().build();
validMessageIds.add(messageId);
messageDAO.put(mailbox, messageId, message, null);
}
// generate stale message ids
for (int i=0; i<5; i++) {
UUID messageId = new MessageIdBuilder().build();
invalidMessageIds.add(messageId);
}
// add stale message ids to indexes only (without message metadata)
Mutator<String> m = createMutator(keyspace, strSe);
LabelIndexPersistence.add(m, mailbox.getId(), invalidMessageIds, message.getLabels());
m.execute();
// get all messages from NOTIFICATION label
List<UUID> allMessageIds = messageDAO.getMessageIds(mailbox,
ReservedLabels.NOTIFICATIONS.getId(), new MessageIdBuilder().build(), 100, true);