### Question:
HazelcastExecutor extends ThreadPoolExecutor implements Executor { void setWaitingTime(long newTime) { waitingTimeInMillis = newTime; } HazelcastExecutor(int maxParallelThreads, HazelcastInstance hazelcast);   }### Answer:
@Test public void shouldWakeUpByItself() throws InterruptedException { configureProcessMock(processMockA1, "book1", OcrPriority.NORMAL, 1L, NOT_ENOUGH_SPACE, ENOUGH_SPACE); executorSutA.setWaitingTime(10); executorSutA.execute(processMockA1); shutdownExecutors(); verify(processMockA1).run(); }
@Test public void shouldNeverWakeUp() throws InterruptedException { configureProcessMock(processMockA1, "book1", OcrPriority.NORMAL, 1L, NOT_ENOUGH_SPACE); executorSutA.setWaitingTime(10); executorSutA.execute(processMockA1); shutdownExecutors(); verify(processMockA1, never()).run(); }
@Test public void secondShouldFreeFirst() throws InterruptedException { configureProcessMock(processMockA1, "book1", OcrPriority.NORMAL, 1L, NOT_ENOUGH_SPACE, ENOUGH_SPACE); configureProcessMock(processMockA2, "book2", OcrPriority.ABOVENORMAL, 2L, ENOUGH_SPACE); executorSutA.setWaitingTime(VERY_LONG); executorSutA.execute(processMockA1); Thread.sleep(10); executorSutA.execute(processMockA2); shutdownExecutors(); verify(processMockA1).run(); verify(processMockA2).run(); }