mock awaitTermination in junit

Viewed 58

i have a code like this

if (!executorService.awaitTermination(900000l,TimeUnit.MILLISECONDS)){
executorService.shutdowNow();
}

what i want is to mock the return type of awaitTermination to get false to go to the condition

what i did in test

@Mock
ExecutorService executorService;

Mockito.when(executorService.awaitTermination(anyLong(),any(TimeUnit.class)).thenReturn(false) // this line dont work it always return true when i debug it

any idea how to mock that line to get false ?

0 Answers
Related