Search in sources :

Example 1 with OldSerializableSyncMessageId

use of org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.OldSerializableSyncMessageId in project Signal-Android by WhisperSystems.

the class RecipientIdJobMigrationTest method migrate_multiDeviceViewOnceOpenJob.

@Test
public void migrate_multiDeviceViewOnceOpenJob() throws Exception {
    OldSerializableSyncMessageId oldId = new OldSerializableSyncMessageId("+16101234567", 1);
    JobData testData = new JobData("MultiDeviceRevealUpdateJob", null, new Data.Builder().putString("message_id", JsonUtils.toJson(oldId)).build());
    mockRecipientResolve("+16101234567", 1);
    RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
    JobData converted = subject.migrate(testData);
    assertEquals("MultiDeviceRevealUpdateJob", converted.getFactoryKey());
    assertNull(converted.getQueueKey());
    assertEquals(JsonUtils.toJson(new NewSerializableSyncMessageId("1", 1)), converted.getData().getString("message_id"));
    new MultiDeviceViewOnceOpenJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : OldSerializableSyncMessageId(org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.OldSerializableSyncMessageId) NewSerializableSyncMessageId(org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.NewSerializableSyncMessageId) JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Data(org.thoughtcrime.securesms.jobmanager.Data) JobData(org.thoughtcrime.securesms.jobmanager.JobMigration.JobData) Application(android.app.Application) MultiDeviceViewOnceOpenJob(org.thoughtcrime.securesms.jobs.MultiDeviceViewOnceOpenJob) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with OldSerializableSyncMessageId

use of org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.OldSerializableSyncMessageId in project Signal-Android by WhisperSystems.

the class RecipientIdJobMigrationTest method migrate_multiDeviceReadUpdateJob_twoIds.

@Test
public void migrate_multiDeviceReadUpdateJob_twoIds() throws Exception {
    OldSerializableSyncMessageId id1 = new OldSerializableSyncMessageId("+16101234567", 1);
    OldSerializableSyncMessageId id2 = new OldSerializableSyncMessageId("+16101112222", 2);
    JobData testData = new JobData("MultiDeviceReadUpdateJob", null, new Data.Builder().putStringArray("message_ids", new String[] { JsonUtils.toJson(id1), JsonUtils.toJson(id2) }).build());
    mockRecipientResolve("+16101234567", 1);
    mockRecipientResolve("+16101112222", 2);
    RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
    JobData converted = subject.migrate(testData);
    assertEquals("MultiDeviceReadUpdateJob", converted.getFactoryKey());
    assertNull(converted.getQueueKey());
    String[] updated = converted.getData().getStringArray("message_ids");
    assertEquals(2, updated.length);
    assertEquals(JsonUtils.toJson(new NewSerializableSyncMessageId("1", 1)), updated[0]);
    assertEquals(JsonUtils.toJson(new NewSerializableSyncMessageId("2", 2)), updated[1]);
    new MultiDeviceReadUpdateJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Also used : OldSerializableSyncMessageId(org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.OldSerializableSyncMessageId) NewSerializableSyncMessageId(org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.NewSerializableSyncMessageId) 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

Application (android.app.Application)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 Data (org.thoughtcrime.securesms.jobmanager.Data)2 JobData (org.thoughtcrime.securesms.jobmanager.JobMigration.JobData)2 NewSerializableSyncMessageId (org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.NewSerializableSyncMessageId)2 OldSerializableSyncMessageId (org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.OldSerializableSyncMessageId)2 MultiDeviceReadUpdateJob (org.thoughtcrime.securesms.jobs.MultiDeviceReadUpdateJob)1 MultiDeviceViewOnceOpenJob (org.thoughtcrime.securesms.jobs.MultiDeviceViewOnceOpenJob)1