use of com.cloud.storage.StorageManagerImpl in project cloudstack by apache.
the class CloudStackPrimaryDataStoreLifeCycleImplTest method initMocks.
@Before
public void initMocks() {
MockitoAnnotations.initMocks(this);
List<HostVO> hostList = new ArrayList<HostVO>();
HostVO host1 = new HostVO(1L, "aa01", Host.Type.Routing, "192.168.1.1", "255.255.255.0", null, null, null, null, null, null, null, null, null, null, UUID.randomUUID().toString(), Status.Up, "1.0", null, null, 1L, null, 0, 0, "aa", 0, Storage.StoragePoolType.NetworkFilesystem);
HostVO host2 = new HostVO(1L, "aa02", Host.Type.Routing, "192.168.1.1", "255.255.255.0", null, null, null, null, null, null, null, null, null, null, UUID.randomUUID().toString(), Status.Up, "1.0", null, null, 1L, null, 0, 0, "aa", 0, Storage.StoragePoolType.NetworkFilesystem);
host1.setResourceState(ResourceState.Enabled);
host2.setResourceState(ResourceState.Disabled);
hostList.add(host1);
hostList.add(host2);
when(_dataStoreMgr.getDataStore(anyLong(), eq(DataStoreRole.Primary))).thenReturn(store);
when(store.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem);
when(store.isShared()).thenReturn(true);
when(store.getName()).thenReturn("newPool");
when(_dataStoreProviderMgr.getDataStoreProvider(anyString())).thenReturn(dataStoreProvider);
when(dataStoreProvider.getName()).thenReturn("default");
((StorageManagerImpl) storageMgr).registerHostListener("default", hostListener);
when(_resourceMgr.listAllUpHosts(eq(Host.Type.Routing), anyLong(), anyLong(), anyLong())).thenReturn(hostList);
when(agentMgr.easySend(anyLong(), Mockito.any(ModifyStoragePoolCommand.class))).thenReturn(answer);
when(answer.getResult()).thenReturn(true);
when(answer.getPoolInfo()).thenReturn(info);
when(info.getLocalPath()).thenReturn("/mnt/1");
when(info.getCapacityBytes()).thenReturn(0L);
when(info.getAvailableBytes()).thenReturn(0L);
when(storagePoolHostDao.findByPoolHost(anyLong(), anyLong())).thenReturn(null);
when(primaryStoreDao.findById(anyLong())).thenReturn(storagePool);
when(primaryStoreDao.update(anyLong(), Mockito.any(StoragePoolVO.class))).thenReturn(true);
when(primaryDataStoreHelper.attachCluster(Mockito.any(DataStore.class))).thenReturn(null);
}
Aggregations