Search in sources :

Example 1 with JobDatabase

use of org.thoughtcrime.securesms.database.JobDatabase in project Signal-Android by WhisperSystems.

the class FastJobStorageTest method updateAllJobsToBePending_writesToDatabase.

@Test
public void updateAllJobsToBePending_writesToDatabase() {
    JobDatabase database = noopDatabase();
    FastJobStorage subject = new FastJobStorage(database);
    subject.updateAllJobsToBePending();
    verify(database).updateAllJobsToBePending();
}
Also used : JobDatabase(org.thoughtcrime.securesms.database.JobDatabase) Test(org.junit.Test)

Example 2 with JobDatabase

use of org.thoughtcrime.securesms.database.JobDatabase in project Signal-Android by WhisperSystems.

the class FastJobStorageTest method noopDatabase.

private JobDatabase noopDatabase() {
    JobDatabase database = mock(JobDatabase.class);
    when(database.getAllJobSpecs()).thenReturn(Collections.emptyList());
    when(database.getAllConstraintSpecs()).thenReturn(Collections.emptyList());
    when(database.getAllDependencySpecs()).thenReturn(Collections.emptyList());
    return database;
}
Also used : JobDatabase(org.thoughtcrime.securesms.database.JobDatabase)

Example 3 with JobDatabase

use of org.thoughtcrime.securesms.database.JobDatabase in project Signal-Android by WhisperSystems.

the class FastJobStorageTest method updateJobRunningState_writesToDatabase.

@Test
public void updateJobRunningState_writesToDatabase() {
    JobDatabase database = fixedDataDatabase(DataSet1.FULL_SPECS);
    FastJobStorage subject = new FastJobStorage(database);
    subject.init();
    subject.updateJobRunningState("id1", true);
    verify(database).updateJobRunningState("id1", true);
}
Also used : JobDatabase(org.thoughtcrime.securesms.database.JobDatabase) Test(org.junit.Test)

Example 4 with JobDatabase

use of org.thoughtcrime.securesms.database.JobDatabase in project Signal-Android by WhisperSystems.

the class FastJobStorageTest method fixedDataDatabase.

private JobDatabase fixedDataDatabase(List<FullSpec> fullSpecs) {
    JobDatabase database = mock(JobDatabase.class);
    when(database.getAllJobSpecs()).thenReturn(Stream.of(fullSpecs).map(FullSpec::getJobSpec).toList());
    when(database.getAllConstraintSpecs()).thenReturn(Stream.of(fullSpecs).map(FullSpec::getConstraintSpecs).flatMap(Stream::of).toList());
    when(database.getAllDependencySpecs()).thenReturn(Stream.of(fullSpecs).map(FullSpec::getDependencySpecs).flatMap(Stream::of).toList());
    return database;
}
Also used : JobDatabase(org.thoughtcrime.securesms.database.JobDatabase) FullSpec(org.thoughtcrime.securesms.jobmanager.persistence.FullSpec) Stream(com.annimon.stream.Stream)

Example 5 with JobDatabase

use of org.thoughtcrime.securesms.database.JobDatabase in project Signal-Android by WhisperSystems.

the class FastJobStorageTest method updateJobAfterRetry_writesToDatabase.

@Test
public void updateJobAfterRetry_writesToDatabase() {
    JobDatabase database = fixedDataDatabase(DataSet1.FULL_SPECS);
    FastJobStorage subject = new FastJobStorage(database);
    subject.init();
    subject.updateJobAfterRetry("id1", true, 1, 10, "a");
    verify(database).updateJobAfterRetry("id1", true, 1, 10, "a");
}
Also used : JobDatabase(org.thoughtcrime.securesms.database.JobDatabase) Test(org.junit.Test)

Aggregations

JobDatabase (org.thoughtcrime.securesms.database.JobDatabase)24 Test (org.junit.Test)20 JobSpec (org.thoughtcrime.securesms.jobmanager.persistence.JobSpec)4 Stream (com.annimon.stream.Stream)2 FullSpec (org.thoughtcrime.securesms.jobmanager.persistence.FullSpec)2