use of org.thoughtcrime.securesms.jobs.SendReadReceiptJob in project Signal-Android by WhisperSystems.
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"));
}
use of org.thoughtcrime.securesms.jobs.SendReadReceiptJob in project Signal-Android by WhisperSystems.
the class SendReadReceiptsJobMigrationTest method givenSendReadReceiptJobDataWithThreadId_whenIMigrate_thenIDoNotReplace.
@Test
public void givenSendReadReceiptJobDataWithThreadId_whenIMigrate_thenIDoNotReplace() {
// GIVEN
SendReadReceiptJob job = new SendReadReceiptJob(1, RecipientId.from(2), new ArrayList<>(), new ArrayList<>());
JobMigration.JobData jobData = new JobMigration.JobData(job.getFactoryKey(), "asdf", job.serialize());
// WHEN
JobMigration.JobData result = testSubject.migrate(jobData);
// THEN
assertEquals(jobData, result);
}
use of org.thoughtcrime.securesms.jobs.SendReadReceiptJob in project Signal-Android by signalapp.
the class SendReadReceiptsJobMigrationTest method givenSendReadReceiptJobDataWithoutThreadIdAndThreadIdNotFound_whenIMigrate_thenIGetAFailingJob.
@Test
public void givenSendReadReceiptJobDataWithoutThreadIdAndThreadIdNotFound_whenIMigrate_thenIGetAFailingJob() {
// 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[] {}).putLong("timestamp", 292837649).build());
when(mockDatabase.getThreadForMessageId(anyLong())).thenReturn(-1L);
// WHEN
JobMigration.JobData result = testSubject.migrate(jobData);
// THEN
assertEquals("FailingJob", result.getFactoryKey());
}
use of org.thoughtcrime.securesms.jobs.SendReadReceiptJob in project Signal-Android by signalapp.
the class SendReadReceiptsJobMigrationTest method givenSendReadReceiptJobDataWithThreadId_whenIMigrate_thenIDoNotReplace.
@Test
public void givenSendReadReceiptJobDataWithThreadId_whenIMigrate_thenIDoNotReplace() {
// GIVEN
SendReadReceiptJob job = new SendReadReceiptJob(1, RecipientId.from(2), new ArrayList<>(), new ArrayList<>());
JobMigration.JobData jobData = new JobMigration.JobData(job.getFactoryKey(), "asdf", job.serialize());
// WHEN
JobMigration.JobData result = testSubject.migrate(jobData);
// THEN
assertEquals(jobData, result);
}
use of org.thoughtcrime.securesms.jobs.SendReadReceiptJob in project Signal-Android by WhisperSystems.
the class SendReadReceiptsJobMigrationTest method givenSendReadReceiptJobDataWithoutThreadIdAndThreadIdNotFound_whenIMigrate_thenIGetAFailingJob.
@Test
public void givenSendReadReceiptJobDataWithoutThreadIdAndThreadIdNotFound_whenIMigrate_thenIGetAFailingJob() {
// 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[] {}).putLong("timestamp", 292837649).build());
when(mockDatabase.getThreadForMessageId(anyLong())).thenReturn(-1L);
// WHEN
JobMigration.JobData result = testSubject.migrate(jobData);
// THEN
assertEquals("FailingJob", result.getFactoryKey());
}
Aggregations