when(aliceFolder.getFolderId()).thenReturn(aliceId);
when(aliceId.getId()).thenReturn(aliceFolderId);
mockFindFolders(new FolderType[]{aliceFolder}, aliceUsername);
UserFolderSyncStateStorage mockSyncStates = mock(UserFolderSyncStateStorage.class);
// First call to get mail
when(mockSyncStates.getLastSyncState(aliceUsername, aliceFolderId)).thenReturn(null);
MessageType[] firstMessages = mockSyncFolderItems(createMockMessages(aliceFolderId, 0, totalMessageCount),
folderContext(aliceUsername, aliceFolderId),
idPageSize, "syncState2", true);
mockGetItem(firstMessages, generateIds(0, totalMessageCount, aliceFolderId), aliceUsername);
ArrayList<String> users = new ArrayList<String>();
users.add(aliceUsername);
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,