use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_threeItems_twoActionTypes_one_success_one_failure.
@Test
public void testTransmitOperationList_threeItems_twoActionTypes_one_success_one_failure() {
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);
// $NON-NLS-1$
Exception testException = new Exception("This is an exception");
actionCallback.getValue().onFailure(testException);
verify(mockOperationCallbackList1).onSuccess(eq(activateVdsList), eq(activateVdsResultList));
verify(mockOperationCallbackSingle2).onFailure(testOperation3, testException);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_oneAction_failure.
@Test
public void testTransmitOperationList_oneAction_failure() {
List<VdcOperation<?, ?>> testList = new ArrayList<>();
ActionParametersBase testParameters = new ActionParametersBase();
VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.ActivateVds, testParameters, mockOperationCallbackSingle1);
testList.add(testOperation1);
testProvider.transmitOperationList(testList);
verify(mockService).runAction(eq(ActionType.ActivateVds), eq(testParameters), actionCallback.capture());
// $NON-NLS-1$
Exception testException = new Exception("Failure");
actionCallback.getValue().onFailure(testException);
verify(mockOperationCallbackSingle1).onFailure(testOperation1, testException);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationAction_success.
@Test
public void testTransmitOperationAction_success() {
ActionParametersBase testParameters = new ActionParametersBase();
final ActionReturnValue testResult = new ActionReturnValue();
final List<VdcOperation<ActionType, ActionParametersBase>> operationList = new ArrayList<>();
final VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddDisk, testParameters, new VdcOperationCallback<VdcOperation<ActionType, ActionParametersBase>, ActionReturnValue>() {
@Override
public void onSuccess(VdcOperation<ActionType, ActionParametersBase> operation, ActionReturnValue 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<ActionType, ActionParametersBase> operation, Throwable caught) {
// $NON-NLS-1$
fail("Should not get here");
}
});
operationList.add(testOperation);
testProvider.transmitOperation(testOperation);
verify(mockService).runAction(eq(ActionType.AddDisk), eq(testParameters), actionCallback.capture());
actionCallback.getValue().onSuccess(testResult);
}
use of org.ovirt.engine.core.common.action.ActionType 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.action.ActionType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_twoItems_success.
@Test
public void testTransmitOperationList_twoItems_success() {
final ActionReturnValue testResult = new ActionReturnValue();
List<VdcOperation<?, ?>> testList = 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);
List<ActionParametersBase> testParameterList = createActionParameterList(testParameters, 2);
List<ActionReturnValue> testResultList = createActionResultList(testResult, 2);
testList.add(testOperation1);
testList.add(testOperation2);
testProvider.transmitOperationList(testList);
verify(mockService).runMultipleActions(eq(ActionType.ActivateVds), (ArrayList<ActionParametersBase>) eq(testParameterList), eq(false), eq(true), actionCallbackList.capture());
actionCallbackList.getValue().onSuccess((ArrayList<ActionReturnValue>) testResultList);
verify(mockOperationCallbackList1).onSuccess(eq(testList), eq(testResultList));
}
Aggregations