use of org.ovirt.engine.core.common.queries.SearchParameters 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.SearchParameters in project ovirt-engine by oVirt.
the class FrontendTest method testrunQuery_success_succeeded_eventshandler_noconverter.
/**
* 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>No success converter defined</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_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);
verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), callback.capture());
QueryReturnValue mockReturnValue = new QueryReturnValue();
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 FrontendTest method testrunQuery_success_not_succeeded_eventshandler_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 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_eventshandler_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("USER_IS_NOT_LOGGED_IN");
// Return value set to failure
mockReturnValue.setSucceeded(false);
callback.getValue().onSuccess(mockReturnValue);
// Make sure the not logged in event is called
verify(mockFrontendNotLoggedInEvent).raise(Frontend.class, EventArgs.EMPTY);
verifyAsyncQuerySucceeded();
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class FrontendTest method testrunQuery_ignored_failure.
/**
* 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>Force a special failure with an HTTP status code = 0, this is an ignored failure</li>
* <li>Check to make sure the appropriate query start and query complete events are fired</li>
* </ol>
*/
@Test
public void testrunQuery_ignored_failure() {
// $NON-NLS-1$
QueryParametersBase testParameters = new SearchParameters("*win*", SearchType.VM);
// $NON-NLS-1$
StatusCodeException exception = new StatusCodeException(0, "0 status code");
frontend.runQuery(QueryType.Search, testParameters, mockAsyncQuery, false);
// 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);
}
verifyAsyncQueryFailed();
}
use of org.ovirt.engine.core.common.queries.SearchParameters in project ovirt-engine by oVirt.
the class FrontendTest method testrunQuery_failure_404.
/**
* 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>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() {
// $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(mockEventsHandler).runQueryFailed(null);
verifyAsyncQueryFailed();
}
Aggregations