use of org.ovirt.engine.ui.uicompat.FrontendMultipleQueryAsyncResult 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();
}
use of org.ovirt.engine.ui.uicompat.FrontendMultipleQueryAsyncResult 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.ui.uicompat.FrontendMultipleQueryAsyncResult in project ovirt-engine by oVirt.
the class Frontend method runMultipleQueries.
/**
* Run multiple queries in a single request to the back-end.
* @param queryTypeList A list of {@code QueryType}s.
* @param queryParamsList A list of parameters associated with each query.
* @param callback The callback to call when the query completes.
* @param state The state object.
*/
public void runMultipleQueries(final List<QueryType> queryTypeList, final List<QueryParametersBase> queryParamsList, final IFrontendMultipleQueryAsyncCallback callback, final Object state) {
VdcOperationCallbackList<VdcOperation<QueryType, QueryParametersBase>, List<QueryReturnValue>> multiCallback = new VdcOperationCallbackList<VdcOperation<QueryType, QueryParametersBase>, List<QueryReturnValue>>() {
@Override
public void onSuccess(final List<VdcOperation<QueryType, QueryParametersBase>> operationList, final List<QueryReturnValue> resultObject) {
// $NON-NLS-1$
logger.finer("Succesful returned result from runMultipleQueries!");
FrontendMultipleQueryAsyncResult f = new FrontendMultipleQueryAsyncResult(queryTypeList, queryParamsList, resultObject);
callback.executed(f);
fireAsyncQuerySucceededEvent(state);
}
@Override
public void onFailure(final List<VdcOperation<QueryType, QueryParametersBase>> operationList, final Throwable caught) {
try {
if (ignoreFailure(caught)) {
return;
}
// $NON-NLS-1$
logger.log(Level.SEVERE, "Failed to execute runMultipleQueries: " + caught, caught);
FrontendMultipleQueryAsyncResult f = new FrontendMultipleQueryAsyncResult(queryTypeList, queryParamsList, null);
failureEventHandler(caught);
callback.executed(f);
} finally {
fireAsyncQueryFailedEvent(state);
}
}
};
List<VdcOperation<?, ?>> operationList = new ArrayList<>();
for (int i = 0; i < queryTypeList.size(); i++) {
QueryParametersBase parameters = queryParamsList.get(i);
// Why do we do this?
parameters.setRefresh(false);
initQueryParamsFilter(parameters);
operationList.add(new VdcOperation<>(queryTypeList.get(i), parameters, true, multiCallback, false));
}
fireAsyncOperationStartedEvent(state);
getOperationManager().addOperationList(operationList);
}
Aggregations