@Test
  public void shouldRestoreItems() throws Exception {
    Date now = new Date();
    List<ImapStore.ImapMessage> messages = new ArrayList<ImapStore.ImapMessage>();
    ContentValues values = new ContentValues();
    values.put(SmsConsts.TYPE, SmsConsts.MESSAGE_TYPE_INBOX);
    values.put(SmsConsts.DATE, now.getTime());

    ImapStore.ImapMessage mockMessage = mock(ImapStore.ImapMessage.class);
    when(mockMessage.getFolder()).thenReturn(folder);
    when(converter.getDataType(mockMessage)).thenReturn(DataType.SMS);
    when(converter.messageToContentValues(mockMessage)).thenReturn(values);

    messages.add(mockMessage);

    when(folder.getMessages(anyInt(), anyBoolean(), any(Date.class))).thenReturn(messages);
    when(resolver.insert(Consts.SMS_PROVIDER, values)).thenReturn(Uri.parse("content://sms/123"));
    task.doInBackground(config);

    verify(resolver).insert(Consts.SMS_PROVIDER, values);
    verify(resolver).delete(Uri.parse("content://sms/conversations/-1"), null, null);

    assertThat(DataType.SMS.getMaxSyncedDate(context)).isEqualTo(now.getTime());
    assertThat(task.getSmsIds()).containsExactly("123");

    verify(store).closeFolders();
  }
 @Test
 public void shouldVerifyStoreSettings() throws Exception {
   task.doInBackground(config);
   verify(store).checkSettings();
 }
 @Test
 public void shouldCloseFolders() throws Exception {
   task.doInBackground(config);
   verify(store).closeFolders();
 }
 @Test
 public void shouldAcquireAndReleaseLocksDuringRestore() throws Exception {
   task.doInBackground(config);
   verify(service).acquireLocks();
   verify(service).releaseLocks();
 }