类org.mockito.internal.verification.api.VerificationData源码实例Demo

下面列出了怎么用org.mockito.internal.verification.api.VerificationData的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: che   文件: ConcurrentCompositeLineConsumerTest.java
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);
  }
}
 
源代码2 项目: astor   文件: VerificationWithTimeoutImpl.java
public void verify(VerificationData data) {
    int soFar = 0;
    MockitoAssertionError error = null;
    while (soFar <= timeout) {
        try {
            delegate.verify(data);
            return;
        } catch (MockitoAssertionError e) {
            error = e;
            soFar += treshhold;
            sleep(treshhold);
        }
    }
    if (error != null) {
        throw error;
    }
}
 
源代码3 项目: astor   文件: AtMost.java
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);
}
 
源代码4 项目: astor   文件: NoMoreInteractions.java
@SuppressWarnings("unchecked")
public void verify(VerificationData data) {
    Invocation unverified = new InvocationsFinder().findFirstUnverified(data.getAllInvocations());                       
    if (unverified != null) {
        new Reporter().noMoreInteractionsWanted(unverified, (List) data.getAllInvocations());
    }
}
 
源代码5 项目: astor   文件: AtLeast.java
public void verify(VerificationData data) {
    MissingInvocationChecker missingInvocation = new MissingInvocationChecker();
    AtLeastXNumberOfInvocationsChecker numberOfInvocations = new AtLeastXNumberOfInvocationsChecker();
    
    if (wantedCount == 1) {
        missingInvocation.check(data.getAllInvocations(), data.getWanted());
    }
    numberOfInvocations.check(data.getAllInvocations(), data.getWanted(), wantedCount);
}
 
源代码6 项目: astor   文件: Times.java
public void verify(VerificationData data) {
    if (wantedCount > 0) {
        MissingInvocationChecker missingInvocation = new MissingInvocationChecker();
        missingInvocation.check(data.getAllInvocations(), data.getWanted());
    }
    NumberOfInvocationsChecker numberOfInvocations = new NumberOfInvocationsChecker();
    numberOfInvocations.check(data.getAllInvocations(), data.getWanted(), wantedCount);
}
 
源代码7 项目: astor   文件: Only.java
@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);
}
 
源代码8 项目: astor   文件: AtMost.java
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);
}
 
源代码9 项目: astor   文件: NoMoreInteractions.java
@SuppressWarnings("unchecked")
public void verify(VerificationData data) {
    Invocation unverified = new InvocationsFinder().findFirstUnverified(data.getAllInvocations());
    if (unverified != null) {
        new Reporter().noMoreInteractionsWanted(unverified, (List) data.getAllInvocations());
    }
}
 
源代码10 项目: astor   文件: AtLeast.java
public void verify(VerificationData data) {
    MissingInvocationChecker missingInvocation = new MissingInvocationChecker();
    AtLeastXNumberOfInvocationsChecker numberOfInvocations = new AtLeastXNumberOfInvocationsChecker();
    
    if (wantedCount == 1) {
        missingInvocation.check(data.getAllInvocations(), data.getWanted());
    }
    numberOfInvocations.check(data.getAllInvocations(), data.getWanted(), wantedCount);
}
 
源代码11 项目: astor   文件: VerificationOverTimeImpl.java
/**
 * Verify the given ongoing verification data, and confirm that it satisfies the delegate verification mode
 * before the full duration has passed.
 *
 * In practice, this polls the delegate verification mode until it is satisfied. If it is not satisfied once
 * the full duration has passed, the last error returned by the delegate verification mode will be thrown
 * here in turn. This may be thrown early if the delegate is unsatisfied and the verification mode is known
 * to never recover from this situation (e.g. {@link AtMost}).
 *
 * If it is satisfied before the full duration has passed, behaviour is dependent on the returnOnSuccess parameter
 * given in the constructor. If true, this verification mode is immediately satisfied once the delegate is. If
 * false, this verification mode is not satisfied until the delegate is satisfied and the full time has passed.
 *
 * @throws MockitoAssertionError if the delegate verification mode does not succeed before the timeout
 */
