use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class FrontendTest method testrunQuery_failure_404_with_pending.
/**
* Run the following test case.
* <ol>
* <li>Run a search query, with *win* as the parameter, searching for VMs</li>
* <li>Immediately, before returning a failure result, call the same run query again</li>
* <li>The callback is NOT marked to handle failures</li>
* <li>Force a failure with an HTTP status code = 404 (file not found)</li>
* <li>Check to make sure only one query is called. Due to the second being a duplicate</li>
* <li>Check to make sure the appropriate query start and query complete events are fired</li>
* </ol>
*/
@Test
public void testrunQuery_failure_404_with_pending() {
// $NON-NLS-1$
QueryParametersBase testParameters = new SearchParameters("*win*", SearchType.VM);
frontend.runQuery(QueryType.Search, testParameters, mockAsyncQuery, false);
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 that only one request is executed, until the first one is complete.
verify(mockService, times(i)).runQuery(eq(QueryType.Search), eq(testParameters), callback.capture());
// Now finish the first request.
// Call the failure handler.
callback.getValue().onFailure(exception);
}
verify(mockEventsHandler, atLeastOnce()).runQueryFailed(null);
verifyAsyncQueryFailed();
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class FrontendTest method testrunMultipleQueries_multiple_success.
/**
* 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</li>
* <li>Check to make sure the appropriate query start and query complete events are fired</li>
* </ol>
*/
@Test
public void testrunMultipleQueries_multiple_success() {
// 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(true);
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();
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class FrontendTest method testrunQuery_success_succeeded_multiple_same_eventshandler_noconverter.
/**
* Run the following test case.
* <ol>
* <li>Run a search query, with *win* as the parameter, searching for VMs</li>
* <li>Immediately, before returning a result, call the same run query again</li>
* <li>Return success, the success status is succeeded</li>
* <li>No success converter defined</li>
* <li>Make sure that the result callback is called only once</li>
* <li>Check to make sure the appropriate query start and query complete events are fired</li>
* </ol>
*/
@Test
public void testrunQuery_success_succeeded_multiple_same_eventshandler_noconverter() {
Object mockModel = new Object();
when(mockAsyncQuery.getModel()).thenReturn(mockModel);
// $NON-NLS-1$
QueryParametersBase testParameters = new SearchParameters("*win*", SearchType.VM);
frontend.runQuery(QueryType.Search, testParameters, mockAsyncQuery, false);
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("USER_IS_NOT_LOGGED_IN");
// Return value set to success
mockReturnValue.setSucceeded(true);
callback.getValue().onSuccess(mockReturnValue);
verify(mockAsyncCallback).onSuccess(mockReturnValue);
verifyAsyncQuerySucceeded();
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class QuotaListModel method syncSearch.
@Override
protected void syncSearch() {
SearchParameters tempVar = new SearchParameters(applySortOptions(getSearchString()), SearchType.Quota, isCaseSensitiveSearch());
tempVar.setMaxCount(getSearchPageSize());
super.syncSearch(QueryType.Search, tempVar);
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class ProviderListModel method syncSearch.
@Override
protected void syncSearch() {
SearchParameters tempVar = new SearchParameters(applySortOptions(getSearchString()), SearchType.Provider, isCaseSensitiveSearch());
tempVar.setMaxCount(getSearchPageSize());
super.syncSearch(QueryType.Search, tempVar);
}
Aggregations