@Test
public void ifIllegalStateExceptionIsThrownIsIsLocked() throws TimeoutException, InterruptedException {

    SynchronizationEvent synchronizationEvent = mock(SynchronizationEvent.class);
    when(synchronizationEvent.isSatisfied()).thenReturn(false);
    Condition condition = mock(Condition.class);
    doAnswer(invocationOnMock -> {
        Thread.sleep(2000);
        return false;
    }).when(condition).await(timeout, TimeUnit.SECONDS);
    Lock lock = mock(Lock.class);
    when(lock.newCondition()).thenReturn(condition);
    doNothing().doThrow(new IllegalMonitorStateException()).when(lock).lock();
    SignalizationBasedEventSynchronizer signalizationBasedEventSynchronizer = new SignalizationBasedEventSynchronizer(timeout, lock);
    Thread signalizingThread = new Thread(new SignalizingRunnable(signalizationBasedEventSynchronizer, synchronizationEvent));
    expectedException.expect(TimeoutException.class);
    signalizingThread.start();
    signalizationBasedEventSynchronizer.awaitUntil(synchronizationEvent);
    signalizingThread.join();
}