Search in sources :

Example 1 with VerificationMode

use of org.mockito.verification.VerificationMode in project powermock by powermock.

the class MockitoNewInvocationControl method verify.

@Override
public synchronized Object verify(Object... mocks) {
    final VerificationMode verificationMode;
    Object mode = MockRepository.getAdditionalState("VerificationMode");
    if (mode != null) {
        if (mode instanceof VerificationMode) {
            verificationMode = (VerificationMode) mode;
        } else {
            throw new IllegalStateException("Internal error. VerificationMode in MockRepository was not of type " + VerificationMode.class.getName() + ".");
        }
    } else {
        verificationMode = times(1);
    }
    Mockito.verify(substitute, verificationMode);
    return null;
}
Also used : VerificationMode(org.mockito.verification.VerificationMode)

Example 2 with VerificationMode

use of org.mockito.verification.VerificationMode in project mule by mulesoft.

the class OperationExecutorFactoryWrapperTestCase method assertOperation.

private void assertOperation(boolean java, boolean blocking) {
    from(wrapper.createExecutor(mockOperation(blocking), emptyMap()).execute(ctx)).block();
    verify(executor).execute(ctx);
    VerificationMode verificationMode = java && !blocking ? times(1) : never();
    verify(ctx, verificationMode).setVariable(eq(COMPLETION_CALLBACK_CONTEXT_PARAM), any());
}
Also used : VerificationMode(org.mockito.verification.VerificationMode)

Example 3 with VerificationMode

use of org.mockito.verification.VerificationMode in project ovirt-engine by oVirt.

the class InternalImportExternalNetworkCommandTest method verifyCalls.

private void verifyCalls(boolean attachToAllClusters) {
    verify(backend).runInternalAction(eq(ActionType.AddNetwork), any(), any());
    VerificationMode expectedNumberOfCalls = attachToAllClusters ? times(1) : never();
    verify(backend, expectedNumberOfCalls).runInternalQuery(eq(QueryType.GetClustersByStoragePoolId), any(), any());
    verify(networkHelper, expectedNumberOfCalls).createNetworkClusters(eq(Collections.singletonList(CLUSTER_ID)));
}
Also used : VerificationMode(org.mockito.verification.VerificationMode)

Example 4 with VerificationMode

use of org.mockito.verification.VerificationMode in project ovirt-engine by oVirt.

the class GlusterSyncJobTest method verifyMocksForHeavyWeight.

private void verifyMocksForHeavyWeight() {
    InOrder inOrder = inOrder(clusterDao, glusterUtil, volumeDao, glusterManager, brickDao);
    // all clusters fetched from db
    inOrder.verify(clusterDao, times(1)).getAll();
    VerificationMode mode = times(1);
    // get the UP server from cluster
    inOrder.verify(glusterUtil, mode).getRandomUpServer(CLUSTER_ID);
    // get volumes of the cluster
    inOrder.verify(volumeDao, mode).getByClusterId(CLUSTER_ID);
    // acquire lock on the cluster
    inOrder.verify(glusterManager, mode).acquireLock(CLUSTER_ID);
    // get volume advance details
    inOrder.verify(glusterManager, mode).getVolumeAdvancedDetails(existingServer1, CLUSTER_ID, existingDistVol.getName());
    // Update capacity info
    inOrder.verify(volumeDao, mode).updateVolumeCapacityInfo(getVolumeAdvancedDetails(existingDistVol).getCapacityInfo());
    // release lock on the cluster
    inOrder.verify(glusterManager, mode).releaseLock(CLUSTER_ID);
    // acquire lock on the cluster for repl volume
    inOrder.verify(glusterManager, mode).acquireLock(CLUSTER_ID);
    // get volume advance details of repl volume
    inOrder.verify(glusterManager, mode).getVolumeAdvancedDetails(existingServer1, CLUSTER_ID, existingReplVol.getName());
    // Add Capacity Info
    inOrder.verify(volumeDao, mode).addVolumeCapacityInfo(getVolumeAdvancedDetails(existingReplVol).getCapacityInfo());
    // Add Capacity Info
    inOrder.verify(brickDao, mode).addBrickProperties(anyList());
    // update brick status
    inOrder.verify(brickDao, mode).updateBrickStatuses(argThat(hasBricksWithChangedStatus()));
    // release lock on the cluster
    inOrder.verify(glusterManager, mode).releaseLock(CLUSTER_ID);
}
Also used : InOrder(org.mockito.InOrder) VerificationMode(org.mockito.verification.VerificationMode)

Example 5 with VerificationMode

use of org.mockito.verification.VerificationMode in project mockito by mockito.

the class VerificationWithAfterTest method should_return_formatted_output_from_toString_when_created_with_factory_method.

@Test
public void should_return_formatted_output_from_toString_when_created_with_factory_method() {
    VerificationMode after = after(3);
    assertThat(after).hasToString("Wanted after 3 ms: [Wanted invocations count: 1]");
}
Also used : VerificationMode(org.mockito.verification.VerificationMode) DummyVerificationMode(org.mockito.internal.verification.DummyVerificationMode) Test(org.junit.Test)

Aggregations

VerificationMode (org.mockito.verification.VerificationMode)31 Test (org.junit.Test)18 DummyVerificationMode (org.mockito.internal.verification.DummyVerificationMode)5 MockAwareVerificationMode (org.mockito.internal.verification.MockAwareVerificationMode)3 SnapshotPolicyVO (com.cloud.storage.SnapshotPolicyVO)2 StoragePoolType (com.cloud.storage.Storage.StoragePoolType)2 IntervalType (com.cloud.utils.DateUtil.IntervalType)2 Method (java.lang.reflect.Method)2 Collections.singletonMap (java.util.Collections.singletonMap)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 AcknowledgeCheckpoint (org.apache.flink.runtime.messages.checkpoint.AcknowledgeCheckpoint)2 DeclineCheckpoint (org.apache.flink.runtime.messages.checkpoint.DeclineCheckpoint)2 OperatorStreamStateHandle (org.apache.flink.runtime.state.OperatorStreamStateHandle)2 PlaceholderStreamStateHandle (org.apache.flink.runtime.state.PlaceholderStreamStateHandle)2 StateHandleID (org.apache.flink.runtime.state.StateHandleID)2 StreamStateHandle (org.apache.flink.runtime.state.StreamStateHandle)2 TestingStreamStateHandle (org.apache.flink.runtime.state.TestingStreamStateHandle)2 ByteStreamStateHandle (org.apache.flink.runtime.state.memory.ByteStreamStateHandle)2