Search in sources :

Example 36 with Params

use of com.birbit.android.jobqueue.Params in project android-priority-jobqueue by yigit.

the class JobQueueTestBase method testDeadlineDoesNotAffectIdQuery.

@Test
public void testDeadlineDoesNotAffectIdQuery() {
    JobQueue jobQueue = createNewJobQueue();
    JobHolder jobHolder = createNewJobHolder(new Params(0).overrideDeadlineToRunInMs(10));
    jobQueue.insert(jobHolder);
    mockTimer.incrementMs(100);
    TestConstraint constraint = new TestConstraint(mockTimer);
    constraint.setExcludeJobIds(Collections.singletonList(jobHolder.getId()));
    assertThat(jobQueue.findJobs(constraint), is(Collections.EMPTY_SET));
    assertThat(jobQueue.getNextJobDelayUntilNs(constraint), is(nullValue()));
}
Also used : JobHolder(com.birbit.android.jobqueue.JobHolder) TestConstraint(com.birbit.android.jobqueue.TestConstraint) JobQueue(com.birbit.android.jobqueue.JobQueue) Params(com.birbit.android.jobqueue.Params) Test(org.junit.Test)

Example 37 with Params

use of com.birbit.android.jobqueue.Params in project android-priority-jobqueue by yigit.

the class JobQueueTestBase method testDelayUntilWithUnmeteredNetworkRequirement3.

@Test
public void testDelayUntilWithUnmeteredNetworkRequirement3() {
    JobQueue jobQueue = createNewJobQueue();
    JobHolder holder1 = createNewJobHolder(new Params(2).overrideDeadlineToRunInMs(2000).requireUnmeteredNetwork().delayInMs(1000));
    jobQueue.insert(holder1);
    TestConstraint constraint = new TestConstraint(mockTimer);
    constraint.setMaxNetworkType(NetworkUtil.METERED);
    assertThat(jobQueue.getNextJobDelayUntilNs(constraint), is(2000000000L));
}
Also used : JobHolder(com.birbit.android.jobqueue.JobHolder) TestConstraint(com.birbit.android.jobqueue.TestConstraint) JobQueue(com.birbit.android.jobqueue.JobQueue) Params(com.birbit.android.jobqueue.Params) Test(org.junit.Test)

Example 38 with Params

use of com.birbit.android.jobqueue.Params in project android-priority-jobqueue by yigit.

the class JobQueueTestBase method testDelayUntilWithNetworkRequirement5.

@Test
public void testDelayUntilWithNetworkRequirement5() {
    JobQueue jobQueue = createNewJobQueue();
    JobHolder holder1 = createNewJobHolder(new Params(2).overrideDeadlineToRunInMs(2000).delayInMs(1000).requireNetwork());
    jobQueue.insert(holder1);
    TestConstraint constraint = new TestConstraint(mockTimer);
    constraint.setMaxNetworkType(NetworkUtil.METERED);
    assertThat(jobQueue.getNextJobDelayUntilNs(constraint), is(1000000000L));
}
Also used : JobHolder(com.birbit.android.jobqueue.JobHolder) TestConstraint(com.birbit.android.jobqueue.TestConstraint) JobQueue(com.birbit.android.jobqueue.JobQueue) Params(com.birbit.android.jobqueue.Params) Test(org.junit.Test)

Example 39 with Params

use of com.birbit.android.jobqueue.Params in project android-priority-jobqueue by yigit.

the class JobQueueTestBase method testDelayUntilWithUnmeteredNetworkRequirementAndRegularDelayedJob3.

@Test
public void testDelayUntilWithUnmeteredNetworkRequirementAndRegularDelayedJob3() {
    JobQueue jobQueue = createNewJobQueue();
    JobHolder holder1 = createNewJobHolder(new Params(2).overrideDeadlineToRunInMs(500).requireUnmeteredNetwork());
    JobHolder holder2 = createNewJobHolder(new Params(2).delayInMs(1000));
    jobQueue.insert(holder1);
    jobQueue.insert(holder2);
    TestConstraint constraint = new TestConstraint(mockTimer);
    constraint.setMaxNetworkType(NetworkUtil.METERED);
    assertThat(jobQueue.getNextJobDelayUntilNs(constraint), is(500000000L));
}
Also used : JobHolder(com.birbit.android.jobqueue.JobHolder) TestConstraint(com.birbit.android.jobqueue.TestConstraint) JobQueue(com.birbit.android.jobqueue.JobQueue) Params(com.birbit.android.jobqueue.Params) Test(org.junit.Test)

Example 40 with Params

use of com.birbit.android.jobqueue.Params in project android-priority-jobqueue by yigit.

the class JobQueueTestBase method testDelayUntilWithUnmeteredNetworkRequirementAndRegularDelayedJob2.

@Test
public void testDelayUntilWithUnmeteredNetworkRequirementAndRegularDelayedJob2() {
    JobQueue jobQueue = createNewJobQueue();
    JobHolder holder1 = createNewJobHolder(new Params(2).overrideDeadlineToRunInMs(1000).requireUnmeteredNetwork());
    JobHolder holder2 = createNewJobHolder(new Params(2).delayInMs(500));
    jobQueue.insert(holder2);
    jobQueue.insert(holder1);
    TestConstraint constraint = new TestConstraint(mockTimer);
    constraint.setMaxNetworkType(NetworkUtil.METERED);
    assertThat(jobQueue.getNextJobDelayUntilNs(constraint), is(500000000L));
}
Also used : JobHolder(com.birbit.android.jobqueue.JobHolder) TestConstraint(com.birbit.android.jobqueue.TestConstraint) JobQueue(com.birbit.android.jobqueue.JobQueue) Params(com.birbit.android.jobqueue.Params) Test(org.junit.Test)

Aggregations

Params (com.birbit.android.jobqueue.Params)95 Test (org.junit.Test)75 JobManager (com.birbit.android.jobqueue.JobManager)47 JobHolder (com.birbit.android.jobqueue.JobHolder)46 DummyJob (com.birbit.android.jobqueue.test.jobs.DummyJob)41 JobQueue (com.birbit.android.jobqueue.JobQueue)40 TestConstraint (com.birbit.android.jobqueue.TestConstraint)37 Job (com.birbit.android.jobqueue.Job)31 CountDownLatch (java.util.concurrent.CountDownLatch)31 Configuration (com.birbit.android.jobqueue.config.Configuration)17 RetryConstraint (com.birbit.android.jobqueue.RetryConstraint)12 TargetApi (android.annotation.TargetApi)9 CancelResult (com.birbit.android.jobqueue.CancelResult)9 Constraint (com.birbit.android.jobqueue.Constraint)8 TagConstraint (com.birbit.android.jobqueue.TagConstraint)8 JobManagerCallbackAdapter (com.birbit.android.jobqueue.callback.JobManagerCallbackAdapter)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 ArrayList (java.util.ArrayList)6 JobManagerCallback (com.birbit.android.jobqueue.callback.JobManagerCallback)4 SqliteJobQueue (com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue)3