Search in sources :

Example 1 with ArgumentMatcherStorage

use of org.mockito.internal.progress.ArgumentMatcherStorage in project mockito by mockito.

the class MockHandlerImplTest method should_remove_verification_mode_even_when_invalid_matchers.

@Test
public void should_remove_verification_mode_even_when_invalid_matchers() throws Throwable {
    // given
    Invocation invocation = new InvocationBuilder().toInvocation();
    @SuppressWarnings("rawtypes") MockHandlerImpl<?> handler = new MockHandlerImpl(new MockSettingsImpl());
    mockingProgress().verificationStarted(VerificationModeFactory.atLeastOnce());
    handler.matchersBinder = new MatchersBinder() {

        public InvocationMatcher bindMatchers(ArgumentMatcherStorage argumentMatcherStorage, Invocation invocation) {
            throw new InvalidUseOfMatchersException();
        }
    };
    try {
        // when
        handler.handle(invocation);
        // then
        fail();
    } catch (InvalidUseOfMatchersException ignored) {
    }
    assertNull(mockingProgress().pullVerificationMode());
}
Also used : InvalidUseOfMatchersException(org.mockito.exceptions.misusing.InvalidUseOfMatchersException) Invocation(org.mockito.invocation.Invocation) MatchersBinder(org.mockito.internal.invocation.MatchersBinder) MockSettingsImpl(org.mockito.internal.creation.MockSettingsImpl) InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) StubbedInvocationMatcher(org.mockito.internal.stubbing.StubbedInvocationMatcher) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) ArgumentMatcherStorage(org.mockito.internal.progress.ArgumentMatcherStorage) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 InvalidUseOfMatchersException (org.mockito.exceptions.misusing.InvalidUseOfMatchersException)1 MockSettingsImpl (org.mockito.internal.creation.MockSettingsImpl)1 InvocationBuilder (org.mockito.internal.invocation.InvocationBuilder)1 InvocationMatcher (org.mockito.internal.invocation.InvocationMatcher)1 MatchersBinder (org.mockito.internal.invocation.MatchersBinder)1 ArgumentMatcherStorage (org.mockito.internal.progress.ArgumentMatcherStorage)1 StubbedInvocationMatcher (org.mockito.internal.stubbing.StubbedInvocationMatcher)1 Invocation (org.mockito.invocation.Invocation)1