Package org.mockito.internal.invocation

Examples of org.mockito.internal.invocation.Invocation


    public void addConsecutiveAnswer(Answer answer) {
        addAnswer(answer, true);
    }

    public void addAnswer(Answer answer, boolean isConsecutive) {
        Invocation invocation = invocationForStubbing.getInvocation();
        mockingProgress.stubbingCompleted(invocation);
        AnswersValidator answersValidator = new AnswersValidator();
        answersValidator.validate(answer, invocation);

        if (isConsecutive) {
View Full Code Here


    InvocationMatcher wantedMatcher = data.getWanted();
    List<Invocation> invocations = data.getAllInvocations();
    List<Invocation> chunk = finder.findInvocations(invocations,wantedMatcher);
    if (invocations.size() != 1 && chunk.size() > 0) {
      marker.markVerified(chunk.get(0), wantedMatcher);
      Invocation unverified = finder.findFirstUnverified(invocations);
      reporter.noMoreInteractionsWanted(unverified, (List) invocations);
    } else if (invocations.size() != 1 || chunk.size() == 0) {
      reporter.wantedButNotInvoked(wantedMatcher);
    }
  }
View Full Code Here

       
        if (!chunk.isEmpty()) {
            return;
        }
       
        Invocation previousInOrder = finder.findPreviousVerifiedInOrder(invocations, context);
        if (previousInOrder == null) {
            /**
             * It is of course possible to have an issue where the arguments are different
             * rather that not invoked in order. Issue related to
             * http://code.google.com/p/mockito/issues/detail?id=27. If the previous order
             * is missing, then this method checks if the arguments are different or if the order
             * is not invoked.
             */
             List<Invocation> actualInvocations = finder.findInvocations(invocations, wanted);
             if (actualInvocations == null || actualInvocations.isEmpty())  {
                 Invocation similar = finder.findSimilarInvocation(invocations, wanted);
                 if (similar != null) {
                     Integer[] indicesOfSimilarMatchingArguments =
                             new ArgumentMatchingTool().getSuspiciouslyNotMatchingArgsIndexes(wanted.getMatchers(),
                                     similar.getArguments());
                     SmartPrinter smartPrinter = new SmartPrinter(wanted, similar, indicesOfSimilarMatchingArguments);
                     reporter.argumentsAreDifferent(smartPrinter.getWanted(), smartPrinter.getActual(), similar.getLocation());
                 } else {
                     reporter.wantedButNotInvoked(wanted);
                 }
             }
        } else {
View Full Code Here

                }
                return null;
            }
        });
        // }
        Invocation invocation = new Invocation(interceptionObject, new DelegatingMethod(method), arguments,
                SequenceNumber.next(), cglibProxyRealMethod) {
            private static final long serialVersionUID = -3679957412502758558L;

            /**
             * We need to override this method because normally the String
             * "method" is assembled by calling the "qualifiedName" method but
             * this is not possible in our case. The reason is that the
             * qualifiedName method does
             *
             * <pre>
             * new MockUtil().getMockName(mock)
             * </pre>
             *
             * which later will call the "isMockitoMock" method which will
             * return false and an exception will be thrown. The reason why
             * "isMockitoMock" returns false is that the mock is not created by
             * the Mockito CGLib Enhancer in case of static methods.
             */
            @Override
            protected String toString(@SuppressWarnings("rawtypes") List<Matcher> matchers, PrintSettings printSettings) {
                MatchersPrinter matchersPrinter = new MatchersPrinter();
                String method = Whitebox.getType(getMock()).getName() + "." + getMethodName();
                String invocation = method + matchersPrinter.getArgumentsLine(matchers, printSettings);
                if (printSettings.isMultiline()
                        || (!matchers.isEmpty() && invocation.length() > Whitebox.<Integer> getInternalState(
                        Invocation.class, "MAX_LINE_LENGTH"))) {
                    return method + matchersPrinter.getArgumentsBlock(matchers, printSettings);
                } else {
                    return invocation;
                }
            }
        };
        try {
            return mockHandler.handle(invocation);
        } catch (NotAMockException e) {
            if(invocation.getMock().getClass().getName().startsWith("java.") &&  MockRepository.getInstanceMethodInvocationControl(invocation.getMock()) != null) {
                return invocation.callRealMethod();
            } else {
                throw e;
            }
        } catch (MockitoAssertionError e) {
            InvocationControlAssertionError.updateErrorMessageForMethodInvocation(e);
View Full Code Here

TOP

Related Classes of org.mockito.internal.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.