### Question:
JobEntryJobRunner implements Runnable { public void waitUntilFinished() { while ( !isFinished() && !job.isStopped() ) { try { Thread.sleep( 0, 1 ); } catch ( InterruptedException e ) { } } } JobEntryJobRunner( Job job, Result result, int entryNr, LogChannelInterface log ); void run(); void setResult( Result result ); Result getResult(); LogChannelInterface getLog(); void setLog( LogChannelInterface log ); Job getJob(); void setJob( Job job ); int getEntryNr(); void setEntryNr( int entryNr ); boolean isFinished(); void waitUntilFinished();  }### Answer:
@Test public void testWaitUntilFinished() throws Exception { when( mockJob.isStopped() ).thenReturn( true ); when( mockJob.getParentJob() ).thenReturn( parentJob ); when( parentJob.isStopped() ).thenReturn( false ); when( mockJob.execute( Mockito.anyInt(), Mockito.any( Result.class ) ) ).thenReturn( mockResult ); jobRunner.waitUntilFinished(); }