Search in sources :

Example 26 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType 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 27 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType 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 28 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType 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 29 with QueryType

use of org.ovirt.engine.core.common.queries.QueryType 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)

Example 30 with QueryType

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

the class AbstractGwtDynamicHostPageServletTest method testRunPublicQuery_GetConfigurationValue.

@Test
public void testRunPublicQuery_GetConfigurationValue() {
    // $NON-NLS-1$
    String sessionId = "sessionId";
    QueryType queryType = QueryType.GetConfigurationValue;
    QueryReturnValue returnIntValue = new QueryReturnValue();
    returnIntValue.setSucceeded(true);
    returnIntValue.setReturnValue(Integer.valueOf(255));
    when(mockBackend.runPublicQuery(eq(QueryType.GetConfigurationValue), eq(mockConfigQueryParams))).thenReturn(returnIntValue);
    Object result = testServlet.runPublicQuery(queryType, mockConfigQueryParams, sessionId);
    assertThat(result, is(instanceOf(Integer.class)));
    verify(mockConfigQueryParams).setSessionId(sessionId);
    verify(mockConfigQueryParams).setFiltered(testServlet.filterQueries());
    verify(mockBackend).runPublicQuery(queryType, mockConfigQueryParams);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) 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