Search in sources :

Example 11 with ActionReturnValue

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);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 12 with ActionReturnValue

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());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 13 with ActionReturnValue

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);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 14 with ActionReturnValue

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);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 15 with ActionReturnValue

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);
}
Also used : HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) ArrayList(java.util.ArrayList) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)293 ArrayList (java.util.ArrayList)57 Guid (org.ovirt.engine.core.compat.Guid)55 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)50 Test (org.junit.Test)37 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)27 ActionType (org.ovirt.engine.core.common.action.ActionType)26 EngineException (org.ovirt.engine.core.common.errors.EngineException)25 VDS (org.ovirt.engine.core.common.businessentities.VDS)23 HashSet (java.util.HashSet)16 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)15 ExecutionException (java.util.concurrent.ExecutionException)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)13 CinderDisk (org.ovirt.engine.core.common.businessentities.storage.CinderDisk)13 StorageServerConnectionParametersBase (org.ovirt.engine.core.common.action.StorageServerConnectionParametersBase)12 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)12 List (java.util.List)11 ChangeVDSClusterParameters (org.ovirt.engine.core.common.action.ChangeVDSClusterParameters)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)11