use of org.mockito.internal.stubbing.answers.Returns in project mockito by mockito.
the class ReporterTest method can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_dont_exists.
@Test(expected = MockitoException.class)
public void can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_delegate_method_dont_exists() throws Exception {
Invocation dumb_invocation = new InvocationBuilder().toInvocation();
IMethods mock_with_bogus_default_answer = mock(IMethods.class, new Returns(false));
throw Reporter.delegatedMethodDoesNotExistOnDelegate(dumb_invocation.getMethod(), mock_with_bogus_default_answer, String.class);
}
use of org.mockito.internal.stubbing.answers.Returns in project mockito by mockito.
the class InlineByteBuddyMockMakerTest method settingsFor.
private 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.stubbing.answers.Returns in project mockito by mockito.
the class InvocationContainerImplStubbingTest method should_get_results_for_methods_stub_only.
@Test
public void should_get_results_for_methods_stub_only() throws Throwable {
invocationContainerImplStubOnly.setInvocationForPotentialStubbing(new InvocationMatcher(simpleMethod));
invocationContainerImplStubOnly.addAnswer(new Returns("simpleMethod"));
Invocation differentMethod = new InvocationBuilder().differentMethod().toInvocation();
invocationContainerImplStubOnly.setInvocationForPotentialStubbing(new InvocationMatcher(differentMethod));
invocationContainerImplStubOnly.addAnswer(new ThrowsException(new MyException()));
assertEquals("simpleMethod", invocationContainerImplStubOnly.answerTo(simpleMethod));
try {
invocationContainerImplStubOnly.answerTo(differentMethod);
fail();
} catch (MyException e) {
}
}
use of org.mockito.internal.stubbing.answers.Returns in project mockito by mockito.
the class InvocationContainerImplStubbingTest method should_finish_stubbing_on_adding_return_value.
@Test
public void should_finish_stubbing_on_adding_return_value() throws Exception {
state.stubbingStarted();
invocationContainerImpl.addAnswer(new Returns("test"));
state.validateState();
}
use of org.mockito.internal.stubbing.answers.Returns in project mockito by mockito.
the class InvocationContainerImplStubbingTest method should_get_results_for_methods.
@Test
public void should_get_results_for_methods() throws Throwable {
invocationContainerImpl.setInvocationForPotentialStubbing(new InvocationMatcher(simpleMethod));
invocationContainerImpl.addAnswer(new Returns("simpleMethod"));
Invocation differentMethod = new InvocationBuilder().differentMethod().toInvocation();
invocationContainerImpl.setInvocationForPotentialStubbing(new InvocationMatcher(differentMethod));
invocationContainerImpl.addAnswer(new ThrowsException(new MyException()));
assertEquals("simpleMethod", invocationContainerImpl.answerTo(simpleMethod));
try {
invocationContainerImpl.answerTo(differentMethod);
fail();
} catch (MyException e) {
}
}
Aggregations