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();
}
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();
}
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();
}
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);
}
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);
}
Aggregations