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

    SynchronizationEvent synchronizationEvent = mock(SynchronizationEvent.class);
    when(synchronizationEvent.isSatisfied()).thenReturn(false);
    Condition condition = mock(Condition.class);
    // condition#await returns false if time was exceeded
    when(condition.await(timeout, TimeUnit.SECONDS)).thenReturn(false);
    Lock lock = mock(Lock.class);
    when(lock.newCondition()).thenReturn(condition);
    SignalizationBasedEventSynchronizer signalizationBasedEventSynchronizer = new SignalizationBasedEventSynchronizer(timeout, lock);
    expectedException.expect(TimeoutException.class);
    signalizationBasedEventSynchronizer.awaitUntil(synchronizationEvent);
}