Search in sources :

Example 66 with QueryParametersBase

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

the class GWTRPCCommunicationProviderTest method testTransmitOperationList_query_and_action_success.

@Test
public void testTransmitOperationList_query_and_action_success() {
    QueryParametersBase testQueryParameters = new QueryParametersBase();
    ActionParametersBase testActionParameters = new ActionParametersBase();
    VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testQueryParameters, mockOperationCallbackSingle1);
    VdcOperation<ActionType, ActionParametersBase> testOperation2 = new VdcOperation<>(ActionType.ActivateVds, testActionParameters, mockOperationCallbackSingle2);
    List<VdcOperation<?, ?>> operationList = new ArrayList<>();
    operationList.add(testOperation1);
    operationList.add(testOperation2);
    testProvider.transmitOperationList(operationList);
    verify(mockService).runQuery(eq(QueryType.Search), eq(testQueryParameters), queryCallback.capture());
    QueryReturnValue testQueryResult = new QueryReturnValue();
    queryCallback.getValue().onSuccess(testQueryResult);
    verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testQueryResult);
    ActionReturnValue testActionResult = new ActionReturnValue();
    verify(mockService).runAction(eq(ActionType.ActivateVds), eq(testActionParameters), actionCallback.capture());
    actionCallback.getValue().onSuccess(testActionResult);
    verify(mockOperationCallbackSingle2).onSuccess(testOperation2, testActionResult);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ActionType(org.ovirt.engine.core.common.action.ActionType) 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) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 67 with QueryParametersBase

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

the class GWTRPCCommunicationProviderTest method testTransmitOperationQuery_failure.

@Test
public void testTransmitOperationQuery_failure() {
    QueryParametersBase testParameters = new QueryParametersBase();
    // $NON-NLS-1$
    final Exception testException = new Exception("This is an exception");
    final List<VdcOperation<QueryType, QueryParametersBase>> operationList = new ArrayList<>();
    final VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameters, new VdcOperationCallback<VdcOperation<QueryType, QueryParametersBase>, QueryReturnValue>() {

        @Override
        public void onSuccess(VdcOperation<QueryType, QueryParametersBase> operation, QueryReturnValue result) {
            // $NON-NLS-1$
            fail("Should not get here");
        }

        @Override
        public void onFailure(VdcOperation<QueryType, QueryParametersBase> operation, Throwable exception) {
            // $NON-NLS-1$
            assertEquals("Operations should match", operationList.get(0), operation);
            // $NON-NLS-1$
            assertEquals("Exceptions should match", testException, exception);
        }
    });
    operationList.add(testOperation);
    testProvider.transmitOperation(testOperation);
    verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), queryCallback.capture());
    queryCallback.getValue().onFailure(testException);
}
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 68 with QueryParametersBase

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

the class OperationProcessorTest method testOnOperationAvailableSingle_failure_query_noretry.

@Test
public void testOnOperationAvailableSingle_failure_query_noretry() {
    QueryParametersBase testParameter = new QueryParametersBase();
    // Setup 'previous' retries, so we have exhausted the retries.
    VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameter, mockCallback1);
    testOperation = new VdcOperation(testOperation, mockCallback2);
    testOperation = new VdcOperation(testOperation, mockCallback2);
    testOperation = new VdcOperation(testOperation, mockCallback2);
    testOperation = new VdcOperation(testOperation, mockCallback2);
    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(testOperation, testException);
    // Verify that the original callback is called.
    verify(mockCallback1).onFailure(testOperation, testException);
}
Also used : QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 69 with QueryParametersBase

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

the class OperationProcessorTest method testOnOperationAvailableList.

@Test
public void testOnOperationAvailableList() {
    ActionParametersBase testActionParameter = new ActionParametersBase();
    QueryParametersBase testQueryParameter = new QueryParametersBase();
    VdcOperation testOperation1 = new VdcOperation(ActionType.AddEventSubscription, testActionParameter, mockCallback1);
    VdcOperation testOperation2 = new VdcOperation(QueryType.Search, testQueryParameter, mockCallback2);
    VdcOperation testOperation3 = new VdcOperation(ActionType.AddEmptyStoragePool, testActionParameter, mockCallback3);
    when(mockOperationManager.pollOperation()).thenReturn(testOperation1).thenReturn(testOperation2).thenReturn(testOperation3).thenReturn(null);
    testProcessor.processAvailableOperations(mockOperationManager);
    verify(mockProvider).transmitOperationList(operationListCaptor.capture());
    // $NON-NLS-1$
    assertEquals("Should have 3 operations", 3, operationListCaptor.getValue().size());
    // Test that we inserted the callback from the processor.
    assertFalse(// $NON-NLS-1$
    "The callbacks should not match.", operationListCaptor.getValue().get(0).getCallback().equals(mockCallback1));
    assertFalse(// $NON-NLS-1$
    "The callbacks should not match.", operationListCaptor.getValue().get(1).getCallback().equals(mockCallback2));
    assertFalse(// $NON-NLS-1$
    "The callbacks should not match.", operationListCaptor.getValue().get(2).getCallback().equals(mockCallback3));
}
Also used : QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 70 with QueryParametersBase

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

the class VdcOperationManagerTest method testAddOperationList.

@Test
public void testAddOperationList() {
    VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.AddNetworkOnProvider, new ActionParametersBase(), null);
    QueryParametersBase testParameters = new QueryParametersBase().withRefresh();
    VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.Search, testParameters, null);
    VdcOperation<QueryType, QueryParametersBase> testOperation3 = new VdcOperation<>(QueryType.Search, testParameters, null);
    List<VdcOperation<?, ?>> operationList = new ArrayList<>();
    operationList.add(testOperation1);
    operationList.add(testOperation2);
    operationList.add(testOperation3);
    testManager.addOperationList(operationList);
    verify(mockOperationProcessor, times(3)).processOperation(testManager);
    verify(mockEventBus, times(2)).fireEvent(any());
    // $NON-NLS-1$
    assertEquals("First poll should be action", testManager.pollOperation(), testOperation1);
    // $NON-NLS-1$
    assertEquals("Second poll should be query", testManager.pollOperation(), testOperation2);
    // $NON-NLS-1$
    assertNull("Third poll should be null", testManager.pollOperation());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Aggregations

QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)89 ArrayList (java.util.ArrayList)41 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)40 QueryType (org.ovirt.engine.core.common.queries.QueryType)37 Test (org.junit.Test)33 StorageServerConnectionQueryParametersBase (org.ovirt.engine.core.common.queries.StorageServerConnectionQueryParametersBase)22 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)18 List (java.util.List)15 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)15 Guid (org.ovirt.engine.core.compat.Guid)13 HashMap (java.util.HashMap)11 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)9 HashSet (java.util.HashSet)7 Map (java.util.Map)6 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 Frontend (org.ovirt.engine.ui.frontend.Frontend)6 Collection (java.util.Collection)5 Quota (org.ovirt.engine.core.common.businessentities.Quota)5 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)5 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)5