protected IStorageHelper setUpStorageHelper( storage_domains dom, StorageType storageType, boolean connect, boolean failure) { StorageHelperDirector director = mock(StorageHelperDirector.class); when(StorageHelperDirector.getInstance()).thenReturn(director); IStorageHelper helper = mock(IStorageHelper.class); if (connect) { when(helper.ConnectStorageToDomainByVdsId(dom, VDS_ID)).thenReturn(true); when(helper.DisconnectStorageFromDomainByVdsId(dom, VDS_ID)).thenReturn(true); } if (!failure) { when(helper.StorageDomainRemoved(dom.getStorageStaticData())).thenReturn(true); } when(director.getItem(storageType)).thenReturn(helper); return helper; }