use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class ReturnsTest method should_allow_correct_type_of_return_value.
@Test
public void should_allow_correct_type_of_return_value() throws Throwable {
new Returns("one").validateFor(new InvocationBuilder().simpleMethod().toInvocation());
new Returns(false).validateFor(new InvocationBuilder().method("booleanReturningMethod").toInvocation());
new Returns(TRUE).validateFor(new InvocationBuilder().method("booleanObjectReturningMethod").toInvocation());
new Returns(1).validateFor(new InvocationBuilder().method("integerReturningMethod").toInvocation());
new Returns(1L).validateFor(new InvocationBuilder().method("longReturningMethod").toInvocation());
new Returns(1L).validateFor(new InvocationBuilder().method("longObjectReturningMethod").toInvocation());
new Returns(null).validateFor(new InvocationBuilder().method("objectReturningMethodNoArgs").toInvocation());
new Returns(1).validateFor(new InvocationBuilder().method("objectReturningMethodNoArgs").toInvocation());
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class ThrowsExceptionTest method should_pass_RuntimeExceptions.
@Test
public void should_pass_RuntimeExceptions() throws Throwable {
new ThrowsException(new Error()).validateFor(new InvocationBuilder().method("canThrowException").toInvocation());
new ThrowsException(new RuntimeException()).validateFor(new InvocationBuilder().method("canThrowException").toInvocation());
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class NoMoreInteractionsTest method noMoreInteractionsInOrderExceptionMessageShouldDescribeMock.
@Test
public void noMoreInteractionsInOrderExceptionMessageShouldDescribeMock() {
//given
NoMoreInteractions n = new NoMoreInteractions();
IMethods mock = mock(IMethods.class, "a mock");
Invocation i = new InvocationBuilder().mock(mock).toInvocation();
try {
//when
n.verifyInOrder(new VerificationDataInOrderImpl(context, asList(i), null));
//then
fail();
} catch (VerificationInOrderFailure e) {
Assertions.assertThat(e.toString()).contains(mock.toString());
}
}
use of org.mockito.internal.invocation.InvocationBuilder in project mockito by mockito.
the class NoMoreInteractionsTest method shouldVerifyInOrder.
@Test
public void shouldVerifyInOrder() {
//given
NoMoreInteractions n = new NoMoreInteractions();
Invocation i = new InvocationBuilder().toInvocation();
assertFalse(context.isVerified(i));
try {
//when
n.verifyInOrder(new VerificationDataInOrderImpl(context, asList(i), null));
//then
fail();
} catch (VerificationInOrderFailure e) {
}
}
use of org.mockito.internal.invocation.InvocationBuilder 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());
}
}
Aggregations