Search in sources :

Example 6 with JobDatabase

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

the class FastJobStorageTest method insertJobs_memoryOnlyJob_doesNotWriteToDatabase.

@Test
public void insertJobs_memoryOnlyJob_doesNotWriteToDatabase() {
    JobDatabase database = noopDatabase();
    FastJobStorage subject = new FastJobStorage(database);
    subject.insertJobs(DataSetMemory.FULL_SPECS);
    verify(database, times(0)).insertJobs(DataSet1.FULL_SPECS);
}
Also used : JobDatabase(org.thoughtcrime.securesms.database.JobDatabase) Test(org.junit.Test)

Example 7 with JobDatabase

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

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 8 with JobDatabase

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

the class FastJobStorageTest method deleteJobs_memoryOnly_doesNotWriteToDatabase.

@Test
public void deleteJobs_memoryOnly_doesNotWriteToDatabase() {
    JobDatabase database = fixedDataDatabase(DataSetMemory.FULL_SPECS);
    FastJobStorage subject = new FastJobStorage(database);
    List<String> ids = Collections.singletonList("id1");
    subject.init();
    subject.deleteJobs(ids);
    verify(database, times(0)).deleteJobs(ids);
}
Also used : JobDatabase(org.thoughtcrime.securesms.database.JobDatabase) Test(org.junit.Test)

Example 9 with JobDatabase

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

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 10 with JobDatabase

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

the class FastJobStorageTest method deleteJobs_writesToDatabase.

@Test
public void deleteJobs_writesToDatabase() {
    JobDatabase database = fixedDataDatabase(DataSet1.FULL_SPECS);
    FastJobStorage subject = new FastJobStorage(database);
    List<String> ids = Arrays.asList("id1", "id2");
    subject.init();
    subject.deleteJobs(ids);
    verify(database).deleteJobs(ids);
}
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