@Test public void testExpiredJobReaper() throws Exception { when(mockClock.now()).thenReturn(new Instant(CURRENT_TS)); when(masterModel.getJobs()).thenReturn(JOBS); when(masterModel.getJobStatus(any(JobId.class))) .then(new Answer<JobStatus>() { @Override public JobStatus answer(final InvocationOnMock invocation) throws Throwable { final JobId jobId = (JobId) invocation.getArguments()[0]; final Map<String, Deployment> deployments = ImmutableMap.of( "hostA", Deployment.of(jobId, Goal.START), "hostB", Deployment.of(jobId, Goal.START)); return JobStatus.newBuilder() .setJob(JOBS.get(jobId)) .setDeployments(deployments) .build(); } }); ExpiredJobReaper.newBuilder() .setClock(mockClock) .setMasterModel(masterModel) .build() .runOneIteration(); verify(masterModel).undeployJob(eq("hostA"), eq(EXPIRING_JOB_ID), eq("")); verify(masterModel).undeployJob(eq("hostB"), eq(EXPIRING_JOB_ID), eq("")); verify(masterModel).removeJob(eq(EXPIRING_JOB_ID), eq("")); verifyNoMoreInteractions(ignoreStubs(masterModel)); }
private ExpiredJobReaper(final Builder builder) { this.masterModel = builder.masterModel; this.interval = builder.interval; this.timeUnit = checkNotNull(builder.timeUnit); this.clock = checkNotNull(builder.clock); }
ExpiredJobReaper extends InterruptingScheduledService { private ExpiredJobReaper(final Builder builder) { this.masterModel = builder.masterModel; this.interval = builder.interval; this.timeUnit = checkNotNull(builder.timeUnit); this.clock = checkNotNull(builder.clock); } }
ExpiredJobReaper extends InterruptingScheduledService { private ExpiredJobReaper(final Builder builder) { this.masterModel = builder.masterModel; this.interval = builder.interval; this.timeUnit = checkNotNull(builder.timeUnit); this.clock = checkNotNull(builder.clock); } private  ExpiredJobReaper(final Builder builder); }
ExpiredJobReaper extends InterruptingScheduledService { private ExpiredJobReaper(final Builder builder) { this.masterModel = builder.masterModel; this.interval = builder.interval; this.timeUnit = checkNotNull(builder.timeUnit); this.clock = checkNotNull(builder.clock); } private  ExpiredJobReaper(final Builder builder); @Override void runOneIteration(); static Builder newBuilder(); }
ExpiredJobReaper extends InterruptingScheduledService { private ExpiredJobReaper(final Builder builder) { this.masterModel = builder.masterModel; this.interval = builder.interval; this.timeUnit = checkNotNull(builder.timeUnit); this.clock = checkNotNull(builder.clock); } private  ExpiredJobReaper(final Builder builder); @Override void runOneIteration(); static Builder newBuilder();  }