use of org.mockito.internal.creation.MockSettingsImpl in project mockito by mockito.
the class NoMoreInteractionsTest method noMoreInteractionsExceptionMessageShouldDescribeMock.
@Test
public void noMoreInteractionsExceptionMessageShouldDescribeMock() {
// given
NoMoreInteractions n = new NoMoreInteractions();
IMethods mock = mock(IMethods.class, "a mock");
InvocationMatcher i = new InvocationBuilder().mock(mock).toInvocationMatcher();
InvocationContainerImpl invocations = new InvocationContainerImpl(new MockSettingsImpl());
invocations.setInvocationForPotentialStubbing(i);
try {
// when
n.verify(new VerificationDataImpl(invocations, null));
// then
fail();
} catch (NoInteractionsWanted e) {
Assertions.assertThat(e.toString()).contains(mock.toString());
}
}
use of org.mockito.internal.creation.MockSettingsImpl in project mockito by mockito.
the class InlineDelegateByteBuddyMockMakerTest method should_mock_interface.
@Test
public void should_mock_interface() {
MockSettingsImpl<Set> mockSettings = new MockSettingsImpl<Set>();
mockSettings.setTypeToMock(Set.class);
mockSettings.defaultAnswer(new Returns(10));
Set<?> proxy = mockMaker.createMock(mockSettings, new MockHandlerImpl<Set>(mockSettings));
assertThat(proxy.size()).isEqualTo(10);
}
use of org.mockito.internal.creation.MockSettingsImpl in project mockito by mockito.
the class InlineDelegateByteBuddyMockMakerTest method settingsFor.
protected static <T> MockCreationSettings<T> settingsFor(Class<T> type, Class<?>... extraInterfaces) {
MockSettingsImpl<T> mockSettings = new MockSettingsImpl<T>();
mockSettings.setTypeToMock(type);
mockSettings.defaultAnswer(new Returns("bar"));
if (extraInterfaces.length > 0)
mockSettings.extraInterfaces(extraInterfaces);
return mockSettings;
}
use of org.mockito.internal.creation.MockSettingsImpl in project mockito by mockito.
the class InlineDelegateByteBuddyMockMakerTest method should_mock_interface_to_string.
@Test
public void should_mock_interface_to_string() {
MockSettingsImpl<Set> mockSettings = new MockSettingsImpl<Set>();
mockSettings.setTypeToMock(Set.class);
mockSettings.defaultAnswer(new Returns("foo"));
Set<?> proxy = mockMaker.createMock(mockSettings, new MockHandlerImpl<Set>(mockSettings));
assertThat(proxy.toString()).isEqualTo("foo");
}
use of org.mockito.internal.creation.MockSettingsImpl in project mockito by mockito.
the class InlineDelegateByteBuddyMockMakerTest method should_mock_class_to_string.
/**
* @see <a href="https://github.com/mockito/mockito/issues/2154">https://github.com/mockito/mockito/issues/2154</a>
*/
@Test
public void should_mock_class_to_string() {
MockSettingsImpl<Object> mockSettings = new MockSettingsImpl<Object>();
mockSettings.setTypeToMock(Object.class);
mockSettings.defaultAnswer(new Returns("foo"));
Object proxy = mockMaker.createMock(mockSettings, new MockHandlerImpl<Object>(mockSettings));
assertThat(proxy.toString()).isEqualTo("foo");
}
Aggregations