com.fitbur.mockito.internal.verification.NoMoreInteractions Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package com.fitbur.mockito.internal.verification;
import static com.fitbur.mockito.exceptions.Reporter.noMoreInteractionsWanted;
import static com.fitbur.mockito.exceptions.Reporter.noMoreInteractionsWantedInOrder;
import java.util.List;
import com.fitbur.mockito.exceptions.Reporter;
import com.fitbur.mockito.internal.invocation.InvocationsFinder;
import com.fitbur.mockito.internal.verification.api.VerificationData;
import com.fitbur.mockito.internal.verification.api.VerificationDataInOrder;
import com.fitbur.mockito.internal.verification.api.VerificationInOrderMode;
import com.fitbur.mockito.invocation.Invocation;
import com.fitbur.mockito.verification.VerificationMode;
public class NoMoreInteractions implements VerificationMode, VerificationInOrderMode {
@SuppressWarnings("unchecked")
public void verify(VerificationData data) {
Invocation unverified = new InvocationsFinder().findFirstUnverified(data.getAllInvocations());
if (unverified != null) {
throw noMoreInteractionsWanted(unverified, (List) data.getAllInvocations());
}
}
public void verifyInOrder(VerificationDataInOrder data) {
List invocations = data.getAllInvocations();
Invocation unverified = new InvocationsFinder().findFirstUnverifiedInOrder(data.getOrderingContext(), invocations);
if (unverified != null) {
throw noMoreInteractionsWantedInOrder(unverified);
}
}
@Override
public VerificationMode description(String description) {
return VerificationModeFactory.description(this, description);
}
}