use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationTest method should_verify_call_order_for_serialized_mock.
@Test
public void should_verify_call_order_for_serialized_mock() throws Exception {
IMethods mock = mock(IMethods.class, withSettings().serializable());
IMethods mock2 = mock(IMethods.class, withSettings().serializable());
mock.arrayReturningMethod();
mock2.arrayReturningMethod();
// when
ByteArrayOutputStream serialized = serializeMock(mock);
ByteArrayOutputStream serialized2 = serializeMock(mock2);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
IMethods readObject2 = deserializeMock(serialized2, IMethods.class);
InOrder inOrder = inOrder(readObject, readObject2);
inOrder.verify(readObject).arrayReturningMethod();
inOrder.verify(readObject2).arrayReturningMethod();
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationTest method should_stub_even_if_some_methods_called_after_serialization.
@Test
public void should_stub_even_if_some_methods_called_after_serialization() throws Exception {
//given
IMethods mock = mock(IMethods.class, withSettings().serializable());
// when
when(mock.simpleMethod(1)).thenReturn("foo");
ByteArrayOutputStream serialized = serializeMock(mock);
IMethods readObject = deserializeMock(serialized, IMethods.class);
when(readObject.simpleMethod(2)).thenReturn("bar");
// then
assertEquals("foo", readObject.simpleMethod(1));
assertEquals("bar", readObject.simpleMethod(2));
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationTest method should_all_mock_and_serializable_value_to_be_serialized.
@Test
public void should_all_mock_and_serializable_value_to_be_serialized() throws Exception {
// given
IMethods mock = mock(IMethods.class, withSettings().serializable());
List<?> value = Collections.emptyList();
when(mock.objectReturningMethodNoArgs()).thenReturn(value);
// when
ByteArrayOutputStream serialized = serializeMock(mock);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
assertEquals(value, readObject.objectReturningMethodNoArgs());
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class ResetTest method shouldRemoveStubbingToString.
@Test
public void shouldRemoveStubbingToString() throws Exception {
IMethods mockTwo = mock(IMethods.class);
when(mockTwo.toString()).thenReturn("test");
reset(mockTwo);
assertThat(mockTwo.toString()).contains("Mock for IMethods");
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class CompareMatcherTest method compareNullArgument.
/**
* Should not throw an {@link NullPointerException}
*
* @see Bug-ID https://github.com/mockito/mockito/issues/457
*/
@Test
public void compareNullArgument() {
final IMethods mock = mock(IMethods.class);
when(mock.forInteger(leq(5))).thenReturn("");
// a default value must be returned
assertThat(mock.forInteger(null)).isNull();
}
Aggregations