Search in sources :

Example 6 with QueryType

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

the class GWTRPCCommunicationProviderTest method testTransmitOperationList_oneQuery_success.

@Test
public void testTransmitOperationList_oneQuery_success() {
    List<VdcOperation<?, ?>> testList = new ArrayList<>();
    QueryParametersBase testParameters = new QueryParametersBase();
    VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackSingle1);
    testList.add(testOperation1);
    testProvider.transmitOperationList(testList);
    verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), queryCallback.capture());
    QueryReturnValue testResult = new QueryReturnValue();
    queryCallback.getValue().onSuccess(testResult);
    verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testResult);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 7 with QueryType

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

the class GWTRPCCommunicationProviderTest method testTransmitPublicOperationList_success.

@Test
public void testTransmitPublicOperationList_success() {
    QueryParametersBase testQueryParameters = new QueryParametersBase();
    VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testQueryParameters, true, false, mockOperationCallbackSingle1);
    List<VdcOperation<?, ?>> operationList = new ArrayList<>();
    operationList.add(testOperation1);
    testProvider.transmitOperationList(operationList);
    verify(mockService).runPublicQuery(eq(QueryType.Search), eq(testQueryParameters), queryCallback.capture());
    QueryReturnValue testQueryResult = new QueryReturnValue();
    queryCallback.getValue().onSuccess(testQueryResult);
    verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testQueryResult);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 8 with QueryType

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

the class GWTRPCCommunicationProviderTest method testTransmitPublicOperationList_two_public_success.

@Test
public void testTransmitPublicOperationList_two_public_success() {
    QueryParametersBase testQueryParameters = new QueryParametersBase();
    VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testQueryParameters, true, false, mockOperationCallbackSingle1);
    VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.GetConfigurationValues, testQueryParameters, true, false, mockOperationCallbackSingle2);
    List<VdcOperation<?, ?>> operationList = new ArrayList<>();
    operationList.add(testOperation1);
    operationList.add(testOperation2);
    testProvider.transmitOperationList(operationList);
    verify(mockService).runPublicQuery(eq(QueryType.Search), eq(testQueryParameters), queryCallback.capture());
    QueryReturnValue testQueryResult = new QueryReturnValue();
    queryCallback.getValue().onSuccess(testQueryResult);
    verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testQueryResult);
    verify(mockService).runPublicQuery(eq(QueryType.GetConfigurationValues), eq(testQueryParameters), queryCallback.capture());
    testQueryResult = new QueryReturnValue();
    queryCallback.getValue().onSuccess(testQueryResult);
    verify(mockOperationCallbackSingle2).onSuccess(testOperation2, testQueryResult);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 9 with QueryType

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

the class OperationProcessorTest method testOnOperationAvailableSingle_failure_with_retry.

@Test
public void testOnOperationAvailableSingle_failure_with_retry() {
    QueryParametersBase testParameter = new QueryParametersBase();
    VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameter, mockCallback1);
    when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
    testProcessor.processAvailableOperations(mockOperationManager);
    verify(mockProvider).transmitOperationList(operationListCaptor.capture());
    // $NON-NLS-1$
    Exception testException = new Exception("This is an exception");
    operationListCaptor.getValue().get(0).getCallback().onFailure(operationListCaptor.getValue().get(0), testException);
    // Verify that the original callback is never called.
    verify(mockCallback1, never()).onFailure(operationListCaptor.getValue().get(0), testException);
    // Verify that the operation is put back in the queue.
    verify(mockOperationManager).addOperation(operationListCaptor.getValue().get(0));
    // Verify that the callback on the operation is no longer the original.
    assertFalse(// $NON-NLS-1$
    "callbacks should not match", operationListCaptor.getValue().get(0).getCallback().equals(mockCallback1));
}
Also used : QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 10 with QueryType

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

the class OperationProcessorTest method testOnOperationAvailableMultiple_same_success.

@Test
public void testOnOperationAvailableMultiple_same_success() {
    QueryParametersBase testParameter = new QueryParametersBase();
    List<VdcOperation<?, ?>> testOperation1List = new ArrayList<>();
    VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameter, mockCallbackList1);
    testOperation1List.add(testOperation1);
    VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.GetDirectoryGroupById, testParameter, mockCallbackList2);
    when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation1).thenReturn((VdcOperation) testOperation1).thenReturn((VdcOperation) testOperation2).thenReturn(null);
    testProcessor.processAvailableOperations(mockOperationManager);
    verify(mockProvider).transmitOperationList(operationListCaptor.capture());
    // Check to make sure it inserted its own callback.
    assertFalse(// $NON-NLS-1$
    "The callbacks should NOT match", operationListCaptor.getValue().get(0).getCallback().equals(mockCallbackList1));
    assertFalse(// $NON-NLS-1$
    "The callbacks should NOT match", operationListCaptor.getValue().get(1).getCallback().equals(mockCallbackList2));
    // There should be only be two items in the list.
    // $NON-NLS-1$
    assertEquals("There should be two items", 2, operationListCaptor.getValue().size());
    List<ActionReturnValue> resultList1 = new ArrayList<>();
    List<ActionReturnValue> resultList2 = new ArrayList<>();
    ActionReturnValue result1 = new ActionReturnValue();
    ActionReturnValue result2 = new ActionReturnValue();
    resultList1.add(result1);
    resultList2.add(result2);
    List<VdcOperation> captured1List = new ArrayList<>();
    captured1List.add(operationListCaptor.getValue().get(0));
    List<VdcOperation> captured2List = new ArrayList<>();
    captured2List.add(operationListCaptor.getValue().get(1));
    operationListCaptor.getValue().get(0).getCallback().onSuccess(captured1List, resultList1);
    verify(mockCallbackList1).onSuccess(testOperation1List, resultList1);
    operationListCaptor.getValue().get(1).getCallback().onSuccess(captured2List, resultList2);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Aggregations

QueryType (org.ovirt.engine.core.common.queries.QueryType)39 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)33 ArrayList (java.util.ArrayList)32 Test (org.junit.Test)22 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)21 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)15 Guid (org.ovirt.engine.core.compat.Guid)9 List (java.util.List)8 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)6 HashMap (java.util.HashMap)5 ActionType (org.ovirt.engine.core.common.action.ActionType)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)5 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)5 VM (org.ovirt.engine.core.common.businessentities.VM)4 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)4 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)3 Map (java.util.Map)3 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)3 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3