org.mockito.internal.stubbing.OngoingStubbingImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockito-all Show documentation
Show all versions of mockito-all Show documentation
Mock objects library for java
/*
* Copyright (c) 2007 Mockito contributors
* This program is made available under the terms of the MIT License.
*/
package org.mockito.internal.stubbing;
import org.mockito.exceptions.Reporter;
import org.mockito.invocation.Invocation;
import org.mockito.stubbing.Answer;
import org.mockito.stubbing.DeprecatedOngoingStubbing;
import org.mockito.stubbing.OngoingStubbing;
import java.util.List;
public class OngoingStubbingImpl extends BaseStubbing {
private final InvocationContainerImpl invocationContainerImpl;
public OngoingStubbingImpl(InvocationContainerImpl invocationContainerImpl) {
this.invocationContainerImpl = invocationContainerImpl;
}
public OngoingStubbing thenAnswer(Answer> answer) {
if(!invocationContainerImpl.hasInvocationForPotentialStubbing()) {
new Reporter().incorrectUseOfApi();
}
invocationContainerImpl.addAnswer(answer);
return new ConsecutiveStubbing(invocationContainerImpl);
}
public OngoingStubbing then(Answer> answer) {
return thenAnswer(answer);
}
public DeprecatedOngoingStubbing toAnswer(Answer> answer) {
invocationContainerImpl.addAnswer(answer);
return new ConsecutiveStubbing(invocationContainerImpl);
}
public List getRegisteredInvocations() {
//TODO interface for tests
return invocationContainerImpl.getInvocations();
}
public M getMock() {
return (M) invocationContainerImpl.invokedMock();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy