Search in sources :

Example 46 with SearchParameters

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

the class VolumeListModel method syncSearch.

@Override
protected void syncSearch() {
    SearchParameters tempVar = new SearchParameters(getSearchString(), SearchType.GlusterVolume, isCaseSensitiveSearch());
    tempVar.setMaxCount(getSearchPageSize());
    super.syncSearch(QueryType.Search, tempVar);
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters)

Example 47 with SearchParameters

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

the class FrontendTest method testrunQuery_success_not_succeeded_noeventshandler_nocallbackhandler.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a search query, with *win* as the parameter, searching for VMs</li>
 *   <li>The callback is NOT marked to handle failures</li>
 *   <li>The failure is NOT, a-not-logged in failure</li>
 *   <li>Return success, but the success status is !succeeded (business logic failure/not logged in)</li>
 *   <li>Check to make sure the appropriate query start and query complete events are fired</li>
 * </ol>
 */
@Test
public void testrunQuery_success_not_succeeded_noeventshandler_nocallbackhandler() {
    // $NON-NLS-1$
    QueryParametersBase testParameters = new SearchParameters("*win*", SearchType.VM);
    frontend.runQuery(QueryType.Search, testParameters, mockAsyncQuery, false);
    verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), callback.capture());
    QueryReturnValue mockReturnValue = new QueryReturnValue();
    // $NON-NLS-1$
    mockReturnValue.setExceptionString("Fake failure for test");
    // Return value set to failure
    mockReturnValue.setSucceeded(false);
    callback.getValue().onSuccess(mockReturnValue);
    // Make sure the not logged in event is never called, as the failure is not a USER_IS_NOT_LOGGED_IN
    verify(mockFrontendNotLoggedInEvent, never()).raise(Frontend.class, EventArgs.EMPTY);
    verifyAsyncQuerySucceeded();
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Test(org.junit.Test)

Example 48 with SearchParameters

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

the class FrontendTest method testrunQuery_failure_404_callback.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a search query, with *win* as the parameter, searching for VMs</li>
 *   <li>The callback is marked to handle failures, make sure the callback failure handler is called</li>
 *   <li>Force a failure with an HTTP status code = 404 (file not found)</li>
 *   <li>Check to make sure the appropriate query start and query complete events are fired</li>
 * </ol>
 */
@Test
public void testrunQuery_failure_404_callback() {
    Object mockModel = new Object();
    when(mockAsyncQuery.isHandleFailure()).thenReturn(true);
    when(mockAsyncQuery.getModel()).thenReturn(mockModel);
    // $NON-NLS-1$
    QueryParametersBase testParameters = new SearchParameters("*win*", SearchType.VM);
    frontend.runQuery(QueryType.Search, testParameters, mockAsyncQuery, false);
    StatusCodeException exception = new StatusCodeException(HttpServletResponse.SC_NOT_FOUND, // $NON-NLS-1$
    "404 status code");
    // Repeat 4 times, because of retries.
    for (int i = 1; i < RETRY_COUNT; i++) {
        verify(mockService, times(i)).runQuery(eq(QueryType.Search), eq(testParameters), callback.capture());
        // Call the failure handler.
        callback.getValue().onFailure(exception);
    }
    verify(mockAsyncCallback).onSuccess(null);
    verify(mockEventsHandler).runQueryFailed(null);
    verifyAsyncQueryFailed();
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) StatusCodeException(com.google.gwt.user.client.rpc.StatusCodeException) Test(org.junit.Test)

Example 49 with SearchParameters

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

the class FrontendTest method testrunMultipleQueries_404_failure.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a multiple search query, with only multiple requests, with *win* / *lin* as the parameter,
 *   searching for VMs</li>
 *   <li>Force a failure with an HTTP status code = 404</li>
 *   <li>Check to make sure the appropriate query start and query complete events are fired</li>
 * </ol>
 */
@Test
public void testrunMultipleQueries_404_failure() {
    // Don't immediately call process until both queries are in the queue.
    fakeScheduler.setThreshold(2);
    when(mockConstants.requestToServerFailedWithCode()).thenReturn(// $NON-NLS-1$
    "A Request to the Server failed with the following Status Code");
    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);
    StatusCodeException exception = new StatusCodeException(HttpServletResponse.SC_NOT_FOUND, // $NON-NLS-1$
    "404 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);
    }
    ArgumentCaptor<FrontendFailureEventArgs> eventArgs = ArgumentCaptor.forClass(FrontendFailureEventArgs.class);
    verify(mockFrontendFailureEvent).raise(eq(Frontend.class), eventArgs.capture());
    assertEquals(// $NON-NLS-1$
    "Message text didn't match", // $NON-NLS-1$
    "A Request to the Server failed with the following Status Code: 404", eventArgs.getValue().getMessages().get(0).getText());
    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 50 with SearchParameters

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

the class FrontendTest method testrunQuery_success_succeeded_eventshandler_converter.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a search query, with *win* as the parameter, searching for VMs</li>
 *   <li>Return success, the success status is succeeded</li>
 *   <li>A success converter defined</li>
 *   <li>Check that the converted value is returned to the callback</li>
 *   <li>Check to make sure the appropriate query start and query complete events are fired</li>
 * </ol>
 */
@Test
public void testrunQuery_success_succeeded_eventshandler_converter() {
    Object mockModel = new Object();
    Object mockResultModel = new Object();
    Object mockConvertedModel = new Object();
    when(mockAsyncQuery.getModel()).thenReturn(mockModel);
    when(mockAsyncQuery.getConverter()).thenReturn(mockConverter);
    // $NON-NLS-1$
    QueryParametersBase testParameters = new SearchParameters("*win*", SearchType.VM);
    frontend.runQuery(QueryType.Search, testParameters, mockAsyncQuery, false);
    verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), callback.capture());
    QueryReturnValue mockReturnValue = new QueryReturnValue();
    mockReturnValue.setReturnValue(mockResultModel);
    // $NON-NLS-1$
    mockReturnValue.setExceptionString("USER_IS_NOT_LOGGED_IN");
    when(mockConverter.convert(mockResultModel)).thenReturn(mockConvertedModel);
    // Return value set to success
    mockReturnValue.setSucceeded(true);
    callback.getValue().onSuccess(mockReturnValue);
    verify(mockAsyncCallback).onSuccess(mockConvertedModel);
    verifyAsyncQuerySucceeded();
}
Also used : SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Test(org.junit.Test)

Aggregations

SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)58 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)19 Test (org.junit.Test)17 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)17 ArrayList (java.util.ArrayList)15 QueryType (org.ovirt.engine.core.common.queries.QueryType)12 StatusCodeException (com.google.gwt.user.client.rpc.StatusCodeException)9 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)7 Frontend (org.ovirt.engine.ui.frontend.Frontend)7 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)7 List (java.util.List)6 Guid (org.ovirt.engine.core.compat.Guid)6 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)6 VDS (org.ovirt.engine.core.common.businessentities.VDS)5 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)5 UIConstants (org.ovirt.engine.ui.uicompat.UIConstants)5 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)4 EnumTranslator (org.ovirt.engine.ui.uicompat.EnumTranslator)4