public WarningsCollector() { createdMocks = new LinkedList(); MockingProgress progress = new ThreadSafeMockingProgress(); progress.setListener(new CollectCreatedMocks(createdMocks)); }
public VerificationCollector assertLazily() { mockingProgress().setVerificationStrategy(new VerificationStrategy() { public VerificationMode maybeVerifyLazily(VerificationMode mode) { return new VerificationWrapper(mode); } }); return this; }
public String toString() { return threadSafely().toString(); }
public void validateMockitoUsage() { mockingProgress().validateState(); }
public void setListener(MockingProgressListener listener) { threadSafely().setListener(listener); } }
public MockHandlerImpl(MockCreationSettings mockSettings) { this.mockSettings = mockSettings; this.mockingProgress = new ThreadSafeMockingProgress(); this.matchersBinder = new MatchersBinder(); this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress); }
/** * For testing purposes only. Is not the part of main API. * * @return last invocation */ public Invocation getLastInvocation() { OngoingStubbingImpl ongoingStubbing = ((OngoingStubbingImpl) mockingProgress().pullOngoingStubbing()); List<Invocation> allInvocations = ongoingStubbing.getRegisteredInvocations(); return allInvocations.get(allInvocations.size() - 1); }
public VerificationMode pullVerificationMode() { return threadSafely().pullVerificationMode(); }
public class MocksCollector { private final List<Object> createdMocks; public MocksCollector() { createdMocks = new LinkedList<Object>(); final MockingProgress progress = new ThreadSafeMockingProgress(); progress.setListener(new CollectCreatedMocks(createdMocks)); } public Object[] getMocks() { return createdMocks.toArray(); } }
public <T> T mock(Class<T> typeToMock, MockSettings settings) { if (!MockSettingsImpl.class.isInstance(settings)) { throw new IllegalArgumentException("Unexpected implementation of '" + settings.getClass().getCanonicalName() + "'\n" + "At the moment, you cannot provide your own implementations of that class."); } MockSettingsImpl impl = MockSettingsImpl.class.cast(settings); MockCreationSettings<T> creationSettings = impl.build(typeToMock); T mock = createMock(creationSettings); mockingProgress().mockingStarted(mock, creationSettings); return mock; }
public void resetOngoingStubbing() { threadSafely().resetOngoingStubbing(); }
Mockito.verify(mockRoutingServerApi).sendRealTimeUpdate( new ThreadSafeMockingProgress().getArgumentMatcherStorage() .reportMatcher(TimeMatcher.isTimeEqual(localDateTime2)) .returnFor(RealtimeUpdate.class));
public MockitoFramework addListener(MockitoListener listener) { Checks.checkNotNull(listener, "listener"); mockingProgress().addListener(listener); return this; }
public ArgumentMatcherStorage getArgumentMatcherStorage() { return threadSafely().getArgumentMatcherStorage(); }
public WarningsCollector() { createdMocks = new LinkedList(); MockingProgress progress = new ThreadSafeMockingProgress(); progress.setListener(new CollectCreatedMocks(createdMocks)); }
public MockitoFramework removeListener(MockitoListener listener) { Checks.checkNotNull(listener, "listener"); mockingProgress().removeListener(listener); return this; }
public void reportOngoingStubbing(IOngoingStubbing iOngoingStubbing) { threadSafely().reportOngoingStubbing(iOngoingStubbing); }
public MockHandler(MockSettingsImpl mockSettings) { this.mockSettings = mockSettings; this.mockingProgress = new ThreadSafeMockingProgress(); this.matchersBinder = new MatchersBinder(); this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress); }
/** * boolean argument that does not match the given argument matcher. * <p> * See examples in javadoc for {@link AdditionalMatchers} class * * @param first * placeholder for the argument matcher. * @return <code>false</code>. */ public static boolean not(boolean first) { mockingProgress().getArgumentMatcherStorage().reportNot(); return false; }
public void stubbingStarted() { threadSafely().stubbingStarted(); }