/** * Run the following test case. * * <ol> * <li>Run MultipleActions with multiple actions, first failure, and second success. * <li>Check to make sure the failure callback is called for the first action * <li>Make sure the success callback is never called for the second action * </ol> */ @Test public void testrunMultipleActions_multipleaction_success_first_failure_second_success() { List<VdcActionType> actionTypes = new ArrayList<VdcActionType>(); actionTypes.add(VdcActionType.AddDisk); actionTypes.add(VdcActionType.AddBricksToGlusterVolume); List<VdcActionParametersBase> testParameters = new ArrayList<VdcActionParametersBase>(); testParameters.add(new VdcActionParametersBase()); testParameters.add(new VdcActionParametersBase()); List<IFrontendActionAsyncCallback> callbacks = new ArrayList<IFrontendActionAsyncCallback>(); callbacks.add(mockActionCallback); callbacks.add(mockActionCallback); Object testState = new Object(); frontend.runMultipleActions( actionTypes, testParameters, callbacks, mockActionFailureCallback, testState); verify(mockService) .runAction(eq(VdcActionType.AddDisk), eq(testParameters.get(0)), callbackAction.capture()); VdcReturnValueBase returnValue = new VdcReturnValueBase(); returnValue.setCanDoAction(false); returnValue.setSucceeded(false); callbackAction.getValue().onSuccess(returnValue); verify(mockActionFailureCallback).executed(callbackParam.capture()); assertEquals(callbackParam.getValue().getReturnValue(), returnValue); // Second call to runAction, the size of the parameters should have decreased verify(mockService, never()) .runAction( eq(VdcActionType.AddBricksToGlusterVolume), eq(testParameters.get(0)), callbackAction.capture()); }
/** * Run the following test case. * * <ol> * <li>Run MultipleActions with a single action, that is successful. * <li>Check to make sure the callback is called * </ol> */ @Test public void testrunMultipleActions_1action() { List<VdcActionType> actionTypes = new ArrayList<VdcActionType>(); actionTypes.add(VdcActionType.AddDisk); List<VdcActionParametersBase> testParameters = new ArrayList<VdcActionParametersBase>(); testParameters.add(new VdcActionParametersBase()); List<IFrontendActionAsyncCallback> callbacks = new ArrayList<IFrontendActionAsyncCallback>(); callbacks.add(mockActionCallback); Object testState = new Object(); frontend.runMultipleActions( actionTypes, testParameters, callbacks, mockActionFailureCallback, testState); verify(mockService) .runAction(eq(VdcActionType.AddDisk), eq(testParameters.get(0)), callbackAction.capture()); VdcReturnValueBase returnValue = new VdcReturnValueBase(); returnValue.setCanDoAction(true); returnValue.setSucceeded(true); callbackAction.getValue().onSuccess(returnValue); verify(mockActionCallback).executed(callbackParam.capture()); assertEquals(callbackParam.getValue().getReturnValue(), returnValue); 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()); // $NON-NLS-1$ }