类org.mockito.internal.stubbing.InvocationContainerImpl源码实例Demo

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

源代码1 项目: spring-analysis-note   文件: MockitoUtils.java
/**
 * 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);
}
 
源代码2 项目: java-technology-stack   文件: MockitoUtils.java
/**
 * 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);
}
 
源代码3 项目: astor   文件: ReturnsDeepStubs.java
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);
  }
 
源代码4 项目: astor   文件: MockHandler.java
public MockHandler(MockSettingsImpl mockSettings) {
    this.mockSettings = mockSettings;
    this.mockingProgress = new ThreadSafeMockingProgress();
    this.matchersBinder = new MatchersBinder();
    this.invocationContainerImpl = new InvocationContainerImpl(mockingProgress);
}
 
源代码5 项目: astor   文件: ReturnsDeepStubs.java
private Object recordDeepStubAnswer(final Object mock, InvocationContainerImpl container) throws Throwable {
    container.addAnswer(new DeeplyStubbedAnswer(mock), false);
    return mock;
}
 
源代码6 项目: astor   文件: MockHandlerImplTest.java
private void stubOrdinaryInvocationWithInvocationMatcher(MockHandlerImpl<?> handler, StubbedInvocationMatcher value) {
	handler.invocationContainerImpl = mock(InvocationContainerImpl.class);
	given(handler.invocationContainerImpl.findAnswerFor(any(InvocationImpl.class))).willReturn(value);
}
 
@After
public void printLogs() {
    ((InvocationContainerImpl) getMockHandler(log).getInvocationContainer()).getInvocations().forEach(System.out::println);
}
 
 类所在包
 类方法
 同包方法