use of org.mockito.verification.VerificationMode in project cdap-ingest by caskdata.
the class RestClientTest method testNotAllowedResponseCodeAnalysis.
@Test
public void testNotAllowedResponseCodeAnalysis() {
StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), HttpStatus.SC_METHOD_NOT_ALLOWED, "Method Not Allowed");
when(response.getStatusLine()).thenReturn(statusLine);
TestUtils.verifyResponse(HttpStatus.SC_METHOD_NOT_ALLOWED, response);
verify(response, new VerificationMode() {
@Override
public void verify(VerificationData verificationData) {
Assert.assertEquals(2, verificationData.getAllInvocations().size());
}
}).getStatusLine();
}
use of org.mockito.verification.VerificationMode in project cloudstack by apache.
the class StorageSystemDataMotionStrategyTest method validateAddSourcePoolToPoolsMapDestinationPoolIsNotNFS.
@Test
public void validateAddSourcePoolToPoolsMapDestinationPoolIsNotNFS() {
List<StoragePoolType> storagePoolTypes = new LinkedList<>(Arrays.asList(StoragePoolType.values()));
storagePoolTypes.remove(StoragePoolType.NetworkFilesystem);
Mockito.doReturn(false).when(destinationStoragePoolVoMock).isManaged();
storagePoolTypes.forEach(poolType -> {
Mockito.doReturn(poolType).when(destinationStoragePoolVoMock).getPoolType();
strategy.addSourcePoolToPoolsMap(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
});
VerificationMode times = Mockito.times(storagePoolTypes.size());
Mockito.verify(destinationStoragePoolVoMock, times).isManaged();
Mockito.verify(destinationStoragePoolVoMock, times).getPoolType();
Mockito.verifyNoMoreInteractions(mapStringStoragePoolTypeMock, sourceStoragePoolVoMock, destinationStoragePoolVoMock);
}
use of org.mockito.verification.VerificationMode in project cloudstack by apache.
the class SnapshotManagerTest method validatePersistSnapshotPolicyLockAquiredUpdateSnapshotPolicy.
@Test
public void validatePersistSnapshotPolicyLockAquiredUpdateSnapshotPolicy() {
PowerMockito.mockStatic(GlobalLock.class);
BDDMockito.given(GlobalLock.getInternLock(Mockito.anyString())).willReturn(globalLockMock);
Mockito.doReturn(true).when(globalLockMock).lock(Mockito.anyInt());
for (IntervalType intervalType : listIntervalTypes) {
Mockito.doReturn(snapshotPolicyVoInstance).when(snapshotPolicyDaoMock).findOneByVolumeInterval(Mockito.anyLong(), Mockito.eq(intervalType));
Mockito.doNothing().when(_snapshotMgr).updateSnapshotPolicy(Mockito.any(SnapshotPolicyVO.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(DateUtil.IntervalType.class), Mockito.anyInt(), Mockito.anyBoolean(), Mockito.anyBoolean());
Mockito.doNothing().when(_snapshotMgr).createTagsForSnapshotPolicy(mapStringStringMock, snapshotPolicyVoMock);
SnapshotPolicyVO result = _snapshotMgr.persistSnapshotPolicy(volumeMock, TEST_SNAPSHOT_POLICY_SCHEDULE, TEST_SNAPSHOT_POLICY_TIMEZONE, intervalType, TEST_SNAPSHOT_POLICY_MAX_SNAPS, TEST_SNAPSHOT_POLICY_DISPLAY, TEST_SNAPSHOT_POLICY_ACTIVE, null);
assertSnapshotPolicyResultAgainstPreBuiltInstance(result);
}
VerificationMode timesVerification = Mockito.times(listIntervalTypes.size());
Mockito.verify(_snapshotMgr, Mockito.never()).createSnapshotPolicy(Mockito.anyLong(), Mockito.anyString(), Mockito.anyString(), Mockito.any(DateUtil.IntervalType.class), Mockito.anyInt(), Mockito.anyBoolean());
Mockito.verify(_snapshotMgr, timesVerification).updateSnapshotPolicy(Mockito.any(SnapshotPolicyVO.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(DateUtil.IntervalType.class), Mockito.anyInt(), Mockito.anyBoolean(), Mockito.anyBoolean());
Mockito.verify(_snapshotMgr, timesVerification).createTagsForSnapshotPolicy(Mockito.any(), Mockito.any());
}
use of org.mockito.verification.VerificationMode in project cloudstack by apache.
the class SnapshotManagerTest method validatePersistSnapshotPolicyLockAquiredCreateSnapshotPolicy.
@Test
public void validatePersistSnapshotPolicyLockAquiredCreateSnapshotPolicy() {
PowerMockito.mockStatic(GlobalLock.class);
BDDMockito.given(GlobalLock.getInternLock(Mockito.anyString())).willReturn(globalLockMock);
Mockito.doReturn(true).when(globalLockMock).lock(Mockito.anyInt());
for (IntervalType intervalType : listIntervalTypes) {
Mockito.doReturn(null).when(snapshotPolicyDaoMock).findOneByVolumeInterval(Mockito.anyLong(), Mockito.eq(intervalType));
Mockito.doReturn(snapshotPolicyVoInstance).when(_snapshotMgr).createSnapshotPolicy(Mockito.anyLong(), Mockito.anyString(), Mockito.anyString(), Mockito.eq(intervalType), Mockito.anyInt(), Mockito.anyBoolean());
Mockito.doNothing().when(_snapshotMgr).createTagsForSnapshotPolicy(mapStringStringMock, snapshotPolicyVoMock);
SnapshotPolicyVO result = _snapshotMgr.persistSnapshotPolicy(volumeMock, TEST_SNAPSHOT_POLICY_SCHEDULE, TEST_SNAPSHOT_POLICY_TIMEZONE, intervalType, TEST_SNAPSHOT_POLICY_MAX_SNAPS, TEST_SNAPSHOT_POLICY_DISPLAY, TEST_SNAPSHOT_POLICY_ACTIVE, null);
assertSnapshotPolicyResultAgainstPreBuiltInstance(result);
}
VerificationMode timesVerification = Mockito.times(listIntervalTypes.size());
Mockito.verify(_snapshotMgr, timesVerification).createSnapshotPolicy(Mockito.anyLong(), Mockito.anyString(), Mockito.anyString(), Mockito.any(DateUtil.IntervalType.class), Mockito.anyInt(), Mockito.anyBoolean());
Mockito.verify(_snapshotMgr, Mockito.never()).updateSnapshotPolicy(Mockito.any(SnapshotPolicyVO.class), Mockito.anyString(), Mockito.anyString(), Mockito.any(DateUtil.IntervalType.class), Mockito.anyInt(), Mockito.anyBoolean(), Mockito.anyBoolean());
Mockito.verify(_snapshotMgr, timesVerification).createTagsForSnapshotPolicy(Mockito.any(), Mockito.any());
}
use of org.mockito.verification.VerificationMode in project kie-wb-common by kiegroup.
the class FormEditorPresenterTest method testOnRemoveComponent.
public void testOnRemoveComponent(boolean noContext) {
loadContent();
loadAvailableFields();
addAllFields();
VerificationMode count = times(1);
if (noContext) {
when(editorHelper.getContent()).thenReturn(null);
count = never();
}
FormEditorPresenter presenterSpy = spy(presenter);
String formId = presenterSpy.getFormDefinition().getId();
FieldDefinition field = editorHelper.getFormDefinition().getFields().get(0);
ComponentRemovedEvent event = new ComponentRemovedEvent(createLayoutComponent(presenter.getFormDefinition(), field), false);
presenterSpy.onRemoveComponent(event);
verify(presenterSpy, count).onSyncPalette(formId);
verify(editorHelper, count).removeField(Mockito.<String>any(), Mockito.anyBoolean());
}
Aggregations