public void verify(VerificationData data) {
    MockitoAssertionError error = null;
    
    long startTime = System.currentTimeMillis();
    while (System.currentTimeMillis() - startTime <= durationMillis) {
        try {
            delegate.verify(data);
            
            if (returnOnSuccess) {
                return;
            } else {
                error = null;
            }
        } catch (MockitoAssertionError e) {
            if (canRecoverFromFailure(delegate)) {
                error = e;
                sleep(pollingPeriodMillis);
            } else {
                throw e;
            }
        }
    }
    
    if (error != null) {
        throw error;
    }
}
 
源代码12 项目: astor   文件: Times.java
public void verify(VerificationData data) {
    if (wantedCount > 0) {
        MissingInvocationChecker missingInvocation = new MissingInvocationChecker();
        missingInvocation.check(data.getAllInvocations(), data.getWanted());
    }
    NumberOfInvocationsChecker numberOfInvocations = new NumberOfInvocationsChecker();
    numberOfInvocations.check(data.getAllInvocations(), data.getWanted(), wantedCount);
}
 
源代码13 项目: astor   文件: Only.java
@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);
}
 
源代码14 项目: yangtools   文件: ArgumentsExtractorVerifier.java
@Override
public void verify(final VerificationData data) {
    List<Invocation> actualInvocations =
        InvocationsFinder.findInvocations(data.getAllInvocations(), data.getTarget());
    if (actualInvocations.size() != 1) {
        throw new MockitoException("This verifier can only be used with 1 invocation, got "
                + actualInvocations.size());
    }
    Invocation invocation = actualInvocations.get(0);
    arguments = invocation.getArguments();
    invocation.markVerified();
}
 
源代码15 项目: Volley-Ball   文件: LastInteraction.java
@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");
    }
}
 
源代码16 项目: astor   文件: InOrderWrapper.java
public void verify(VerificationData data) {
    List<Invocation> allInvocations = new AllInvocationsFinder().find(inOrder.getMocksToBeVerifiedInOrder());
    VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, allInvocations, data.getWanted());
    mode.verifyInOrder(dataInOrder);
}
 
源代码17 项目: astor   文件: MockAwareVerificationMode.java
public void verify(VerificationData data) {
    mode.verify(data);
}
 
源代码18 项目: astor   文件: Timeout.java
public void verify(VerificationData data) {
    impl.verify(data);
}
 
源代码19 项目: astor   文件: DummyVerificationMode.java
public void verify(VerificationData data) {
}
 
源代码20 项目: astor   文件: Calls.java
public void verify(VerificationData data) {
    throw new MockitoException( "calls is only intended to work with InOrder" );
}
 
源代码21 项目: astor   文件: InOrderWrapper.java
public void verify(VerificationData data) {
    List<Invocation> invocations = new VerifiableInvocationsFinder().find(inOrder.getMocksToBeVerifiedInOrder());
    VerificationDataInOrderImpl dataInOrder = new VerificationDataInOrderImpl(inOrder, invocations, data.getWanted());
    mode.verifyInOrder(dataInOrder);
}
 
源代码22 项目: astor   文件: MockAwareVerificationMode.java
public void verify(VerificationData data) {
    mode.verify(data);
}
 
源代码23 项目: astor   文件: VerificationWrapper.java
public void verify(VerificationData data) {
    wrappedVerification.verify(data);
}
 
源代码24 项目: astor   文件: DummyVerificationMode.java
public void verify(VerificationData data) {
}
 
@Override
public void verify(VerificationData data) {
  throw new RuntimeException("Applies only to inorder verification");
}
 
源代码26 项目: astor   文件: VerificationMode.java
void verify(VerificationData data); 
源代码27 项目: astor   文件: VerificationMode.java
void verify(VerificationData data); 
 类所在包
 同包方法