use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_threeItems_twoActionTypes_success.
@Test
public void testTransmitOperationList_threeItems_twoActionTypes_success() {
final ActionReturnValue testResult = new ActionReturnValue();
List<VdcOperation<?, ?>> testList = new ArrayList<>();
List<VdcOperation<?, ?>> activateVdsList = new ArrayList<>();
ActionParametersBase testParameters = new ActionParametersBase();
VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.ActivateVds, testParameters, mockOperationCallbackList1);
VdcOperation<ActionType, ActionParametersBase> testOperation2 = new VdcOperation<>(ActionType.ActivateVds, testParameters, mockOperationCallbackList1);
VdcOperation<ActionType, ActionParametersBase> testOperation3 = new VdcOperation<>(ActionType.ActivateStorageDomain, testParameters, mockOperationCallbackSingle2);
testList.add(testOperation1);
testList.add(testOperation2);
testList.add(testOperation3);
activateVdsList.add(testOperation1);
activateVdsList.add(testOperation2);
List<ActionParametersBase> activateVdsParameterList = createActionParameterList(testParameters, 2);
List<ActionReturnValue> testResultList = createActionResultList(testResult, 3);
List<ActionReturnValue> activateVdsResultList = createActionResultList(testResult, 2);
testProvider.transmitOperationList(testList);
verify(mockService).runMultipleActions(eq(ActionType.ActivateVds), (ArrayList<ActionParametersBase>) eq(activateVdsParameterList), eq(false), eq(true), actionCallbackList.capture());
verify(mockService).runAction(eq(ActionType.ActivateStorageDomain), eq(testParameters), actionCallback.capture());
actionCallbackList.getValue().onSuccess((ArrayList<ActionReturnValue>) testResultList);
actionCallback.getValue().onSuccess(testResult);
verify(mockOperationCallbackList1).onSuccess(eq(activateVdsList), eq(activateVdsResultList));
verify(mockOperationCallbackSingle2).onSuccess(testOperation3, testResultList.get(2));
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableSingle_failure_action_noretry.
@Test
public void testOnOperationAvailableSingle_failure_action_noretry() {
ActionParametersBase testParameter = new ActionParametersBase();
VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddEventSubscription, testParameter, mockCallback1);
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.action.ActionType in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableSingle_success.
@Test
public void testOnOperationAvailableSingle_success() {
ActionParametersBase testParameter = new ActionParametersBase();
VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddEventSubscription, testParameter, mockCallback1);
when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
Object testResult = new Object();
operationListCaptor.getValue().get(0).getCallback().onSuccess(testOperation, testResult);
// Verify that the original callback is called.
verify(mockCallback1).onSuccess(testOperation, testResult);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class VdcOperationManagerTest method testAddOperationAction.
@Test
public void testAddOperationAction() {
VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddNetworkOnProvider, new ActionParametersBase(), null);
testManager.addOperation(testOperation);
verify(mockOperationProcessor).processOperation(testManager);
verify(mockEventBus).fireEvent(any());
// $NON-NLS-1$
assertEquals("Operations must match", testOperation, testManager.pollOperation());
}
use of org.ovirt.engine.core.common.action.ActionType 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