Java Code Examples for org.mockito.internal.verification.api.VerificationData#getWanted()

The following examples show how to use org.mockito.internal.verification.api.VerificationData#getWanted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConcurrentCompositeLineConsumerTest.java    From che with Eclipse Public License 2.0 6 votes vote down vote up
public void verify(VerificationData verificationData) {
  List<Invocation> invocations = verificationData.getAllInvocations();
  InvocationMatcher invocationMatcher = verificationData.getWanted();

  if (invocations == null || invocations.isEmpty()) {
    throw new MockitoException(
        "\nNo interactions with "
            + invocationMatcher.getInvocation().getMock()
            + " mock so far");
  }
  Invocation invocation = invocations.get(invocations.size() - 1);

  if (!invocationMatcher.matches(invocation)) {
    throw new MockitoException("\nWanted but not invoked:\n" + invocationMatcher);
  }
}
 
Example 2
Source File: AtMost.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void verify(VerificationData data) {
    List<Invocation> invocations = data.getAllInvocations();
    InvocationMatcher wanted = data.getWanted();
    
    InvocationsFinder finder = new InvocationsFinder();
    List<Invocation> found = finder.findInvocations(invocations, wanted);
    int foundSize = found.size();
    if (foundSize > maxNumberOfInvocations) {
        new Reporter().wantedAtMostX(maxNumberOfInvocations, foundSize);
    }
    
    invocationMarker.markVerified(found, wanted);
}
 
Example 3
Source File: Only.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
   public void verify(VerificationData data) {
	InvocationMatcher wantedMatcher = data.getWanted();
	List<Invocation> invocations = data.getAllInvocations();
	List<Invocation> chunk = finder.findInvocations(invocations,wantedMatcher);
	if (invocations.size() != 1 && chunk.size() > 0) {			
		Invocation unverified = finder.findFirstUnverified(invocations);
		reporter.noMoreInteractionsWanted(unverified, (List) invocations);
	} else if (invocations.size() != 1 || chunk.size() == 0) {
		reporter.wantedButNotInvoked(wantedMatcher);
	}
	marker.markVerified(chunk.get(0), wantedMatcher);
}
 
Example 4
Source File: AtMost.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void verify(VerificationData data) {
    List<Invocation> invocations = data.getAllInvocations();
    InvocationMatcher wanted = data.getWanted();
    
    InvocationsFinder finder = new InvocationsFinder();
    List<Invocation> found = finder.findInvocations(invocations, wanted);
    int foundSize = found.size();
    if (foundSize > maxNumberOfInvocations) {
        new Reporter().wantedAtMostX(maxNumberOfInvocations, foundSize);
    }
    
    invocationMarker.markVerified(found, wanted);
}
 
Example 5
Source File: Only.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
   public void verify(VerificationData data) {
	InvocationMatcher wantedMatcher = data.getWanted();
	List<Invocation> invocations = data.getAllInvocations();
	List<Invocation> chunk = finder.findInvocations(invocations,wantedMatcher);
	if (invocations.size() != 1 && chunk.size() > 0) {			
		Invocation unverified = finder.findFirstUnverified(invocations);
		reporter.noMoreInteractionsWanted(unverified, (List) invocations);
	} else if (invocations.size() != 1 || chunk.size() == 0) {
		reporter.wantedButNotInvoked(wantedMatcher);
	}
	marker.markVerified(chunk.get(0), wantedMatcher);
}
 
Example 6
Source File: LastInteraction.java    From Volley-Ball with MIT License 5 votes vote down vote up
@Override
public void verify(VerificationData data) {
    List<Invocation> invocations = data.getAllInvocations();
    InvocationMatcher matcher = data.getWanted();
    Invocation invocation = invocations.get(invocations.size() - 1);

    if (!matcher.matches(invocation)) {
        throw new MockitoException("This is not the last interaction with the mock object");
    }
}
 
Example 7
Source File: InOrderWrapper.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void verify(VerificationData data) {
    List<Invocation> allInvocations = new AllInvocationsFinder().find(inOrder.getMocksToBeVerifiedInOrder());
    VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, allInvocations, data.getWanted());
    mode.verifyInOrder(dataInOrder);
}
 
Example 8
Source File: InOrderWrapper.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
public void verify(VerificationData data) {
    List<Invocation> invocations = new VerifiableInvocationsFinder().find(inOrder.getMocksToBeVerifiedInOrder());
    VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, invocations, data.getWanted());
    mode.verifyInOrder(dataInOrder);
}