Search in sources :

Example 6 with StorageDomainsAndStoragePoolIdQueryParameters

use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.

the class GetStorageDomainsWithAttachedStoragePoolGuidQueryTest method testStoragePoolIdReturnNullStoragePool.

@Test
public void testStoragePoolIdReturnNullStoragePool() {
    mockStoragePoolDao(null);
    // Create parameters
    List<StorageDomain> storageDomainList = new ArrayList<>();
    storageDomainList.add(storageDomain);
    StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
    when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
    when(paramsMock.isCheckStoragePoolStatus()).thenReturn(Boolean.TRUE);
    // Run 'HSMGetStorageDomainInfo' command
    VDSReturnValue returnValue = new VDSReturnValue();
    returnValue.setSucceeded(true);
    Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
    returnValue.setReturnValue(storageDomainToPoolId);
    when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
    // Execute command
    getQuery().executeQueryCommand();
    // Assert the query's results
    List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
    assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) StorageDomainsAndStoragePoolIdQueryParameters(org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair) Test(org.junit.Test)

Example 7 with StorageDomainsAndStoragePoolIdQueryParameters

use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.

the class GetStorageDomainsWithAttachedStoragePoolGuidQueryTest method testUninitializedStoragePool.

@Test
public void testUninitializedStoragePool() {
    StoragePool storagePool = new StoragePool();
    storagePool.setStatus(StoragePoolStatus.Uninitialized);
    mockStoragePoolDao(storagePool);
    // Create parameters
    List<StorageDomain> storageDomainList = new ArrayList<>();
    storageDomainList.add(storageDomain);
    StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
    when(paramsMock.getStorageDomainList()).thenReturn(storageDomainList);
    when(paramsMock.isCheckStoragePoolStatus()).thenReturn(Boolean.TRUE);
    // Run 'HSMGetStorageDomainInfo' command
    VDSReturnValue returnValue = new VDSReturnValue();
    returnValue.setSucceeded(true);
    Pair<StorageDomainStatic, Guid> storageDomainToPoolId = new Pair<>(storageDomain.getStorageStaticData(), Guid.newGuid());
    returnValue.setReturnValue(storageDomainToPoolId);
    when(vdsBrokerFrontendMock.runVdsCommand(eq(VDSCommandType.HSMGetStorageDomainInfo), any())).thenReturn(returnValue);
    // Execute command
    getQuery().executeQueryCommand();
    // Assert the query's results
    List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
    assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid) StorageDomainsAndStoragePoolIdQueryParameters(org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue) Pair(org.ovirt.engine.core.common.utils.Pair) Test(org.junit.Test)

Example 8 with StorageDomainsAndStoragePoolIdQueryParameters

use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.

the class GetFileStorageDomainsWithAttachedStoragePoolGuidQueryTest method testFetchUsingStorageServerConnectionWithAttachedStorageDomain.

@Test
public void testFetchUsingStorageServerConnectionWithAttachedStorageDomain() {
    StoragePool storagePool = new StoragePool();
    storagePool.setStatus(StoragePoolStatus.Up);
    mockStoragePoolDao(storagePool);
    // Create parameters
    StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
    when(paramsMock.getStorageDomainList()).thenReturn(null);
    StorageServerConnections storageServerConnection = new StorageServerConnections();
    when(paramsMock.getStorageServerConnection()).thenReturn(storageServerConnection);
    StorageDomain mockedStorageDomain = new StorageDomain();
    mockedStorageDomain.setStorageStaticData(new StorageDomainStatic());
    mockedStorageDomain.setStoragePoolId(Guid.newGuid());
    List<StorageDomain> storageDomains = new ArrayList<>();
    storageDomains.add(mockedStorageDomain);
    QueryReturnValue vdcReturnValue = new QueryReturnValue();
    vdcReturnValue.setSucceeded(true);
    vdcReturnValue.setReturnValue(storageDomains);
    doReturn(vdcReturnValue).when(getQuery()).getExistingStorageDomainList(eq(storageServerConnection));
    // Execute command
    getQuery().executeQueryCommand();
    // Assert the query's results
    List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
    returnedStorageDomainList.add(mockedStorageDomain.getStorageStaticData());
    assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) StorageDomainsAndStoragePoolIdQueryParameters(org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters) Test(org.junit.Test)

