Package org.mockito.exceptions

Examples of org.mockito.exceptions.Reporter


    public void verify(VerificationData data) {
        Invocation unverified = new InvocationsFinder().findFirstUnverified(data.getAllInvocations());
       
        if (unverified != null) {
            new Reporter().noMoreInteractionsWanted(unverified);
        }
    }
View Full Code Here


    public void verifyInOrder(VerificationDataInOrder data) {
        List<Invocation> invocations = data.getAllInvocations();
        Invocation unverified = new InvocationsFinder().findFirstUnverifiedInOrder(data.getOrderingContext(), invocations);
       
        if (unverified != null) {
            new Reporter().noMoreInteractionsWantedInOrder(unverified);
        }
    }
View Full Code Here

        if (wanted == null) {
            return;
        }
        ObjectMethodsGuru o = new ObjectMethodsGuru();
        if (o.isToString(wanted.getMethod())) {
            new Reporter().cannotVerifyToString();
        }
    }
View Full Code Here

  @Override
  public void verify(VerificationData data) {
    List<Invocation> invocations = data.getAllInvocations();
    InvocationMatcher wanted = data.getWanted();

    Reporter reporter = new Reporter();
    InvocationsFinder finder = new InvocationsFinder();
    List<Invocation> found = finder.findInvocations(invocations, wanted);
    int invocationCount = found.size();
    if (invocationCount != _wantedNumberOfInvocations) {
      LOG.warn("invocation count is " + invocationCount + " expected was " + _wantedNumberOfInvocations + " +-"
              + _aberration);
    }

    int minNumberOfInvocations = _wantedNumberOfInvocations - _aberration;
    if (invocationCount < minNumberOfInvocations) {
      Location lastLocation = finder.getLastLocation(invocations);
      reporter.tooLittleActualInvocations(new AtLeastDiscrepancy(minNumberOfInvocations, invocationCount), wanted,
              lastLocation);
    }
    int maxNumberOfInvocations = _wantedNumberOfInvocations + _aberration;
    if (invocationCount > maxNumberOfInvocations) {
      reporter.wantedAtMostX(maxNumberOfInvocations, invocationCount);
    }
  }
View Full Code Here

        }
    }

    static void throwIfAlreadyAssigned(Field field, boolean alreadyAssigned) {
        if (alreadyAssigned) {
            new Reporter().moreThanOneAnnotationNotAllowed(field.getName());
        }
    }
View Full Code Here

            if (new ObjectMethodsGuru().isToString(currentInvocation.getMethod())) {
                return "SmartNull returned by this unstubbed method call on a mock:\n" +
                        unstubbedInvocation.toString();
            }

            new Reporter().smartNullPointerException(unstubbedInvocation.toString(), location);
            return null;
        }
View Full Code Here

    private void validateReturnArgIdentity(ReturnsArgumentAt returnsArgumentAt, Invocation invocation) {
        returnsArgumentAt.validateIndexWithinInvocationRange(invocation);

        MethodInfo methodInfo = new MethodInfo(invocation);
        if (!methodInfo.isValidReturnType(returnsArgumentAt.returnedTypeOnSignature(invocation))) {
            new Reporter().wrongTypeOfArgumentToReturn(invocation, methodInfo.printMethodReturnType(),
                                                       returnsArgumentAt.returnedTypeOnSignature(invocation),
                                                       returnsArgumentAt.wantedArgumentPosition());
        }

    }
View Full Code Here

        return invocation.getArguments().length - 1;
    }

    private int checkWithinAllowedRange(int argumentPosition) {
        if (argumentPosition != LAST_ARGUMENT && argumentPosition < 0) {
            new Reporter().invalidArgumentRangeAtIdentityAnswerCreationTime();
        }
        return argumentPosition;
    }
View Full Code Here

        return wantedArgumentPosition;
    }

    public void validateIndexWithinInvocationRange(InvocationOnMock invocation) {
        if (!argumentPositionInRange(invocation)) {
            new Reporter().invalidArgumentPositionRangeAtInvocationTime(invocation,
                                                                        returningLastArg(),
                                                                        wantedArgumentPosition);
        }
    }
View Full Code Here

        this.invocationContainerImpl = invocationContainerImpl;
    }

    public OngoingStubbing<T> thenAnswer(Answer<?> answer) {
        if(!invocationContainerImpl.hasInvocationForPotentialStubbing()) {
            new Reporter().incorrectUseOfApi();
        }

        invocationContainerImpl.addAnswer(answer);
        return new ConsecutiveStubbing<T>(invocationContainerImpl);
    }
View Full Code Here

TOP

Related Classes of org.mockito.exceptions.Reporter

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.