use of com.android.dx.mockito.inline.extended.StaticInOrder in project dexmaker by linkedin.
the class MockInstanceUsingExtendedMockito method verifyInOrder.
@Test
public void verifyInOrder() throws Exception {
TestClass t = mock(TestClass.class);
assertNull(t.echo("mocked"));
when(t.echo(eq("stubbed"))).thenReturn("B");
assertEquals("B", t.echo("stubbed"));
StaticInOrder inOrder = ExtendedMockito.inOrder(t);
inOrder.verify(t).echo("mocked");
inOrder.verify(t).echo("stubbed");
}
use of com.android.dx.mockito.inline.extended.StaticInOrder in project dexmaker by linkedin.
the class VerifyStatic method verifyBadOrder.
@Test(expected = VerificationInOrderFailure.class)
public void verifyBadOrder() throws Exception {
MockitoSession session = mockitoSession().mockStatic(EchoClass.class).startMocking();
try {
EchoClass.echo("marco!");
EchoClass.echo("polo");
StaticInOrder echoInOrder = inOrder(staticMockMarker(EchoClass.class));
echoInOrder.verify(() -> EchoClass.echo(eq("polo")));
echoInOrder.verify(() -> EchoClass.echo(eq("marco!")));
} finally {
session.finishMocking();
}
}
use of com.android.dx.mockito.inline.extended.StaticInOrder in project dexmaker by linkedin.
the class VerifyStatic method verifyBadMatcher.
@Test
public void verifyBadMatcher() throws Exception {
MockitoSession session = mockitoSession().mockStatic(EchoClass.class).startMocking();
try {
EchoClass.echo("marco!");
EchoClass.echo("polo");
StaticInOrder echoInOrder = inOrder(staticMockMarker(EchoClass.class));
echoInOrder.verify(() -> EchoClass.echo(eq("marco!")));
try {
echoInOrder.verify(() -> EchoClass.echo(eq("badMarker")));
fail();
} catch (VerificationInOrderFailure e) {
assertTrue(e.getMessage(), e.getMessage().contains("badMarker"));
}
} finally {
session.finishMocking();
}
}
use of com.android.dx.mockito.inline.extended.StaticInOrder in project dexmaker by linkedin.
the class VerifyStatic method verifyInOrder.
@Test
public void verifyInOrder() throws Exception {
MockitoSession session = mockitoSession().mockStatic(EchoClass.class).mockStatic(ConsumeClass.class).startMocking();
try {
EchoClass.echo("marco!");
ConsumeClass.consume("donuts");
ConsumeClass.consume("nougat");
EchoClass.echo("polo");
StaticInOrder echoInOrder = inOrder(staticMockMarker(EchoClass.class));
echoInOrder.verify(() -> EchoClass.echo(eq("marco!")));
echoInOrder.verify(() -> EchoClass.echo(eq("polo")));
echoInOrder.verifyNoMoreInteractions();
StaticInOrder consumeInOrder = inOrder(staticMockMarker(ConsumeClass.class));
consumeInOrder.verify(() -> ConsumeClass.consume(eq("donuts")));
consumeInOrder.verify(() -> ConsumeClass.consume(eq("nougat")));
consumeInOrder.verifyNoMoreInteractions();
StaticInOrder combinedInOrder = inOrder(staticMockMarker(EchoClass.class, ConsumeClass.class));
combinedInOrder.verify(() -> EchoClass.echo(eq("marco!")));
combinedInOrder.verify(() -> ConsumeClass.consume(eq("donuts")));
combinedInOrder.verify(() -> ConsumeClass.consume(eq("nougat")));
combinedInOrder.verify(() -> EchoClass.echo(eq("polo")));
combinedInOrder.verifyNoMoreInteractions();
} finally {
session.finishMocking();
}
}
Aggregations