use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_query_and_action_success.
@Test
public void testTransmitOperationList_query_and_action_success() {
QueryParametersBase testQueryParameters = new QueryParametersBase();
ActionParametersBase testActionParameters = new ActionParametersBase();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testQueryParameters, mockOperationCallbackSingle1);
VdcOperation<ActionType, ActionParametersBase> testOperation2 = new VdcOperation<>(ActionType.ActivateVds, testActionParameters, mockOperationCallbackSingle2);
List<VdcOperation<?, ?>> operationList = new ArrayList<>();
operationList.add(testOperation1);
operationList.add(testOperation2);
testProvider.transmitOperationList(operationList);
verify(mockService).runQuery(eq(QueryType.Search), eq(testQueryParameters), queryCallback.capture());
QueryReturnValue testQueryResult = new QueryReturnValue();
queryCallback.getValue().onSuccess(testQueryResult);
verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testQueryResult);
ActionReturnValue testActionResult = new ActionReturnValue();
verify(mockService).runAction(eq(ActionType.ActivateVds), eq(testActionParameters), actionCallback.capture());
actionCallback.getValue().onSuccess(testActionResult);
verify(mockOperationCallbackSingle2).onSuccess(testOperation2, testActionResult);
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationQuery_failure.
@Test
public void testTransmitOperationQuery_failure() {
QueryParametersBase testParameters = new QueryParametersBase();
// $NON-NLS-1$
final Exception testException = new Exception("This is an exception");
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$
fail("Should not get here");
}
@Override
public void onFailure(VdcOperation<QueryType, QueryParametersBase> operation, Throwable exception) {
// $NON-NLS-1$
assertEquals("Operations should match", operationList.get(0), operation);
// $NON-NLS-1$
assertEquals("Exceptions should match", testException, exception);
}
});
operationList.add(testOperation);
testProvider.transmitOperation(testOperation);
verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), queryCallback.capture());
queryCallback.getValue().onFailure(testException);
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableSingle_failure_query_noretry.
@Test
public void testOnOperationAvailableSingle_failure_query_noretry() {
QueryParametersBase testParameter = new QueryParametersBase();
// Setup 'previous' retries, so we have exhausted the retries.
VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameter, mockCallback1);
testOperation = new VdcOperation(testOperation, mockCallback2);
testOperation = new VdcOperation(testOperation, mockCallback2);
testOperation = new VdcOperation(testOperation, mockCallback2);
testOperation = new VdcOperation(testOperation, mockCallback2);
when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
// $NON-NLS-1$
Exception testException = new Exception("This is an exception");
operationListCaptor.getValue().get(0).getCallback().onFailure(testOperation, testException);
// Verify that the original callback is called.
verify(mockCallback1).onFailure(testOperation, testException);
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class VdcOperationManagerTest method testAddOperationList.
@Test
public void testAddOperationList() {
VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.AddNetworkOnProvider, new ActionParametersBase(), null);
QueryParametersBase testParameters = new QueryParametersBase().withRefresh();
VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.Search, testParameters, null);
VdcOperation<QueryType, QueryParametersBase> testOperation3 = new VdcOperation<>(QueryType.Search, testParameters, null);
List<VdcOperation<?, ?>> operationList = new ArrayList<>();
operationList.add(testOperation1);
operationList.add(testOperation2);
operationList.add(testOperation3);
testManager.addOperationList(operationList);
verify(mockOperationProcessor, times(3)).processOperation(testManager);
verify(mockEventBus, times(2)).fireEvent(any());
// $NON-NLS-1$
assertEquals("First poll should be action", testManager.pollOperation(), testOperation1);
// $NON-NLS-1$
assertEquals("Second poll should be query", testManager.pollOperation(), testOperation2);
// $NON-NLS-1$
assertNull("Third poll should be null", testManager.pollOperation());
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class AbstractGwtDynamicHostPageServletTest method testRunPublicQuery_GetConfigurationValue.
@Test
public void testRunPublicQuery_GetConfigurationValue() {
// $NON-NLS-1$
String sessionId = "sessionId";
QueryType queryType = QueryType.GetConfigurationValue;
QueryReturnValue returnIntValue = new QueryReturnValue();
returnIntValue.setSucceeded(true);
returnIntValue.setReturnValue(Integer.valueOf(255));
when(mockBackend.runPublicQuery(eq(QueryType.GetConfigurationValue), eq(mockConfigQueryParams))).thenReturn(returnIntValue);
Object result = testServlet.runPublicQuery(queryType, mockConfigQueryParams, sessionId);
assertThat(result, is(instanceOf(Integer.class)));
verify(mockConfigQueryParams).setSessionId(sessionId);
verify(mockConfigQueryParams).setFiltered(testServlet.filterQueries());
verify(mockBackend).runPublicQuery(queryType, mockConfigQueryParams);
}
Aggregations