assertStoreContents();
}
@Test
public void testConsistentJobIndex() {
final IScheduledTask a = makeTask("a", "jim", "test", "job");
final IScheduledTask b = makeTask("b", "jim", "test", "job");
final IScheduledTask c = makeTask("c", "jim", "test", "job2");
final IScheduledTask d = makeTask("d", "joe", "test", "job");
final IScheduledTask e = makeTask("e", "jim", "prod", "job");
final Query.Builder jimsJob = Query.jobScoped(JobKeys.from("jim", "test", "job"));
final Query.Builder jimsJob2 = Query.jobScoped(JobKeys.from("jim", "test", "job2"));
final Query.Builder joesJob = Query.jobScoped(JobKeys.from("joe", "test", "job"));
store.saveTasks(ImmutableSet.of(a, b, c, d, e));
assertQueryResults(jimsJob, a, b);
assertQueryResults(jimsJob2, c);
assertQueryResults(joesJob, d);
store.deleteTasks(ImmutableSet.of(Tasks.id(b)));
assertQueryResults(jimsJob, a);
assertQueryResults(jimsJob2, c);
assertQueryResults(joesJob, d);
store.mutateTasks(jimsJob, new TaskMutation() {
@Override
public IScheduledTask apply(IScheduledTask task) {
return IScheduledTask.build(task.newBuilder().setStatus(RUNNING));
}
});
IScheduledTask aRunning = IScheduledTask.build(a.newBuilder().setStatus(RUNNING));
assertQueryResults(jimsJob, aRunning);
assertQueryResults(jimsJob2, c);
assertQueryResults(joesJob, d);
store.deleteTasks(ImmutableSet.of(Tasks.id(d)));