### Question:
LastRunConstraint extends ProtoConstraint.LastRunConstraint implements CheckableConstraint { public LastRunConstraint(long durationSinceLastRun, TimeUnit unit) { super(durationSinceLastRun, unit); } LastRunConstraint(long durationSinceLastRun, TimeUnit unit); @Override ConstraintResult check(ProgramSchedule schedule, ConstraintContext context);  }### Answer:
@Test public void testLastRunConstraint() { Store store = AppFabricTestHelper.getInjector().getInstance(Store.class); try { long now = System.currentTimeMillis(); long nowSec = TimeUnit.MILLISECONDS.toSeconds(now); ProgramSchedule schedule = new ProgramSchedule("SCHED1", "one partition schedule", WORKFLOW_ID, ImmutableMap.of("prop3", "abc"), new PartitionTrigger(DATASET_ID, 1), ImmutableList.of()); SimpleJob job = new SimpleJob(schedule, 0, now, Collections.emptyList(), Job.State.PENDING_TRIGGER, 0L); LastRunConstraint lastRunConstraint = new LastRunConstraint(1, TimeUnit.HOURS); ConstraintContext constraintContext = new ConstraintContext(job, now, store); assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext)); ProgramRunId pid1 = WORKFLOW_ID.run(RunIds.generate(nowSec - TimeUnit.HOURS.toSeconds(3)).getId()); Map<String, String> systemArgs = ImmutableMap.of(ProgramOptionConstants.SCHEDULE_NAME, schedule.getName()); setStartAndRunning(store, pid1, EMPTY_MAP, systemArgs); assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext)); store.setSuspend(pid1, AppFabricTestHelper.createSourceId(++sourceId), -1); assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext)); store.setResume(pid1, AppFabricTestHelper.createSourceId(++sourceId), -1); assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext)); store.setStop(pid1, nowSec - TimeUnit.HOURS.toSeconds(2), ProgramRunStatus.COMPLETED, AppFabricTestHelper.createSourceId(++sourceId)); assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext)); ProgramRunId pid2 = WORKFLOW_ID.run(RunIds.generate(nowSec - TimeUnit.HOURS.toSeconds(2)).getId()); setStartAndRunning(store, pid2); assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext)); store.setStop(pid2, nowSec - TimeUnit.MINUTES.toSeconds(1), ProgramRunStatus.FAILED, AppFabricTestHelper.createSourceId(++sourceId)); assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext)); ProgramRunId pid3 = WORKFLOW_ID.run(RunIds.generate(nowSec - TimeUnit.HOURS.toSeconds(2)).getId()); setStartAndRunning(store, pid3); assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext)); store.setStop(pid3, nowSec - TimeUnit.MINUTES.toSeconds(1), ProgramRunStatus.KILLED, AppFabricTestHelper.createSourceId(++sourceId)); assertSatisfied(true, lastRunConstraint.check(schedule, constraintContext)); ProgramRunId pid4 = WORKFLOW_ID.run(RunIds.generate(nowSec - TimeUnit.HOURS.toSeconds(2)).getId()); setStartAndRunning(store, pid4); assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext)); store.setStop(pid4, nowSec - TimeUnit.MINUTES.toSeconds(1), ProgramRunStatus.COMPLETED, AppFabricTestHelper.createSourceId(++sourceId)); assertSatisfied(false, lastRunConstraint.check(schedule, constraintContext)); } finally { AppFabricTestHelper.shutdown(); } }