use of org.mockito.invocation.MockHandler in project mockito by mockito.
the class AbstractByteBuddyMockMakerTest method should_reset_mock_and_set_new_handler.
@Test
public void should_reset_mock_and_set_new_handler() throws Throwable {
MockCreationSettings<SampleClass> settings = settingsWithSuperCall(SampleClass.class);
SampleClass proxy = mockMaker.createMock(settings, new MockHandlerImpl<SampleClass>(settings));
MockHandler handler = new MockHandlerImpl<SampleClass>(settings);
mockMaker.resetMock(proxy, handler, settings);
assertThat(mockMaker.getHandler(proxy)).isSameAs(handler);
}
use of org.mockito.invocation.MockHandler in project mockito by mockito.
the class MockUtil method resetMock.
public static <T> void resetMock(T mock) {
InternalMockHandler oldHandler = (InternalMockHandler) getMockHandler(mock);
MockCreationSettings settings = oldHandler.getMockSettings();
MockHandler newHandler = createMockHandler(settings);
mockMaker.resetMock(mock, newHandler, settings);
}
use of org.mockito.invocation.MockHandler in project powermock by powermock.
the class MockitoMethodInvocationControl method verifyNoMoreInteractions.
public void verifyNoMoreInteractions() {
try {
final MockHandler mockHandler = methodInterceptorFilter.getHandler();
if (mockHandler instanceof MockHandler) {
InvocationContainer invocationContainer = Whitebox.invokeMethod(mockHandler, "getInvocationContainer");
VerificationDataImpl data = new VerificationDataImpl(invocationContainer, null);
VerificationModeFactory.noMoreInteractions().verify(data);
} else {
throw new RuntimeException("Cannot perform verifyNoMoreInteractions because of unknown mockhandler type " + mockHandler.getClass());
}
} catch (MockitoAssertionError e) {
InvocationControlAssertionError.updateErrorMessageForVerifyNoMoreInteractions(e);
throw e;
} catch (Exception e) {
throw new RuntimeException("PowerMock internal error", e);
}
}
use of org.mockito.invocation.MockHandler in project mockito by mockito.
the class AbstractMockMakerTest method should_reset_mock_and_set_new_handler.
@Test
public void should_reset_mock_and_set_new_handler() throws Throwable {
MockCreationSettings<C> settings = settingsWithSuperCall(target);
C proxy = mockMaker.createMock(settings, new MockHandlerImpl<C>(settings));
MockHandler handler = new MockHandlerImpl<C>(settings);
mockMaker.resetMock(proxy, handler, settings);
assertThat(mockMaker.getHandler(proxy)).isSameAs(handler);
}
use of org.mockito.invocation.MockHandler in project mockito by mockito.
the class AbstractMockMakerTest method should_mocks_have_different_interceptors.
@Test
public void should_mocks_have_different_interceptors() throws Exception {
C mockOne = mockMaker.createMock(settingsFor(target), dummyHandler());
C mockTwo = mockMaker.createMock(settingsFor(target), dummyHandler());
MockHandler handlerOne = mockMaker.getHandler(mockOne);
MockHandler handlerTwo = mockMaker.getHandler(mockTwo);
assertThat(handlerOne).isNotSameAs(handlerTwo);
}
Aggregations