Search in sources :

Example 46 with ActionType

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

the class GWTRPCCommunicationProviderTest method testTransmitOperationList_threeItems_twoActionTypes_success.

@Test
public void testTransmitOperationList_threeItems_twoActionTypes_success() {
    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);
    actionCallback.getValue().onSuccess(testResult);
    verify(mockOperationCallbackList1).onSuccess(eq(activateVdsList), eq(activateVdsResultList));
    verify(mockOperationCallbackSingle2).onSuccess(testOperation3, testResultList.get(2));
}
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 47 with ActionType

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

the class OperationProcessorTest method testOnOperationAvailableSingle_failure_action_noretry.

@Test
public void testOnOperationAvailableSingle_failure_action_noretry() {
    ActionParametersBase testParameter = new ActionParametersBase();
    VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddEventSubscription, testParameter, mockCallback1);
    when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
    testProcessor.processAvailableOperations(mockOperationManager);
    verify(mockProvider).transmitOperationList(operationListCaptor.capture());
    // $NON-NLS-1$
    Exception testException = new Exception("This is an exception");
    operationListCaptor.getValue().get(0).getCallback().onFailure(testOperation, testException);
    // Verify that the original callback is called.
    verify(mockCallback1).onFailure(testOperation, testException);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 48 with ActionType

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

the class OperationProcessorTest method testOnOperationAvailableSingle_success.

@Test
public void testOnOperationAvailableSingle_success() {
    ActionParametersBase testParameter = new ActionParametersBase();
    VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddEventSubscription, testParameter, mockCallback1);
    when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
    testProcessor.processAvailableOperations(mockOperationManager);
    verify(mockProvider).transmitOperationList(operationListCaptor.capture());
    Object testResult = new Object();
    operationListCaptor.getValue().get(0).getCallback().onSuccess(testOperation, testResult);
    // Verify that the original callback is called.
    verify(mockCallback1).onSuccess(testOperation, testResult);
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 49 with ActionType

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

the class VdcOperationManagerTest method testAddOperationAction.

@Test
public void testAddOperationAction() {
    VdcOperation<ActionType, ActionParametersBase> testOperation = new VdcOperation<>(ActionType.AddNetworkOnProvider, new ActionParametersBase(), null);
    testManager.addOperation(testOperation);
    verify(mockOperationProcessor).processOperation(testManager);
    verify(mockEventBus).fireEvent(any());
    // $NON-NLS-1$
    assertEquals("Operations must match", testOperation, testManager.pollOperation());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) Test(org.junit.Test)

Example 50 with ActionType

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

the class VdcOperationManagerTest method testAddOperationList.

@Test
public void testAddOperationList() {
    VdcOperation<ActionType, ActionParametersBase> testOperation1 = new VdcOperation<>(ActionType.AddNetworkOnProvider, new ActionParametersBase(), null);
    QueryParametersBase testParameters = new QueryParametersBase().withRefresh();
    VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.Search, testParameters, null);
    VdcOperation<QueryType, QueryParametersBase> testOperation3 = new VdcOperation<>(QueryType.Search, testParameters, null);
    List<VdcOperation<?, ?>> operationList = new ArrayList<>();
    operationList.add(testOperation1);
    operationList.add(testOperation2);
    operationList.add(testOperation3);
    testManager.addOperationList(operationList);
    verify(mockOperationProcessor, times(3)).processOperation(testManager);
    verify(mockEventBus, times(2)).fireEvent(any());
    // $NON-NLS-1$
    assertEquals("First poll should be action", testManager.pollOperation(), testOperation1);
    // $NON-NLS-1$
    assertEquals("Second poll should be query", testManager.pollOperation(), testOperation2);
    // $NON-NLS-1$
    assertNull("Third poll should be null", testManager.pollOperation());
}
Also used : ActionType(org.ovirt.engine.core.common.action.ActionType) 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)

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