Search in sources :

Example 41 with ActionType

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);
}
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 42 with ActionType

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

Example 43 with ActionType

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);
}
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 44 with ActionType

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

Example 45 with ActionType

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));
}
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

ActionType (org.ovirt.engine.core.common.action.ActionType)58 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)37 ArrayList (java.util.ArrayList)31 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)24 Test (org.junit.Test)23 IFrontendActionAsyncCallback (org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback)16 Guid (org.ovirt.engine.core.compat.Guid)15 List (java.util.List)13 QueryType (org.ovirt.engine.core.common.queries.QueryType)11 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)11 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)11 Frontend (org.ovirt.engine.ui.frontend.Frontend)10 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)10 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)10 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)9 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)9 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)9 Arrays (java.util.Arrays)7 HashSet (java.util.HashSet)7 Set (java.util.Set)7