use of org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.NewSerializableSyncMessageId 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());
}
use of org.thoughtcrime.securesms.jobmanager.migrations.RecipientIdJobMigration.NewSerializableSyncMessageId 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());
}
Aggregations