Search in sources :

Example 1 with QueryType

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

the class FrontendTest method testrunMultipleQueries_multiple_success_and_failure.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a multiple search query, with multiple requests, with *win* or *lin* as the parameter,
 *   searching for VMs</li>
 *   <li>Return success, the success status is succeeded, with a failure in the result set</li>
 *   <li>Check to make sure the appropriate query start and query complete events are fired</li>
 * </ol>
 */
@Test
public void testrunMultipleQueries_multiple_success_and_failure() {
    // Don't immediately call process until both queries are in the queue.
    fakeScheduler.setThreshold(2);
    ArrayList<QueryType> queryTypeList = new ArrayList<>();
    queryTypeList.add(QueryType.Search);
    queryTypeList.add(QueryType.Search);
    ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
    // $NON-NLS-1$
    queryParamsList.add(new SearchParameters("*win*", SearchType.VM));
    // $NON-NLS-1$
    queryParamsList.add(new SearchParameters("*lin*", SearchType.VM));
    // $NON-NLS-1$
    frontend.runMultipleQueries(queryTypeList, queryParamsList, mockMultipleQueryCallback, ASYNC_OPERATION_TARGET);
    verify(mockService).runMultipleQueries(eq(queryTypeList), eq(queryParamsList), callbackMultipleQueries.capture());
    // Call the failure handler.
    List<QueryReturnValue> result = new ArrayList<>();
    result.add(new QueryReturnValue());
    result.get(0).setSucceeded(false);
    result.add(new QueryReturnValue());
    result.get(1).setSucceeded(true);
    ArgumentCaptor<FrontendMultipleQueryAsyncResult> multipleResultCaptor = ArgumentCaptor.forClass(FrontendMultipleQueryAsyncResult.class);
    callbackMultipleQueries.getValue().onSuccess((ArrayList<QueryReturnValue>) result);
    verify(mockMultipleQueryCallback).executed(multipleResultCaptor.capture());
    assertEquals(// $NON-NLS-1$
    "callback result much match", // $NON-NLS-1$
    result, multipleResultCaptor.getValue().getReturnValues());
    verifyAsyncQuerySucceeded();
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) 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) FrontendMultipleQueryAsyncResult(org.ovirt.engine.ui.uicompat.FrontendMultipleQueryAsyncResult) Test(org.junit.Test)

Example 2 with QueryType

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

the class FrontendTest method testrunMultipleQueries_ignored_failure_multiple.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a multiple search query, with multiple requests, with *win* or *lin* as the parameter, searching for
 *    VMs</li>
 *   <li>Force a special failure with an HTTP status code = 0, this is an ignored failure (escape key pressed)</li>
 *   <li>Check to make sure the appropriate query start and query complete events are fired</li>
 * </ol>
 */
@Test
public void testrunMultipleQueries_ignored_failure_multiple() {
    // Don't immediately call process until both queries are in the queue.
    fakeScheduler.setThreshold(2);
    ArrayList<QueryType> queryTypeList = new ArrayList<>();
    queryTypeList.add(QueryType.Search);
    queryTypeList.add(QueryType.Search);
    ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
    // $NON-NLS-1$
    queryParamsList.add(new SearchParameters("*win*", SearchType.VM));
    // $NON-NLS-1$
    queryParamsList.add(new SearchParameters("*lin*", SearchType.VM));
    // $NON-NLS-1$
    frontend.runMultipleQueries(queryTypeList, queryParamsList, mockMultipleQueryCallback, ASYNC_OPERATION_TARGET);
    // $NON-NLS-1$
    StatusCodeException exception = new StatusCodeException(0, "0 status code");
    // Repeat 4 times, because of retries.
    for (int i = 1; i < RETRY_COUNT; i++) {
        // Reset the count so we can re-add both entries again.
        fakeScheduler.resetCount();
        verify(mockService, times(i)).runMultipleQueries(eq(queryTypeList), eq(queryParamsList), callbackMultipleQueries.capture());
        // Call the failure handler.
        callbackMultipleQueries.getValue().onFailure(exception);
    }
    verify(mockFrontendFailureEvent, never()).raise(eq(Frontend.class), any());
    verifyAsyncQueryFailed();
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StatusCodeException(com.google.gwt.user.client.rpc.StatusCodeException) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 3 with QueryType

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

the class FrontendTest method testrunMultipleQueries_ignored_failure.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a multiple search query, with only one request, with *win* as the parameter, searching for VMs</li>
 *   <li>The callback is NOT marked to handle failures</li>
 *   <li>Force a special failure with an HTTP status code = 0, this is an ignored failure (escape key pressed)</li>
 *   <li>Check to make sure the appropriate query start and query complete events are fired</li>
 * </ol>
 */
@Test
public void testrunMultipleQueries_ignored_failure() {
    ArrayList<QueryType> queryTypeList = new ArrayList<>();
    queryTypeList.add(QueryType.Search);
    ArrayList<QueryParametersBase> queryParamsList = new ArrayList<>();
    // $NON-NLS-1$
    queryParamsList.add(new SearchParameters("*win*", SearchType.VM));
    // $NON-NLS-1$
    frontend.runMultipleQueries(queryTypeList, queryParamsList, mockMultipleQueryCallback, ASYNC_OPERATION_TARGET);
    // $NON-NLS-1$
    StatusCodeException exception = new StatusCodeException(0, "0 status code");
    // Repeat 4 times, because of retries.
    for (int i = 1; i < RETRY_COUNT; i++) {
        verify(mockService, times(i)).runMultipleQueries(eq(queryTypeList), eq(queryParamsList), callbackMultipleQueries.capture());
        // Call the failure handler.
        callbackMultipleQueries.getValue().onFailure(exception);
    }
    verify(mockFrontendFailureEvent, never()).raise(eq(Frontend.class), any());
    verifyAsyncQueryFailed();
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StatusCodeException(com.google.gwt.user.client.rpc.StatusCodeException) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 4 with QueryType

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

the class GWTRPCCommunicationProviderTest method testTransmitOperationList_oneQuery_failure.

@Test
public void testTransmitOperationList_oneQuery_failure() {
    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());
    // $NON-NLS-1$
    Exception testException = new Exception("This is an exception");
    queryCallback.getValue().onFailure(testException);
    verify(mockOperationCallbackSingle1).onFailure(testOperation1, testException);
}
Also used : 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 5 with QueryType

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

the class GWTRPCCommunicationProviderTest method testTransmitOperationQuery_success.

@Test
public void testTransmitOperationQuery_success() {
    QueryParametersBase testParameters = new QueryParametersBase();
    final QueryReturnValue testResult = new QueryReturnValue();
    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$
            assertEquals("Test results should match", testResult, result);
            // $NON-NLS-1$
            assertEquals("Operations should match", operationList.get(0), operation);
        }

        @Override
        public void onFailure(VdcOperation<QueryType, QueryParametersBase> operation, Throwable caught) {
            // $NON-NLS-1$
            fail("Should not get here");
        }
    });
    operationList.add(testOperation);
    testProvider.transmitOperation(testOperation);
    verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), queryCallback.capture());
    queryCallback.getValue().onSuccess(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)

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