Search in sources :

Example 11 with InOrder

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();
}
Also used : InOrder(org.mockito.InOrder) SuppressLoggerChecks(org.elasticsearch.common.SuppressLoggerChecks)

Example 12 with InOrder

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();
}
Also used : InOrder(org.mockito.InOrder)

Example 13 with InOrder

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);
}
Also used : ClientMfiInfoUpdateBuilder(org.mifos.domain.builders.ClientMfiInfoUpdateBuilder) InOrder(org.mockito.InOrder) UserContext(org.mifos.security.util.UserContext) ClientMfiInfoUpdate(org.mifos.dto.domain.ClientMfiInfoUpdate) Test(org.junit.Test)

Example 14 with InOrder

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();
}
Also used : InOrder(org.mockito.InOrder) Test(org.junit.Test)

Example 15 with InOrder

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) {
    }
}
Also used : InOrder(org.mockito.InOrder) VerificationInOrderFailure(org.mockito.exceptions.verification.VerificationInOrderFailure) Test(org.junit.Test)

Aggregations

InOrder (org.mockito.InOrder)3292 Test (org.junit.Test)2308 Test (org.junit.jupiter.api.Test)377 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)108 HashMap (java.util.HashMap)104 ArrayList (java.util.ArrayList)98 Response (com.jayway.restassured.response.Response)79 Matchers.containsString (org.hamcrest.Matchers.containsString)69 IOException (java.io.IOException)64 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)63 SmallTest (org.mule.tck.size.SmallTest)62 List (java.util.List)57 CompletableFuture (java.util.concurrent.CompletableFuture)52 Cleanup (lombok.Cleanup)46 InvocationOnMock (org.mockito.invocation.InvocationOnMock)46 WireCommands (io.pravega.shared.protocol.netty.WireCommands)45 ProcessorInterceptor (org.mule.runtime.api.interception.ProcessorInterceptor)44 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)44 Metadata (io.grpc.Metadata)43 ComponentLocation (org.mule.runtime.api.component.location.ComponentLocation)41