Search in sources :

Example 6 with BackupState

use of com.zegoggles.smssync.service.state.BackupState in project sms-backup-plus by jberkel.

the class BackupTaskTest method shouldBackupItems.

@Test
public void shouldBackupItems() throws Exception {
    mockFetch(SMS, 1);
    when(converter.convertMessages(any(Cursor.class), eq(SMS))).thenReturn(result(SMS, 1));
    when(store.getFolder(notNull(DataType.class), same(dataTypePreferences))).thenReturn(folder);
    BackupState finalState = task.doInBackground(config);
    verify(folder).appendMessages(anyListOf(Message.class));
    verify(service).transition(SmsSyncState.LOGIN, null);
    verify(service).transition(SmsSyncState.CALC, null);
    assertThat(finalState).isNotNull();
    assertThat(finalState.isFinished()).isTrue();
    assertThat(finalState.currentSyncedItems).isEqualTo(1);
    assertThat(finalState.itemsToSync).isEqualTo(1);
    assertThat(finalState.backupType).isEqualTo(config.backupType);
}
Also used : BackupState(com.zegoggles.smssync.service.state.BackupState) MimeMessage(com.fsck.k9.mail.internet.MimeMessage) Message(com.fsck.k9.mail.Message) DataType(com.zegoggles.smssync.mail.DataType) BackupItemsFetcher.emptyCursor(com.zegoggles.smssync.service.BackupItemsFetcher.emptyCursor) Cursor(android.database.Cursor) MatrixCursor(android.database.MatrixCursor) Test(org.junit.Test)

Aggregations

BackupState (com.zegoggles.smssync.service.state.BackupState)6 DataType (com.zegoggles.smssync.mail.DataType)5 Message (com.fsck.k9.mail.Message)3 Test (org.junit.Test)3 Cursor (android.database.Cursor)2 MatrixCursor (android.database.MatrixCursor)2 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)2 BackupItemsFetcher.emptyCursor (com.zegoggles.smssync.service.BackupItemsFetcher.emptyCursor)2 MessagingException (com.fsck.k9.mail.MessagingException)1 ContactGroup (com.zegoggles.smssync.contacts.ContactGroup)1 ConversionResult (com.zegoggles.smssync.mail.ConversionResult)1 BackupDisabledException (com.zegoggles.smssync.service.exception.BackupDisabledException)1 ConnectivityException (com.zegoggles.smssync.service.exception.ConnectivityException)1 MissingPermissionException (com.zegoggles.smssync.service.exception.MissingPermissionException)1 RequiresLoginException (com.zegoggles.smssync.service.exception.RequiresLoginException)1