use of com.cloud.legacymodel.communication.command.GetStorageStatsCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testGetStorageStatsCommand.
@Test
public void testGetStorageStatsCommand() {
final DataStoreTO store = Mockito.mock(DataStoreTO.class);
final GetStorageStatsCommand command = new GetStorageStatsCommand(store);
final KvmStoragePoolManager storagePoolMgr = Mockito.mock(KvmStoragePoolManager.class);
final KvmStoragePool secondaryPool = Mockito.mock(KvmStoragePool.class);
when(this.libvirtComputingResource.getStoragePoolMgr()).thenReturn(storagePoolMgr);
when(storagePoolMgr.getStoragePool(command.getPooltype(), command.getStorageId(), true)).thenReturn(secondaryPool);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertTrue(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
verify(storagePoolMgr, times(1)).getStoragePool(command.getPooltype(), command.getStorageId(), true);
}
use of com.cloud.legacymodel.communication.command.GetStorageStatsCommand in project cosmic by MissionCriticalCloud.
the class LibvirtComputingResourceTest method testGetStorageStatsCommandException.
@Test
public void testGetStorageStatsCommandException() {
final DataStoreTO store = Mockito.mock(DataStoreTO.class);
final GetStorageStatsCommand command = new GetStorageStatsCommand(store);
when(this.libvirtComputingResource.getStoragePoolMgr()).thenThrow(CloudRuntimeException.class);
final LibvirtRequestWrapper wrapper = LibvirtRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, this.libvirtComputingResource);
assertFalse(answer.getResult());
verify(this.libvirtComputingResource, times(1)).getStoragePoolMgr();
}
use of com.cloud.legacymodel.communication.command.GetStorageStatsCommand in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testGetStorageStatsCommand.
@Test
public void testGetStorageStatsCommand() {
final XsHost xsHost = Mockito.mock(XsHost.class);
final DataStoreTO store = Mockito.mock(DataStoreTO.class);
final GetStorageStatsCommand storageStatsCommand = new GetStorageStatsCommand(store);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(this.citrixResourceBase.getHost()).thenReturn(xsHost);
final Answer answer = wrapper.execute(storageStatsCommand, this.citrixResourceBase);
verify(this.citrixResourceBase, times(1)).getConnection();
assertFalse(answer.getResult());
}
Aggregations