Java 类org.mockito.internal.stubbing.InvocationContainer 实例源码

项目:astor    文件:MockitoCore.java   
public void verifyNoMoreInteractions(Object... mocks) {
    assertMocksNotEmpty(mocks);
    mockingProgress.validateState();
    for (Object mock : mocks) {
        try {
            if (mock == null) {
                reporter.nullPassedToVerifyNoMoreInteractions();
            }
            InvocationContainer invocations = mockUtil.getMockHandler(mock).getInvocationContainer();
            VerificationDataImpl data = new VerificationDataImpl(invocations, null);
            VerificationModeFactory.noMoreInteractions().verify(data);
        } catch (NotAMockException e) {
            reporter.notAMockPassedToVerifyNoMoreInteractions();
        }
    }
}
项目:astor    文件:MockitoCore.java   
public void verifyNoMoreInteractions(Object... mocks) {
    assertMocksNotEmpty(mocks);
    mockingProgress.validateState();
    for (Object mock : mocks) {
        try {
            if (mock == null) {
                reporter.nullPassedToVerifyNoMoreInteractions();
            }
            InvocationContainer invocations = mockUtil.getMockHandler(mock).getInvocationContainer();
            VerificationDataImpl data = new VerificationDataImpl(invocations, null);
            VerificationModeFactory.noMoreInteractions().verify(data);
        } catch (NotAMockException e) {
            reporter.notAMockPassedToVerifyNoMoreInteractions();
        }
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MockitoAopProxyTargetInterceptor.java   
Verification(Object target) {
    MockUtil mockUtil = new MockUtil();
    InternalMockHandler<?> handler = mockUtil.getMockHandler(target);
    InvocationContainer container = handler.getInvocationContainer();
    Field field = ReflectionUtils.findField(container.getClass(),
            "mockingProgress");
    ReflectionUtils.makeAccessible(field);
    this.progress = (MockingProgress) ReflectionUtils.getField(field, container);
}
项目:spring-boot-concourse    文件:MockitoAopProxyTargetInterceptor.java   
Verification(Object target) {
    MockUtil mockUtil = new MockUtil();
    InternalMockHandler<?> handler = mockUtil.getMockHandler(target);
    InvocationContainer container = handler.getInvocationContainer();
    Field field = ReflectionUtils.findField(container.getClass(),
            "mockingProgress");
    ReflectionUtils.makeAccessible(field);
    this.progress = (MockingProgress) ReflectionUtils.getField(field, container);
}
项目:astor    文件:MockitoCore.java   
public Object[] ignoreStubs(Object... mocks) {
    for (Object m : mocks) {
        InvocationContainer invocationContainer = new MockUtil().getMockHandler(m).getInvocationContainer();
        List<Invocation> ins = invocationContainer.getInvocations();
        for (Invocation in : ins) {
            if (in.stubInfo() != null) {
                in.ignoreForVerification();
            }
        }
    }
    return mocks;
}
项目:powermock    文件:PowerMockMaker.java   
public InvocationContainer getInvocationContainer() {
    return null;
}
项目:astor    文件:MockHandler.java   
public InvocationContainer getInvocationContainer() {
    return invocationContainerImpl;
}
项目:astor    文件:VerificationDataImpl.java   
public VerificationDataImpl(InvocationContainer invocations, InvocationMatcher wanted) {
    this.invocations = invocations;
    this.wanted = wanted;
    this.assertWantedIsVerifiable();
}
项目:astor    文件:NoMoreInteractionsExcludingStubsTest.java   
/**
 * Ignores stubbed methods of given mocks for the sake of verification.
 * <p>
 * Other words: all *stubbed* methods of given mocks are made *verfied* so that they don't get in a way during verifyNoMoreInteractions().
 * <p>
 * This method changes the input mocks! This method returns input mocks for convenience. 
 * <p>
 * Example:
 * <pre>
 *  //mocking lists for the sake of the example (if you mock List in real you will burn in hell)
 *  List mock1 = mock(List.class), mock2 = mock(List.class);
 * 
 *  //stubbing mocks:
 *  when(mock1.get(0)).thenReturn(10);
 *  when(mock2.get(0)).thenReturn(20);
 *
 *  //using mocks by calling stubbed get(0) methods:
 *  System.out.println(mock1.get(0)); //prints 10
 *  System.out.println(mock2.get(0)); //prints 20
 *
 *  //using mocks by calling clear() methods:
 *  mock1.clear();
 *  mock2.clear();
 *
 *  //verification:
 *  verify(mock1).clear();
 *  verify(mock2).clear();
 *
 *  //verifyNoMoreInteractions() fails because get() methods were not accounted for.
 *  try { verifyNoMoreInteractions(mock1, mock2); } catch (NoInteractionsWanted e);
 *
 *  //However, if ignore stubbed methods then we can verifyNoMoreInteractions() 
 *  verifyNoMoreInteractions(ignoreStubs(mock1, mock2));
 *
 *  //Remember that ignoreStubs() *changes* the input mocks and returns them for convenience.
 * <pre>
 *
 * @param mocks input mocks that will be changed
 * @return the same mocks that were passed in as parameters
 */
public static Object[] ignoreStubs(Object... mocks) {
    for (Object m : mocks) {
        InvocationContainer invocationContainer = new MockUtil().getMockHandler(m).getInvocationContainer();
        List<Invocation> ins = invocationContainer.getInvocations();
        for (Invocation in : ins) {
            InvocationMarker invocationMarker = new InvocationMarker();
            if (in.stubInfo() != null) {
                invocationMarker.markVerified(in, new CapturesArgumensFromInvocation() {
                    public void captureArgumentsFrom(Invocation i) {
                        //don't capture
                    }
                });
            }
        }
    }
    return mocks;
}
项目:astor    文件:InvocationNotifierHandler.java   
public InvocationContainer getInvocationContainer() {
    return mockHandler.getInvocationContainer();
}
项目:astor    文件:NullResultGuardian.java   
public InvocationContainer getInvocationContainer() {
    return delegate.getInvocationContainer();
}
项目:astor    文件:VerificationDataImpl.java   
public VerificationDataImpl(InvocationContainer invocations, InvocationMatcher wanted) {
    this.invocations = invocations;
    this.wanted = wanted;
    this.assertWantedIsVerifiable();
}
项目:astor    文件:MockHandlerInterface.java   
InvocationContainer getInvocationContainer();
项目:astor    文件:InternalMockHandler.java   
InvocationContainer getInvocationContainer();