Example 9 with StorageDomainsAndStoragePoolIdQueryParameters

use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.

the class GetFileStorageDomainsWithAttachedStoragePoolGuidQueryTest method testFetchUsingStorageServerConnectionWithEmptyListRetrieved.

@Test
public void testFetchUsingStorageServerConnectionWithEmptyListRetrieved() {
    StoragePool storagePool = new StoragePool();
    storagePool.setStatus(StoragePoolStatus.Up);
    mockStoragePoolDao(storagePool);
    // Create parameters
    StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
    when(paramsMock.getStorageDomainList()).thenReturn(null);
    StorageServerConnections storageServerConnections = new StorageServerConnections();
    when(paramsMock.getStorageServerConnection()).thenReturn(storageServerConnections);
    List<StorageDomain> storageDomains = new ArrayList<>();
    QueryReturnValue vdcReturnValue = new QueryReturnValue();
    vdcReturnValue.setSucceeded(true);
    vdcReturnValue.setReturnValue(storageDomains);
    doReturn(vdcReturnValue).when(getQuery()).getExistingStorageDomainList(eq(storageServerConnections));
    // Execute command
    getQuery().executeQueryCommand();
    // Assert the query's results
    List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
    assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) StorageDomain(org.ovirt.engine.core.common.businessentities.StorageDomain) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) StorageDomainsAndStoragePoolIdQueryParameters(org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters) Test(org.junit.Test)

Example 10 with StorageDomainsAndStoragePoolIdQueryParameters

use of org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters in project ovirt-engine by oVirt.

the class GetFileStorageDomainsWithAttachedStoragePoolGuidQueryTest method testFetchUsingStorageServerConnectionWithFailedInternalQuery.

@Test
public void testFetchUsingStorageServerConnectionWithFailedInternalQuery() {
    StoragePool storagePool = new StoragePool();
    storagePool.setStatus(StoragePoolStatus.Up);
    mockStoragePoolDao(storagePool);
    // Create parameters
    StorageDomainsAndStoragePoolIdQueryParameters paramsMock = getQueryParameters();
    when(paramsMock.getStorageDomainList()).thenReturn(null);
    StorageServerConnections storageServerConnections = new StorageServerConnections();
    when(paramsMock.getStorageServerConnection()).thenReturn(storageServerConnections);
    QueryReturnValue vdcReturnValue = new QueryReturnValue();
    vdcReturnValue.setSucceeded(false);
    vdcReturnValue.setReturnValue(null);
    doReturn(vdcReturnValue).when(getQuery()).getExistingStorageDomainList(eq(storageServerConnections));
    // Execute command
    getQuery().executeQueryCommand();
    // Assert the query's results
    List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>();
    assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue());
}
Also used : StorageDomainStatic(org.ovirt.engine.core.common.businessentities.StorageDomainStatic) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) StorageServerConnections(org.ovirt.engine.core.common.businessentities.StorageServerConnections) ArrayList(java.util.ArrayList) StorageDomainsAndStoragePoolIdQueryParameters(org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters) Test(org.junit.Test)

Aggregations

StorageDomainsAndStoragePoolIdQueryParameters (org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters)14 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)12 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)10 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)9 Guid (org.ovirt.engine.core.compat.Guid)8 Pair (org.ovirt.engine.core.common.utils.Pair)7 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)7 StorageServerConnections (org.ovirt.engine.core.common.businessentities.StorageServerConnections)4 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)4 AbstractQueryTest (org.ovirt.engine.core.bll.AbstractQueryTest)3 Action (org.ovirt.engine.api.model.Action)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1