use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigrationTest method migrate_pushGroupSendJob_null.
@Test
public void migrate_pushGroupSendJob_null() throws Exception {
JobData testData = new JobData("PushGroupSendJob", "someGroupId", new Data.Builder().putString("filter_address", null).putLong("message_id", 123).build());
mockRecipientResolve("someGroupId", 5);
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
JobData converted = subject.migrate(testData);
assertEquals("PushGroupSendJob", converted.getFactoryKey());
assertEquals(RecipientId.from(5).toQueueKey(), converted.getQueueKey());
assertNull(converted.getData().getString("filter_recipient"));
assertFalse(converted.getData().hasString("filter_address"));
new PushGroupSendJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigrationTest method migrate_directoryRefreshJob_null.
@Test
public void migrate_directoryRefreshJob_null() throws Exception {
JobData testData = new JobData("DirectoryRefreshJob", "DirectoryRefreshJob", new Data.Builder().putString("address", null).putBoolean("notify_of_new_users", true).build());
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
JobData converted = subject.migrate(testData);
assertEquals("DirectoryRefreshJob", converted.getFactoryKey());
assertEquals("DirectoryRefreshJob", converted.getQueueKey());
assertNull(converted.getData().getString("recipient"));
assertTrue(converted.getData().getBoolean("notify_of_new_users"));
assertFalse(converted.getData().hasString("address"));
new DirectoryRefreshJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigrationTest method migrate_smsSendJob_nonNull.
@Test
public void migrate_smsSendJob_nonNull() throws Exception {
JobData testData = new JobData("SmsSendJob", "+16101234567", 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());
assertEquals(RecipientId.from(1).toQueueKey(), 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());
}
use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData 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());
}
use of org.thoughtcrime.securesms.jobmanager.JobMigration.JobData in project Signal-Android by WhisperSystems.
the class RecipientIdJobMigrationTest method migrate_sendDeliveryReceiptJob.
@Test
public void migrate_sendDeliveryReceiptJob() throws Exception {
JobData testData = new JobData("SendDeliveryReceiptJob", null, new Data.Builder().putString("address", "+16101234567").putLong("message_id", 1).putLong("timestamp", 2).build());
mockRecipientResolve("+16101234567", 1);
RecipientIdJobMigration subject = new RecipientIdJobMigration(mock(Application.class));
JobData converted = subject.migrate(testData);
assertEquals("SendDeliveryReceiptJob", converted.getFactoryKey());
assertNull(converted.getQueueKey());
assertEquals("1", converted.getData().getString("recipient"));
assertEquals(1, converted.getData().getLong("message_id"));
assertEquals(2, converted.getData().getLong("timestamp"));
new SendDeliveryReceiptJob.Factory().create(mock(Job.Parameters.class), converted.getData());
}
Aggregations