org.mockito.internal.stubbing.InvocationContainerImpl Java Examples
The following examples show how to use
org.mockito.internal.stubbing.InvocationContainerImpl.
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: MockitoUtils.java From spring-analysis-note with MIT License | 5 votes |
/** * Verify the same invocations have been applied to two mocks. This is generally not * the preferred way test with mockito and should be avoided if possible. * @param expected the mock containing expected invocations * @param actual the mock containing actual invocations * @param argumentAdapters adapters that can be used to change argument values before they are compared */ public static <T> void verifySameInvocations(T expected, T actual, InvocationArgumentsAdapter... argumentAdapters) { List<Invocation> expectedInvocations = ((InvocationContainerImpl) MockUtil.getMockHandler(expected).getInvocationContainer()).getInvocations(); List<Invocation> actualInvocations = ((InvocationContainerImpl) MockUtil.getMockHandler(actual).getInvocationContainer()).getInvocations(); verifySameInvocations(expectedInvocations, actualInvocations, argumentAdapters); }
Example #2
Source File: MockitoUtils.java From java-technology-stack with MIT License | 5 votes |
/** * Verify the same invocations have been applied to two mocks. This is generally not * the preferred way test with mockito and should be avoided if possible. * @param expected the mock containing expected invocations * @param actual the mock containing actual invocations * @param argumentAdapters adapters that can be used to change argument values before they are compared */ public static <T> void verifySameInvocations(T expected, T actual, InvocationArgumentsAdapter... argumentAdapters) { List<Invocation> expectedInvocations = ((InvocationContainerImpl) MockUtil.getMockHandler(expected).getInvocationContainer()).getInvocations(); List<Invocation> actualInvocations = ((InvocationContainerImpl) MockUtil.getMockHandler(actual).getInvocationContainer()).getInvocations(); verifySameInvocations(expectedInvocations, actualInvocations, argumentAdapters); }
Example #3
Source File: ReturnsDeepStubs.java From astor with GNU General Public License v2.0 | 5 votes |
private Object deepStub(InvocationOnMock invocation, GenericMetadataSupport returnTypeGenericMetadata) throws Throwable { InternalMockHandler<Object> handler = new MockUtil().getMockHandler(invocation.getMock()); InvocationContainerImpl container = (InvocationContainerImpl) handler.getInvocationContainer(); // matches invocation for verification for (StubbedInvocationMatcher stubbedInvocationMatcher : container.getStubbedInvocations()) { if(container.getInvocationForStubbing().matches(stubbedInvocationMatcher.getInvocation())) { return stubbedInvocationMatcher.answer(invocation); } } // record deep stub answer return recordDeepStubAnswer(newDeepStubMock(returnTypeGenericMetadata), container); }
Example #4
Source File: MockHandler.java From astor with GNU General Public License v2.0 | 4 votes |
public MockHandler(MockSettingsImpl mockSettings) { this.mockSettings = mockSettings; this.mockingProgress = new ThreadSafeMockingProgress(); this.matchersBinder = new MatchersBinder(); this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress); }
Example #5
Source File: ReturnsDeepStubs.java From astor with GNU General Public License v2.0 | 4 votes |
private Object recordDeepStubAnswer(final Object mock, InvocationContainerImpl container) throws Throwable { container.addAnswer(new DeeplyStubbedAnswer(mock), false); return mock; }
Example #6
Source File: MockHandlerImplTest.java From astor with GNU General Public License v2.0 | 4 votes |
private void stubOrdinaryInvocationWithInvocationMatcher(MockHandlerImpl<?> handler, StubbedInvocationMatcher value) { handler.invocationContainerImpl = mock(InvocationContainerImpl.class); given(handler.invocationContainerImpl.findAnswerFor(any(InvocationImpl.class))).willReturn(value); }
Example #7
Source File: VersionLogContextVariableProducerTest.java From logging-interceptor with Apache License 2.0 | 4 votes |
@After public void printLogs() { ((InvocationContainerImpl) getMockHandler(log).getInvocationContainer()).getInvocations().forEach(System.out::println); }