/** * Run the following test case. * <ol> * <li>Run a single action</li> * <li>Force a failure with an HTTP status code = 404</li> * <li>Check to make sure the failure event is fired</li> * <li>Check to make sure the callback is called</li> * </ol> */ @Test public void testrunActionImpl_404_failure() { ActionParametersBase testParameters = new ActionParametersBase(); frontend.runAction(ActionType.AddDisk, testParameters, mockActionCallback, testState, false); verify(mockService).runAction(eq(ActionType.AddDisk), eq(testParameters), callbackAction.capture()); StatusCodeException exception = new StatusCodeException(HttpServletResponse.SC_NOT_FOUND, "404 status code"); //$NON-NLS-1$ callbackAction.getValue().onFailure(exception); verify(mockFrontendFailureEvent).raise(eq(Frontend.class), (FrontendFailureEventArgs) any()); verify(mockActionCallback).executed(callbackParam.capture()); assertEquals(testParameters, callbackParam.getValue().getParameters(), "Parameters should match"); //$NON-NLS-1$ assertNull(callbackParam.getValue().getReturnValue(), "Result should be null"); //$NON-NLS-1$ assertEquals(testState, callbackParam.getValue().getState(), "States should match"); //$NON-NLS-1$ assertEquals(ActionType.AddDisk, callbackParam.getValue().getActionType(), "Action type should match"); //$NON-NLS-1$ verifyAsyncActionStartedAndFailed(); }
/** * Run the following test case. * <ol> * <li>Run a single action</li> * <li>Return success.</li> * <li>Check to make sure the callback is called</li> * </ol> */ @Test public void testrunActionImpl_success() { ActionParametersBase testParameters = new ActionParametersBase(); frontend.runAction(ActionType.AddDisk, testParameters, mockActionCallback, testState, false); verify(mockService).runAction(eq(ActionType.AddDisk), eq(testParameters), callbackAction.capture()); ActionReturnValue returnValue = new ActionReturnValue(); callbackAction.getValue().onSuccess(returnValue); verify(mockActionCallback).executed(callbackParam.capture()); assertEquals(testParameters, callbackParam.getValue().getParameters(), "Parameters should match"); //$NON-NLS-1$ assertEquals(returnValue, callbackParam.getValue().getReturnValue(), "Result should match"); //$NON-NLS-1$ assertEquals(testState, callbackParam.getValue().getState(), "States should match"); //$NON-NLS-1$ assertEquals(ActionType.AddDisk, callbackParam.getValue().getActionType(), "Action type should match"); //$NON-NLS-1$ verifyAsyncActionStartedAndSucceeded(); }
assertEquals(returnValue, callbackParam.getValue().getReturnValue(), "Result should match"); //$NON-NLS-1$ assertEquals(testState, callbackParam.getValue().getState(), "States should match"); //$NON-NLS-1$ assertEquals(ActionType.AddDisk, callbackParam.getValue().getActionType(), "Action type should match"); //$NON-NLS-1$ ArgumentCaptor<FrontendFailureEventArgs> failureCaptor =
assertEquals(returnValue, callbackParam.getValue().getReturnValue(), "Result should match"); //$NON-NLS-1$ assertEquals(testState, callbackParam.getValue().getState(), "States should match"); //$NON-NLS-1$ assertEquals(ActionType.AddDisk, callbackParam.getValue().getActionType(), "Action type should match"); //$NON-NLS-1$ ArgumentCaptor<FrontendFailureEventArgs> failureCaptor =
assertEquals(returnValue, callbackParam.getValue().getReturnValue(), "Result should match"); //$NON-NLS-1$ assertEquals(testState, callbackParam.getValue().getState(), "States should match"); //$NON-NLS-1$ assertEquals(ActionType.AddDisk, callbackParam.getValue().getActionType(), "Action type should match"); //$NON-NLS-1$ ArgumentCaptor<FrontendFailureEventArgs> failureCaptor =
/** * Run the following test case. * <ol> * <li>Run a single action</li> * <li>Return logical failure, validate=false.</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() { ActionParametersBase testParameters = new ActionParametersBase(); ActionReturnValue returnValue = new ActionReturnValue(); returnValue.setValid(false); // Yes this is the default, but to make sure. frontend.handleActionResult(ActionType.AddDisk, testParameters, returnValue, mockActionCallback, testState, false); verify(mockActionCallback).executed(callbackParam.capture()); assertEquals(testParameters, callbackParam.getValue().getParameters(), "Parameters should match"); //$NON-NLS-1$ assertEquals(returnValue, callbackParam.getValue().getReturnValue(), "Result should match"); //$NON-NLS-1$ assertEquals(testState, callbackParam.getValue().getState(), "States should match"); //$NON-NLS-1$ assertEquals(ActionType.AddDisk, callbackParam.getValue().getActionType(), "Action type should match"); //$NON-NLS-1$ }
assertEquals(returnValue, callbackParam.getValue().getReturnValue(), "Result should match"); //$NON-NLS-1$ assertEquals(testState, callbackParam.getValue().getState(), "States should match"); //$NON-NLS-1$ assertEquals(ActionType.AddDisk, callbackParam.getValue().getActionType(), "Action type should match"); //$NON-NLS-1$ verify(mockEventsHandler).runActionExecutionFailed(ActionType.AddDisk, testFault);