Search in sources :

Example 11 with JobData

use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.

the class RecipientIdFollowUpJobMigrationTest method migrate_requestGroupInfoJob_good.

@Test
public void migrate_requestGroupInfoJob_good() throws Exception {
    JobData testData = new JobData("RequestGroupInfoJob", null, new Data.Builder().putString("source", "1").putString("group_id", "__textsecure_group__!abcdef0123456789abcdef0123456789").build());
    RecipientIdFollowUpJobMigration subject = new RecipientIdFollowUpJobMigration();
    JobData converted = subject.migrate(testData);
    assertEquals("RequestGroupInfoJob", converted.getFactoryKey());
    assertNull(converted.getQueueKey());
    assertEquals("1", converted.getData().getString("source"));
    assertEquals("__textsecure_group__!abcdef0123456789abcdef0123456789", converted.getData().getString("group_id"));
    new RequestGroupInfoJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) RequestGroupInfoJob(org.thoughtcrime.securesms.jobs.RequestGroupInfoJob) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with JobData

use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.

the class RecipientIdFollowUpJobMigrationTest method migrate_sendDeliveryReceiptJob_bad.

@Test
public void migrate_sendDeliveryReceiptJob_bad() throws Exception {
    JobData testData = new JobData("SendDeliveryReceiptJob", null, new Data.Builder().putString("recipient", "1").build());
    RecipientIdFollowUpJobMigration subject = new RecipientIdFollowUpJobMigration();
    JobData converted = subject.migrate(testData);
    assertEquals("FailingJob", converted.getFactoryKey());
    assertNull(converted.getQueueKey());
    new FailingJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : FailingJob(org.thoughtcrime.securesms.jobs.FailingJob) JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Data(org.thoughtcrime.securesms.jobmanager.Data) JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with JobData

use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.

the class RecipientIdJobMigrationTest method migrate_smsSendJob_null.

@Test
public void migrate_smsSendJob_null() throws Exception {
    JobData testData = new JobData("SmsSendJob", null, new Data.Builder().putLong("message_id", 1).putInt("run_attempt", 0).build());
    mockRecipientResolve("+16101234567", 1);
    RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
    JobData converted = subject.migrate(testData);
    assertEquals("SmsSendJob", converted.getFactoryKey());
    assertNull(converted.getQueueKey());
    assertEquals(1, converted.getData().getLong("message_id"));
    assertEquals(0, converted.getData().getInt("run_attempt"));
    new SmsSendJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : SmsSendJob(org.thoughtcrime.securesms.jobs.SmsSendJob) JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Application(android.app.Application) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with JobData

use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.

the class RecipientIdJobMigrationTest method migrate_requestGroupInfoJob.

@Test
public void migrate_requestGroupInfoJob() throws Exception {
    JobData testData = new JobData("RequestGroupInfoJob", null, new Data.Builder().putString("source", "+16101234567").putString("group_id", "__textsecure_group__!abcdef0123456789abcdef0123456789").build());
    mockRecipientResolve("+16101234567", 1);
    RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
    JobData converted = subject.migrate(testData);
    assertEquals("RequestGroupInfoJob", converted.getFactoryKey());
    assertNull(converted.getQueueKey());
    assertEquals("1", converted.getData().getString("source"));
    assertEquals("__textsecure_group__!abcdef0123456789abcdef0123456789", converted.getData().getString("group_id"));
    new RequestGroupInfoJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) RequestGroupInfoJob(org.thoughtcrime.securesms.jobs.RequestGroupInfoJob) Application(android.app.Application) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with JobData

use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.

the class RecipientIdJobMigrationTest method migrate_multiDeviceReadUpdateJob_empty.

@Test
public void migrate_multiDeviceReadUpdateJob_empty() throws Exception {
    JobData testData = new JobData("MultiDeviceReadUpdateJob", null, new Data.Builder().putStringArray("message_ids", new String[0]).build());
    RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
    JobData converted = subject.migrate(testData);
    assertEquals("MultiDeviceReadUpdateJob", converted.getFactoryKey());
    assertNull(converted.getQueueKey());
    assertEquals(0, converted.getData().getStringArray("message_ids").length);
    new MultiDeviceReadUpdateJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Data(org.thoughtcrime.securesms.jobmanager.Data) JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Application(android.app.Application) MultiDeviceReadUpdateJob(org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

JobData (org.thoughtcrime.securesms.jobmanager.JobMigration.JobData)22 Test (org.junit.Test)21 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 Application (android.app.Application)17 Data (org.thoughtcrime.securesms.jobmanager.Data)9 NewSerializableSyncMessageId (org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.NewSerializableSyncMessageId)2 OldSerializableSyncMessageId (org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.OldSerializableSyncMessageId)2 DirectoryRefreshJob (org.thoughtcrime.securesms.jobs.DirectoryRefreshJob)2 FailingJob (org.thoughtcrime.securesms.jobs.FailingJob)2 MultiDeviceReadUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob)2 PushGroupSendJob (org.thoughtcrime.securesms.jobs.PushGroupSendJob)2 RequestGroupInfoJob (org.thoughtcrime.securesms.jobs.RequestGroupInfoJob)2 SendDeliveryReceiptJob (org.thoughtcrime.securesms.jobs.SendDeliveryReceiptJob)2 SmsSendJob (org.thoughtcrime.securesms.jobs.SmsSendJob)2 SuppressLint (android.annotation.SuppressLint)1 JobSpec (org.thoughtcrime.securesms.jobmanager.persistence.JobSpec)1 MultiDeviceContactUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceContactUpdateJob)1 MultiDeviceVerifiedUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceVerifiedUpdateJob)1 MultiDeviceViewOnceOpenJob (org.thoughtcrime.securesms.jobs.MultiDeviceViewOnceOpenJob)1 PushGroupUpdateJob (org.thoughtcrime.securesms.jobs.PushGroupUpdateJob)1