Package org.mockito.invocation

Examples of org.mockito.invocation.Invocation


    @Test
    public void shouldKnowWhenVarargsMatch() {
        //given
        mock.varargs("1", "2", "3");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(new Equals("1"), Any.ANY, new InstanceOf(String.class)));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here


    @Test
    public void shouldKnowWhenVarargsDifferent() {
        //given
        mock.varargs("1", "2");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(new Equals("100"), Any.ANY));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here

    @Test
    public void shouldNotAllowAnyObjectMatchEntireVararg() {
        //given
        mock.varargs("1", "2");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(Any.ANY));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here

    }
   
    @Test
    public void should_fail_when_calling_real_method_on_interface() throws Throwable {
        //given
        Invocation invocationOnInterface = new InvocationBuilder().method("simpleMethod").toInvocation();
        try {
            //when
            validator.validate(new CallsRealMethods(), invocationOnInterface);
            //then
            fail();
View Full Code Here

    @Test
    public void shouldAllowAnyVarargMatchEntireVararg() {
        //given
        mock.varargs("1", "2");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(AnyVararg.ANY_VARARG));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here

    @Test
    public void should_be_OK_when_calling_real_method_on_concrete_class() throws Throwable {
        //given
        ArrayList mock = mock(ArrayList.class);
        mock.clear();
        Invocation invocationOnClass = new MockitoCore().getLastInvocation();
        //when
        validator.validate(new CallsRealMethods(), invocationOnClass);
        //then no exception is thrown
    }
View Full Code Here

    @Test
    public void shouldNotAllowAnyObjectWithMixedVarargs() {
        //given
        mock.mixedVarargs(1, "1", "2");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(new Equals(1)));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here

    @Test
    public void shouldAllowAnyObjectWithMixedVarargs() {
        //given
        mock.mixedVarargs(1, "1", "2");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(new Equals(1), AnyVararg.ANY_VARARG));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here

    @Test
    public void shouldNotMatchWhenSomeOtherArgumentDoesNotMatch() {
        //given
        mock.mixedVarargs(1, "1", "2");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(new Equals(100), AnyVararg.ANY_VARARG));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here

    @Test
    public void shouldAnyObjectVarargDealWithDifferentSizeOfArgs() {
        //given
        mock.mixedVarargs(1, "1", "2");
        Invocation invocation = getLastInvocation();
        InvocationMatcher invocationMatcher = new InvocationMatcher(invocation, (List) asList(new Equals(1)));

        //when
        boolean match = comparator.argumentsMatch(invocationMatcher, invocation);
View Full Code Here

TOP

Related Classes of org.mockito.invocation.Invocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.