use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_oneAction_success.
@Test
public void testTransmitOperationList_oneAction_success() {
final ActionReturnValue testResult = new ActionReturnValue();
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());
actionCallback.getValue().onSuccess(testResult);
verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testResult);
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testGetOperationResult_One.
@Test
public void testGetOperationResult_One() {
VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.ActivateVds, new ActionParametersBase(), null);
List<VdcOperation<?, ?>> testOperationList = new ArrayList<>();
testOperationList.add(testOperation1);
List<VdcOperation<?, ?>> allOperationList = new ArrayList<>();
allOperationList.add(testOperation1);
ActionReturnValue testResult1 = new ActionReturnValue();
List<ActionReturnValue> allResults = new ArrayList<>();
allResults.add(testResult1);
List<?> result = testProvider.getOperationResult(testOperationList, allOperationList, allResults);
// $NON-NLS-1$
assertEquals("Result should have one results", 1, result.size());
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableMultiple_same_success.
@Test
public void testOnOperationAvailableMultiple_same_success() {
QueryParametersBase testParameter = new QueryParametersBase();
List<VdcOperation<?, ?>> testOperation1List = new ArrayList<>();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameter, mockCallbackList1);
testOperation1List.add(testOperation1);
VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.GetDirectoryGroupById, testParameter, mockCallbackList2);
when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation1).thenReturn((VdcOperation) testOperation1).thenReturn((VdcOperation) testOperation2).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
// Check to make sure it inserted its own callback.
assertFalse(// $NON-NLS-1$
"The callbacks should NOT match", operationListCaptor.getValue().get(0).getCallback().equals(mockCallbackList1));
assertFalse(// $NON-NLS-1$
"The callbacks should NOT match", operationListCaptor.getValue().get(1).getCallback().equals(mockCallbackList2));
// There should be only be two items in the list.
// $NON-NLS-1$
assertEquals("There should be two items", 2, operationListCaptor.getValue().size());
List<ActionReturnValue> resultList1 = new ArrayList<>();
List<ActionReturnValue> resultList2 = new ArrayList<>();
ActionReturnValue result1 = new ActionReturnValue();
ActionReturnValue result2 = new ActionReturnValue();
resultList1.add(result1);
resultList2.add(result2);
List<VdcOperation> captured1List = new ArrayList<>();
captured1List.add(operationListCaptor.getValue().get(0));
List<VdcOperation> captured2List = new ArrayList<>();
captured2List.add(operationListCaptor.getValue().get(1));
operationListCaptor.getValue().get(0).getCallback().onSuccess(captured1List, resultList1);
verify(mockCallbackList1).onSuccess(testOperation1List, resultList1);
operationListCaptor.getValue().get(1).getCallback().onSuccess(captured2List, resultList2);
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableMultiple_success.
@Test
public void testOnOperationAvailableMultiple_success() {
ActionParametersBase testParameter = new ActionParametersBase();
VdcOperation testOperation1 = new VdcOperation(ActionType.AddEventSubscription, testParameter, mockCallback1);
VdcOperation testOperation2 = new VdcOperation(ActionType.AddEventSubscription, testParameter, mockCallback2);
when(mockOperationManager.pollOperation()).thenReturn(testOperation1).thenReturn(testOperation2).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
assertFalse("The callbacks should not match", // $NON-NLS-1$
operationListCaptor.getValue().get(0).getCallback().equals(mockCallback1));
assertFalse("The callbacks should not match", // $NON-NLS-1$
operationListCaptor.getValue().get(1).getCallback().equals(mockCallback2));
List<ActionReturnValue> resultList1 = new ArrayList<>();
List<ActionReturnValue> resultList2 = new ArrayList<>();
ActionReturnValue result1 = new ActionReturnValue();
ActionReturnValue result2 = new ActionReturnValue();
resultList1.add(result1);
resultList2.add(result2);
operationListCaptor.getValue().get(0).getCallback().onSuccess(operationListCaptor.getValue().get(0), resultList1);
verify(mockCallback1).onSuccess(testOperation1, resultList1);
operationListCaptor.getValue().get(1).getCallback().onSuccess(operationListCaptor.getValue().get(1), resultList2);
verify(mockCallback2).onSuccess(testOperation2, resultList2);
}
use of org.ovirt.engine.core.common.action.ActionReturnValue in project ovirt-engine by oVirt.
the class ClusterListModel method addHosts.
private void addHosts(final MultipleHostsModel hostsModel) {
hostsModel.startProgress();
ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
for (Object object : hostsModel.getHosts().getItems()) {
HostDetailModel hostDetailModel = (HostDetailModel) ((EntityModel) object).getEntity();
VDS host = new VDS();
host.setVdsName(hostDetailModel.getName());
host.setHostName(hostDetailModel.getAddress());
host.setSshKeyFingerprint(hostDetailModel.getFingerprint());
host.setPort(54321);
// TODO: get from UI, till then using defaults.
host.setSshPort(22);
// $NON-NLS-1$
host.setSshUsername("root");
host.setClusterId(hostsModel.getClusterModel().getClusterId());
host.setPmEnabled(false);
AddVdsActionParameters parameters = new AddVdsActionParameters();
parameters.setVdsId(host.getId());
parameters.setvds(host);
parameters.setPassword(hostDetailModel.getPassword());
parameters.setOverrideFirewall(hostsModel.isConfigureFirewall());
parametersList.add(parameters);
}
// Todo: calling the runMultipleAction() with isRunOnlyIfAllValidationPass=false
// becuase this flag is now supported.
// should check what is the required behaviour and return to true if required.
Frontend.getInstance().runMultipleAction(ActionType.AddVds, parametersList, false, result -> {
hostsModel.stopProgress();
boolean isAllValidatePassed = true;
for (ActionReturnValue returnValueBase : result.getReturnValue()) {
isAllValidatePassed = returnValueBase.isValid();
if (!isAllValidatePassed) {
break;
}
}
if (isAllValidatePassed) {
cancel();
}
}, null);
}
Aggregations