use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class FrontendActionTest method testrunMultipleActions_1action.
/**
* Run the following test case.
* <ol>
* <li>Run MultipleActions with a single action, that is successful.</li>
* <li>Check to make sure the callback is called</li>
* </ol>
*/
@Test
public void testrunMultipleActions_1action() {
List<ActionType> actionTypes = new ArrayList<>();
actionTypes.add(ActionType.AddDisk);
List<ActionParametersBase> testParameters = new ArrayList<>();
testParameters.add(new ActionParametersBase());
List<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
callbacks.add(mockActionCallback);
frontend.runMultipleActions(actionTypes, testParameters, callbacks, mockActionFailureCallback, testState);
verify(mockService).runAction(eq(ActionType.AddDisk), eq(testParameters.get(0)), callbackAction.capture());
ActionReturnValue returnValue = new ActionReturnValue();
returnValue.setValid(true);
returnValue.setSucceeded(true);
callbackAction.getValue().onSuccess(returnValue);
verify(mockActionCallback).executed(callbackParam.capture());
assertEquals(returnValue, callbackParam.getValue().getReturnValue());
// $NON-NLS-1$
assertEquals("List size should be 0", 0, actionTypes.size());
// $NON-NLS-1$
assertEquals("List size should be 0", 0, testParameters.size());
// $NON-NLS-1$
assertEquals("List size should be 0", 0, callbacks.size());
verifyAsyncActionStartedAndSucceeded();
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class FrontendActionTest method testrunMultipleActions_multipleaction_success_first_success_second_failure.
/**
* Run the following test case.
* <ol>
* <li>Run MultipleActions with multiple actions, first success, and second failure.</li>
* <li>Check to make sure the success callback is called for the first action</li>
* <li>Check to make sure the failure callback is called for the second action</li>
* </ol>
*/
@Test
public void testrunMultipleActions_multipleaction_success_first_success_second_failure() {
List<ActionType> actionTypes = new ArrayList<>();
actionTypes.add(ActionType.AddDisk);
actionTypes.add(ActionType.AddBricksToGlusterVolume);
List<ActionParametersBase> testParameters = new ArrayList<>();
testParameters.add(new ActionParametersBase());
testParameters.add(new ActionParametersBase());
List<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
callbacks.add(mockActionCallback);
callbacks.add(mockActionCallback);
frontend.runMultipleActions(actionTypes, testParameters, callbacks, mockActionFailureCallback, testState);
verify(mockService).runAction(eq(ActionType.AddDisk), eq(testParameters.get(0)), callbackAction.capture());
ActionReturnValue returnValue = new ActionReturnValue();
returnValue.setValid(true);
returnValue.setSucceeded(true);
callbackAction.getValue().onSuccess(returnValue);
verify(mockActionCallback).executed(callbackParam.capture());
assertEquals(returnValue, callbackParam.getValue().getReturnValue());
// Second call to runAction
verify(mockService).runAction(eq(ActionType.AddBricksToGlusterVolume), eq(testParameters.get(0)), callbackAction.capture());
returnValue = new ActionReturnValue();
returnValue.setValid(false);
returnValue.setSucceeded(false);
callbackAction.getValue().onSuccess(returnValue);
verify(mockActionFailureCallback).executed(callbackParam.capture());
assertEquals(returnValue, callbackParam.getValue().getReturnValue());
verifyAsyncActionStartedAndSucceeded();
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class RegisterVmModel method onSave.
protected void onSave() {
List<ActionParametersBase> parameters = prepareParameters();
ActionType actionType = ActionType.ImportVmFromConfiguration;
onSave(actionType, parameters);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class SanStorageModelBase method connectTargets.
private void connectTargets() {
VDS host = getContainer().getHost().getSelectedItem();
if (host == null) {
return;
}
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
final SanStorageModelBase sanStorageModel = this;
IFrontendActionAsyncCallback loginCallback = result -> sanStorageModel.postLogin(result.getReturnValue(), sanStorageModel);
for (int i = 0; i < targetsToConnect.size(); i++) {
SanTargetModel model = targetsToConnect.get(i);
StorageServerConnections connection = new StorageServerConnections();
connection.setStorageType(StorageType.ISCSI);
// $NON-NLS-1$
connection.setUserName(getUseUserAuth().getEntity() ? getUserName().getEntity() : "");
// $NON-NLS-1$
connection.setPassword(getUseUserAuth().getEntity() ? getPassword().getEntity() : "");
connection.setIqn(model.getName());
connection.setConnection(model.getAddress());
connection.setPort(String.valueOf(model.getPort()));
connection.setPortal(model.getPortal());
actionTypes.add(ActionType.ConnectStorageToVds);
parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
callbacks.add(loginCallback);
}
Object target = getWidgetModel() != null ? getWidgetModel() : getContainer();
Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, null, target);
}
use of org.ovirt.engine.core.common.action.ActionType in project ovirt-engine by oVirt.
the class LibvirtSecretModel method onSave.
private void onSave() {
if (!validate()) {
return;
}
ActionType actionType = isNew() ? ActionType.AddLibvirtSecret : ActionType.UpdateLibvirtSecret;
flush();
Frontend.getInstance().runAction(actionType, new LibvirtSecretParameters(getEntity()), result -> {
ActionReturnValue res = result.getReturnValue();
if (res.getSucceeded()) {
getCancelCommand().execute();
}
}, this);
}
Aggregations