Search in sources :

Example 6 with SendReadReceiptJob

use of org.thoughtcrime.securesms.jobs.SendReadReceiptJob in project Signal-Android by signalapp.

the class SendReadReceiptsJobMigrationTest method givenSendReadReceiptJobDataWithoutThreadIdAndThreadIdFound_whenIMigrate_thenIInsertThreadId.

@Test
public void givenSendReadReceiptJobDataWithoutThreadIdAndThreadIdFound_whenIMigrate_thenIInsertThreadId() {
    // GIVEN
    SendReadReceiptJob job = new SendReadReceiptJob(1, RecipientId.from(2), new ArrayList<>(), new ArrayList<>());
    JobMigration.JobData jobData = new JobMigration.JobData(job.getFactoryKey(), "asdf", new Data.Builder().putString("recipient", RecipientId.from(2).serialize()).putLongArray("message_ids", new long[] { 1, 2, 3, 4, 5 }).putLong("timestamp", 292837649).build());
    when(mockDatabase.getThreadForMessageId(anyLong())).thenReturn(1234L);
    // WHEN
    JobMigration.JobData result = testSubject.migrate(jobData);
    // THEN
    assertEquals(1234L, result.getData().getLong("thread"));
    assertEquals(RecipientId.from(2).serialize(), result.getData().getString("recipient"));
    assertTrue(result.getData().hasLongArray("message_ids"));
    assertTrue(result.getData().hasLong("timestamp"));
}
Also used : SendReadReceiptJob(org.thoughtcrime.securesms.jobs.SendReadReceiptJob) JobMigration(org.thoughtcrime.securesms.jobmanager.JobMigration) Data(org.thoughtcrime.securesms.jobmanager.Data) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 JobMigration (org.thoughtcrime.securesms.jobmanager.JobMigration)6 SendReadReceiptJob (org.thoughtcrime.securesms.jobs.SendReadReceiptJob)6 Data (org.thoughtcrime.securesms.jobmanager.Data)4