use of org.mockito.InOrder in project elasticsearch by elastic.
the class AbstractLifecycleRunnableTests method testDoRunDoesNotRunWhenStoppedOrClosed.
@SuppressLoggerChecks(reason = "mock usage")
public void testDoRunDoesNotRunWhenStoppedOrClosed() throws Exception {
Callable<?> runCallable = mock(Callable.class);
// it's stopped or closed
when(lifecycle.stoppedOrClosed()).thenReturn(true);
AbstractLifecycleRunnable runnable = new AbstractLifecycleRunnable(lifecycle, logger) {
@Override
public void onFailure(Exception e) {
fail("It should not fail");
}
@Override
protected void doRunInLifecycle() throws Exception {
fail("Should not run with lifecycle stopped or closed.");
}
};
runnable.run();
InOrder inOrder = inOrder(lifecycle, logger, runCallable);
inOrder.verify(lifecycle).stoppedOrClosed();
inOrder.verify(logger).trace(anyString());
// onAfter uses it too, but we're not testing it here
inOrder.verify(lifecycle).stoppedOrClosed();
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project elasticsearch by elastic.
the class AbstractRunnableTests method testOnAfterSuccess.
public void testOnAfterSuccess() throws Exception {
Callable<?> runCallable = mock(Callable.class);
Callable<?> afterCallable = mock(Callable.class);
AbstractRunnable runnable = new AbstractRunnable() {
@Override
public void onFailure(Exception e) {
fail(e.toString());
}
@Override
protected void doRun() throws Exception {
runCallable.call();
}
@Override
public void onAfter() {
try {
afterCallable.call();
} catch (Exception e) {
fail(e.toString());
}
}
};
runnable.run();
InOrder inOrder = inOrder(runCallable, afterCallable);
inOrder.verify(runCallable).call();
inOrder.verify(afterCallable).call();
}
use of org.mockito.InOrder in project head by mifos.
the class ClientUpdateTest method userContextAndUpdateDetailsAreSetBeforeBeginningAuditLogging.
@Test
public void userContextAndUpdateDetailsAreSetBeforeBeginningAuditLogging() throws Exception {
// setup
UserContext userContext = TestUtils.makeUser();
ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdateBuilder().build();
// stubbing
when(customerDao.findCustomerById(clientMfiInfoUpdate.getClientId())).thenReturn(mockedClient);
// exercise test
customerService.updateClientMfiInfo(userContext, clientMfiInfoUpdate);
// verification
InOrder inOrder = inOrder(hibernateTransactionHelper, mockedClient);
inOrder.verify(mockedClient).updateDetails(userContext);
inOrder.verify(hibernateTransactionHelper).beginAuditLoggingFor(mockedClient);
}
use of org.mockito.InOrder in project mockito by mockito.
the class FindingRedundantInvocationsInOrderTest method shouldWorkFineIfNoInvocatins.
@Test
public void shouldWorkFineIfNoInvocatins() throws Exception {
//when
InOrder inOrder = inOrder(mock);
//then
inOrder.verifyNoMoreInteractions();
}
use of org.mockito.InOrder in project mockito by mockito.
the class SelectedMocksInOrderVerificationTest method shouldThrowTooLittleInvocationsForMockTwo.
@Test
public void shouldThrowTooLittleInvocationsForMockTwo() {
InOrder inOrder = inOrder(mockTwo);
try {
inOrder.verify(mockTwo, times(4)).simpleMethod(2);
fail();
} catch (VerificationInOrderFailure e) {
}
}
Aggregations