use of org.mockito.internal.handler.MockHandlerImpl 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.internal.handler.MockHandlerImpl in project mockito by mockito.
the class InlineByteBuddyMockMakerTest method should_throw_exception_redefining_array.
@Test
@SuppressWarnings("unchecked")
public void should_throw_exception_redefining_array() {
int[] array = new int[5];
MockCreationSettings<? extends int[]> settings = settingsFor(array.getClass());
try {
mockMaker.createMock(settings, new MockHandlerImpl(settings));
fail("Expected a MockitoException");
} catch (MockitoException e) {
assertThat(e).hasMessageContaining("Arrays cannot be mocked");
}
}
use of org.mockito.internal.handler.MockHandlerImpl in project mockito by mockito.
the class InlineByteBuddyMockMakerTest method should_throw_exception_redefining_unmodifiable_class.
@Test
@SuppressWarnings("unchecked")
public void should_throw_exception_redefining_unmodifiable_class() {
MockCreationSettings settings = settingsFor(int.class);
try {
mockMaker.createMock(settings, new MockHandlerImpl(settings));
fail("Expected a MockitoException");
} catch (MockitoException e) {
e.printStackTrace();
assertThat(e).hasMessageContaining("Could not modify all classes");
}
}
use of org.mockito.internal.handler.MockHandlerImpl 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.internal.handler.MockHandlerImpl in project mockito by mockito.
the class InlineDelegateByteBuddyMockMakerTest method should_throw_exception_redefining_unmodifiable_class.
@Test
@SuppressWarnings("unchecked")
public void should_throw_exception_redefining_unmodifiable_class() {
MockCreationSettings settings = settingsFor(int.class);
try {
mockMaker.createMock(settings, new MockHandlerImpl(settings));
fail("Expected a MockitoException");
} catch (MockitoException e) {
e.printStackTrace();
assertThat(e).hasMessageContaining("Could not modify all classes");
}
}
Aggregations