Search in sources :

Example 26 with MockSettingsImpl

use of org.mockito.internal.creation.MockSettingsImpl 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) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) ArgumentMatcherStorage(org.mockito.internal.progress.ArgumentMatcherStorage) Test(org.junit.Test)

Aggregations

MockSettingsImpl (org.mockito.internal.creation.MockSettingsImpl)26 Test (org.junit.Test)19 Returns (org.mockito.internal.stubbing.answers.Returns)9 MockSettings (org.mockito.MockSettings)5 InvocationBuilder (org.mockito.internal.invocation.InvocationBuilder)5 CollectionData (com.torodb.core.d2r.CollectionData)4 DocPartData (com.torodb.core.d2r.DocPartData)4 BackendTransactionJob (com.torodb.core.dsl.backend.BackendTransactionJob)4 InsertBackendJob (com.torodb.core.dsl.backend.InsertBackendJob)4 List (java.util.List)4 Optional (java.util.Optional)4 Invocation (org.mockito.invocation.Invocation)4 MockName (org.mockito.mock.MockName)4 MockCreationSettings (org.mockito.mock.MockCreationSettings)3 AddFieldDdlJob (com.torodb.core.dsl.backend.AddFieldDdlJob)2 AddScalarDddlJob (com.torodb.core.dsl.backend.AddScalarDddlJob)2 ImmutableMetaField (com.torodb.core.transaction.metainf.ImmutableMetaField)2 ImmutableMetaScalar (com.torodb.core.transaction.metainf.ImmutableMetaScalar)2 InvocationMatcher (org.mockito.internal.invocation.InvocationMatcher)2 AddDocPartDdlJob (com.torodb.core.dsl.backend.AddDocPartDdlJob)1