Search in sources :

Example 31 with VerificationMode

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

the class StorageSystemDataMotionStrategyTest method validateAddSourcePoolToPoolsMapMapDoesNotContainsKey.

@Test
public void validateAddSourcePoolToPoolsMapMapDoesNotContainsKey() {
    List<StoragePoolType> storagePoolTypes = new LinkedList<>(Arrays.asList(StoragePoolType.values()));
    Mockito.doReturn(false).when(destinationStoragePoolVoMock).isManaged();
    Mockito.doReturn(StoragePoolType.NetworkFilesystem).when(destinationStoragePoolVoMock).getPoolType();
    Mockito.doReturn("").when(sourceStoragePoolVoMock).getUuid();
    Mockito.doReturn(false).when(mapStringStoragePoolTypeMock).containsKey(Mockito.anyString());
    Mockito.doReturn(null).when(mapStringStoragePoolTypeMock).put(Mockito.anyString(), Mockito.any());
    storagePoolTypes.forEach(poolType -> {
        Mockito.doReturn(poolType).when(sourceStoragePoolVoMock).getPoolType();
        strategy.addSourcePoolToPoolsMap(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
    });
    VerificationMode times = Mockito.times(storagePoolTypes.size());
    Mockito.verify(destinationStoragePoolVoMock, never()).getScope();
    Mockito.verify(destinationStoragePoolVoMock, times).isManaged();
    Mockito.verify(destinationStoragePoolVoMock, times).getPoolType();
    Mockito.verify(sourceStoragePoolVoMock, times).getUuid();
    Mockito.verify(mapStringStoragePoolTypeMock, times).containsKey(Mockito.anyString());
    Mockito.verify(sourceStoragePoolVoMock, times).getPoolType();
    Mockito.verify(mapStringStoragePoolTypeMock, times).put(Mockito.anyString(), Mockito.any());
    Mockito.verifyNoMoreInteractions(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) LinkedList(java.util.LinkedList) VerificationMode(org.mockito.verification.VerificationMode) 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