Search in sources :

Example 11 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class FrontendActionTest method testHandleActionResult_SucceededFalse.

/**
 * Run the following test case.
 * <ol>
 *   <li>Run a single action</li>
 *   <li>Return logical failure, validate=true.</li>
 *   <li>Get succeeded is false.</li>
 *   <li>IsSyncronious is true.</li>
 *   <li>showDialog is true.</li>
 *   <li>Check to make sure the failure event is fired</li>
 *   <li>Check to make sure the callback is called</li>
 * </ol>
 * Test just the handler method.
 */
@Test
public void testHandleActionResult_SucceededFalse() {
    ActionParametersBase testParameters = new ActionParametersBase();
    ActionReturnValue returnValue = new ActionReturnValue();
    returnValue.setValid(true);
    returnValue.setIsSynchronous(true);
    // Yes this is the default, but to make sure.
    returnValue.setSucceeded(false);
    EngineFault testFault = new EngineFault();
    returnValue.setFault(testFault);
    frontend.handleActionResult(ActionType.AddDisk, testParameters, returnValue, mockActionCallback, testState, true);
    verify(mockActionCallback).executed(callbackParam.capture());
    // $NON-NLS-1$
    assertEquals("Parameters should match", testParameters, callbackParam.getValue().getParameters());
    // $NON-NLS-1$
    assertEquals("Result should match", returnValue, callbackParam.getValue().getReturnValue());
    // $NON-NLS-1$
    assertEquals("States should match", testState, callbackParam.getValue().getState());
    assertEquals(// $NON-NLS-1$
    "Action type should match", // $NON-NLS-1$
    ActionType.AddDisk, callbackParam.getValue().getActionType());
    verify(mockEventsHandler).runActionExecutionFailed(ActionType.AddDisk, testFault);
}
Also used : ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EngineFault(org.ovirt.engine.core.common.errors.EngineFault) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 12 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class GWTRPCCommunicationProviderTest method testGetOperationResult_One_of_Two.

@Test
public void testGetOperationResult_One_of_Two() {
    VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.ActivateVds, new ActionParametersBase(), null);
    VdcOperation<ActionType, ActionParametersBase> testOperation2 = new VdcOperation<>(ActionType.AddBookmark, new ActionParametersBase(), null);
    List<VdcOperation<?, ?>> testOperationList = new ArrayList<>();
    testOperationList.add(testOperation2);
    List<VdcOperation<?, ?>> allOperationList = new ArrayList<>();
    allOperationList.add(testOperation1);
    allOperationList.add(testOperation2);
    ActionReturnValue testResult1 = new ActionReturnValue();
    ActionReturnValue testResult2 = new ActionReturnValue();
    List<ActionReturnValue> allResults = new ArrayList<>();
    allResults.add(testResult1);
    allResults.add(testResult2);
    List<?> result = testProvider.getOperationResult(testOperationList, allOperationList, allResults);
    // $NON-NLS-1$
    assertEquals("Result should have one results", 1, result.size());
    // $NON-NLS-1$
    assertEquals("Result should match", testResult2, result.get(0));
}
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 ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase in project ovirt-engine by oVirt.

the class GWTRPCCommunicationProviderTest method testTransmitOperationAction_failure.

@Test
public void testTransmitOperationAction_failure() {
    ActionParametersBase testParameters = new ActionParametersBase();
    final List<VdcOperation<ActionType, ActionParametersBase>> operationList = new ArrayList<>();
    // $NON-NLS-1$
    final Exception testException = new Exception("This is an exception");
    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$
            fail("Should not get here");
        }

        @Override
        public void onFailure(VdcOperation<ActionType, ActionParametersBase> operation, Throwable exception) {
            // $NON-NLS-1$
            assertEquals("Operations should match", operationList.get(0), operation);
            // $NON-NLS-1$
            assertEquals("Exceptions should match", testException, exception);
        }
    });
    operationList.add(testOperation);
    testProvider.transmitOperation(testOperation);
    verify(mockService).runAction(eq(ActionType.AddDisk), eq(testParameters), actionCallback.capture());
    actionCallback.getValue().onFailure(testException);
}
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 14 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase 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 15 with ActionParametersBase

use of org.ovirt.engine.core.common.action.ActionParametersBase 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)

Aggregations

ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)204 ArrayList (java.util.ArrayList)149 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)53 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)52 ActionType (org.ovirt.engine.core.common.action.ActionType)45 Test (org.junit.Test)44 Guid (org.ovirt.engine.core.compat.Guid)35 VDS (org.ovirt.engine.core.common.businessentities.VDS)26 List (java.util.List)23 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)23 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)20 VM (org.ovirt.engine.core.common.businessentities.VM)19 QueryType (org.ovirt.engine.core.common.queries.QueryType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)18 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)18 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)16 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)16 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)16 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)15