Search in sources :

Example 6 with InvocationMatcher

use of org.mockito.internal.invocation.InvocationMatcher in project mockito by mockito.

the class OnlyTest method shouldMarkAsVerified.

@Test
public void shouldMarkAsVerified() {
    // given
    Invocation invocation = new InvocationBuilder().toInvocation();
    assertFalse(invocation.isVerified());
    // when
    only.verify(new VerificationDataStub(new InvocationMatcher(invocation), invocation));
    // then
    assertTrue(invocation.isVerified());
}
Also used : Invocation(org.mockito.invocation.Invocation) MatchableInvocation(org.mockito.invocation.MatchableInvocation) InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) Test(org.junit.Test)

Example 7 with InvocationMatcher

use of org.mockito.internal.invocation.InvocationMatcher in project mockito by mockito.

the class SmartPrinterTest method setup.

@Before
public void setup() throws Exception {
    mock.varargs("first very long argument", "second very long argument", "another very long argument");
    multi = new InvocationMatcher(getLastInvocation());
    mock.varargs("short arg");
    shortie = new InvocationMatcher(getLastInvocation());
}
Also used : InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) Before(org.junit.Before)

Example 8 with InvocationMatcher

use of org.mockito.internal.invocation.InvocationMatcher in project mockito by mockito.

the class VerificationDataImplTest method shouldToStringBeNotVerifiable.

@Test
public void shouldToStringBeNotVerifiable() throws Exception {
    InvocationMatcher toString = new InvocationBuilder().method("toString").toInvocationMatcher();
    try {
        new VerificationDataImpl(null, toString);
        fail();
    } catch (MockitoException e) {
    }
}
Also used : MockitoException(org.mockito.exceptions.base.MockitoException) InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) Test(org.junit.Test)

Example 9 with InvocationMatcher

use of org.mockito.internal.invocation.InvocationMatcher in project mockito by mockito.

the class AtLeastXNumberOfInvocationsCheckerTest method shouldReportTooFewInvocations.

@Test
public void shouldReportTooFewInvocations() {
    // given
    Invocation invocation = new InvocationBuilder().simpleMethod().toInvocation();
    Invocation invocationTwo = new InvocationBuilder().differentMethod().toInvocation();
    // when
    assertThatThrownBy(() -> {
        checkAtLeastNumberOfInvocations(asList(invocation, invocationTwo), new InvocationMatcher(invocation), 2);
    }).isInstanceOf(TooFewActualInvocations.class).hasMessageContainingAll("iMethods.simpleMethod();", "Wanted *at least* 2 times", "But was 1 time");
}
Also used : Invocation(org.mockito.invocation.Invocation) InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) InvocationBuilder(org.mockito.internal.invocation.InvocationBuilder) TooFewActualInvocations(org.mockito.exceptions.verification.TooFewActualInvocations) Test(org.junit.Test)

Example 10 with InvocationMatcher

use of org.mockito.internal.invocation.InvocationMatcher in project mockito by mockito.

the class InvocationContainerImplTest method should_return_invoked_mock_stub_only.

@Test
public void should_return_invoked_mock_stub_only() throws Exception {
    containerStubOnly.setInvocationForPotentialStubbing(new InvocationMatcher(invocation));
    assertEquals(invocation.getMock(), containerStubOnly.invokedMock());
}
Also used : InvocationMatcher(org.mockito.internal.invocation.InvocationMatcher) Test(org.junit.Test)

Aggregations

InvocationMatcher (org.mockito.internal.invocation.InvocationMatcher)25 Test (org.junit.Test)19 InvocationBuilder (org.mockito.internal.invocation.InvocationBuilder)15 Invocation (org.mockito.invocation.Invocation)13 ThrowsException (org.mockito.internal.stubbing.answers.ThrowsException)4 MockSettingsImpl (org.mockito.internal.creation.MockSettingsImpl)3 Returns (org.mockito.internal.stubbing.answers.Returns)3 InOrderContextImpl (org.mockito.internal.verification.InOrderContextImpl)3 InOrderContext (org.mockito.internal.verification.api.InOrderContext)3 MockitoException (org.mockito.exceptions.base.MockitoException)2 NoInteractionsWanted (org.mockito.exceptions.verification.NoInteractionsWanted)2 InvocationContainerImpl (org.mockito.internal.stubbing.InvocationContainerImpl)2 IMethods (org.mockitousage.IMethods)2 LinkedList (java.util.LinkedList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Before (org.junit.Before)1 ArgumentMatcher (org.mockito.ArgumentMatcher)1 InvalidUseOfMatchersException (org.mockito.exceptions.misusing.InvalidUseOfMatchersException)1 TooFewActualInvocations (org.mockito.exceptions.verification.TooFewActualInvocations)1 VerificationInOrderFailure (org.mockito.exceptions.verification.VerificationInOrderFailure)1