ExchangeMailStore store = new ExchangeMailStore(getService(), idPageSize, getItemPageSize);
Iterator<MailboxItem> mail = store.getMail(users, mockSyncStates).iterator();
for (int i = 0; i < totalMessageCount; i++)
{
assertTrue(mail.hasNext());
MailboxItem item = mail.next();
assertEquals("ALICE-FOLDER:the #" + i + " id", item.getHeader("Item ID"));
}
assertFalse(mail.hasNext());
verify(mockSyncStates).setSyncState(aliceUsername, aliceFolderId, "syncState2");
when(mockSyncStates.getLastSyncState(aliceUsername, aliceFolderId)).thenReturn("newSyncState");
MessageType[] newMessages =
mockSyncFolderItems(createMockMessages(aliceFolderId, 10, 2),
folderContext(aliceUsername, aliceFolderId, "newSyncState"),
idPageSize, "lastSyncState", true);
mockGetItem(newMessages,
generateIds(10, 2, aliceFolderId),
aliceUsername);
mail = store.getMail(users, mockSyncStates).iterator();
for (int i = 10; i < 12; i++)
{
assertTrue(mail.hasNext());
MailboxItem item = mail.next();
assertEquals("ALICE-FOLDER:the #" + i + " id", item.getHeader("Item ID"));
}
assertFalse(mail.hasNext());
verify(mockSyncStates).setSyncState(aliceUsername, aliceFolderId, "lastSyncState");
}