use of org.ovirt.engine.core.common.queries.QueryParametersBase 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.QueryParametersBase 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.QueryParametersBase 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.QueryParametersBase in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableList.
@Test
public void testOnOperationAvailableList() {
ActionParametersBase testActionParameter = new ActionParametersBase();
QueryParametersBase testQueryParameter = new QueryParametersBase();
VdcOperation testOperation1 = new VdcOperation(ActionType.AddEventSubscription, testActionParameter, mockCallback1);
VdcOperation testOperation2 = new VdcOperation(QueryType.Search, testQueryParameter, mockCallback2);
VdcOperation testOperation3 = new VdcOperation(ActionType.AddEmptyStoragePool, testActionParameter, mockCallback3);
when(mockOperationManager.pollOperation()).thenReturn(testOperation1).thenReturn(testOperation2).thenReturn(testOperation3).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
// $NON-NLS-1$
assertEquals("Should have 3 operations", 3, operationListCaptor.getValue().size());
// Test that we inserted the callback from the processor.
assertFalse(// $NON-NLS-1$
"The callbacks should not match.", operationListCaptor.getValue().get(0).getCallback().equals(mockCallback1));
assertFalse(// $NON-NLS-1$
"The callbacks should not match.", operationListCaptor.getValue().get(1).getCallback().equals(mockCallback2));
assertFalse(// $NON-NLS-1$
"The callbacks should not match.", operationListCaptor.getValue().get(2).getCallback().equals(mockCallback3));
}
use of org.ovirt.engine.core.common.queries.QueryParametersBase 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());
}
Aggregations