package org.ovirt.engine.core.bll.storage.domain; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; import org.junit.Test; import org.ovirt.engine.core.common.businessentities.StorageDomainStatic; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; import org.ovirt.engine.core.common.businessentities.storage.StorageType; import org.ovirt.engine.core.common.queries.StorageDomainsAndStoragePoolIdQueryParameters; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.vdscommands.HSMGetStorageDomainInfoVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; import org.ovirt.engine.core.compat.Guid; public class GetBlockStorageDomainsWithAttachedStoragePoolGuidQueryTest extends AbstractGetStorageDomainsWithAttachedStoragePoolGuidQueryTestCase <StorageDomainsAndStoragePoolIdQueryParameters, GetBlockStorageDomainsWithAttachedStoragePoolGuidQuery<StorageDomainsAndStoragePoolIdQueryParameters>> { @Override protected StorageType getStorageType() { return StorageType.ISCSI; } @Test public void testNullStorageDomainListQuery() { StoragePool storagePool = new StoragePool(); storagePool.setStatus(StoragePoolStatus.Up); mockStoragePoolDao(storagePool); // 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(HSMGetStorageDomainInfoVDSCommandParameters.class))).thenReturn(returnValue); // Execute command getQuery().executeQueryCommand(); // Assert the query's results List<StorageDomainStatic> returnedStorageDomainList = new ArrayList<>(); assertEquals(returnedStorageDomainList, getQuery().getQueryReturnValue().getReturnValue()); } }