@Test
public void testTaskLifeCycle() {
expectStatusCountersInitialized();
IScheduledTask taskA = makeTask(JOB_A, INIT);
expectGetHostRack("hostA", "rackA").atLeastOnce();
expectStatExport(rackStatName("rackA"));
replayAndBuild();
schedulerActivated();
changeState(makeTask(JOB_A, INIT), PENDING);
assertEquals(1, getValue(PENDING));
changeState(IScheduledTask.build(taskA.newBuilder().setStatus(PENDING)), ASSIGNED);
assertEquals(0, getValue(PENDING));
assertEquals(1, getValue(ASSIGNED));
taskA = makeTask(JOB_A, ASSIGNED, "hostA");
changeState(IScheduledTask.build(taskA.newBuilder().setStatus(ASSIGNED)), RUNNING);
assertEquals(0, getValue(ASSIGNED));
assertEquals(1, getValue(RUNNING));
changeState(IScheduledTask.build(taskA.newBuilder().setStatus(RUNNING)), FINISHED);
assertEquals(0, getValue(RUNNING));
assertEquals(1, getValue(FINISHED));
assertEquals(0, getValue(rackStatName("rackA")));
vars.tasksDeleted(new TasksDeleted(ImmutableSet.of(
IScheduledTask.build(taskA.newBuilder().setStatus(FINISHED)))));
assertAllZero();
}