예제 #1
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a multiple actions, with multiple actions
  *   <li>Have one of them fail. The rest is successful
  *   <li>Check to make sure the failure event is never fired
  * </ol>
  */
 @SuppressWarnings("unchecked")
 @Test
 public void testrunMultipleActionsMultipleSuccess_oneFailure() {
   // Don't immediately call process until both queries are in the queue.
   fakeScheduler.setThreshold(2);
   ArrayList<VdcActionParametersBase> parameters = new ArrayList<VdcActionParametersBase>();
   parameters.add(new VdcActionParametersBase());
   parameters.add(new VdcActionParametersBase());
   parameters.get(0).setCommandId(Guid.Empty);
   Object testState = new Object();
   frontend.runMultipleAction(
       VdcActionType.AddLocalStorageDomain,
       parameters,
       false,
       mockMultipleActionCallback,
       testState);
   verify(mockService)
       .runMultipleActions(
           eq(VdcActionType.AddLocalStorageDomain),
           eq(parameters),
           eq(false),
           eq(false),
           callbackMultipleActions.capture());
   ArrayList<VdcReturnValueBase> returnValues = new ArrayList<VdcReturnValueBase>();
   returnValues.add(new VdcReturnValueBase());
   returnValues.add(new VdcReturnValueBase());
   returnValues.get(0).setCanDoAction(true);
   returnValues.get(1).setCanDoAction(false);
   callbackMultipleActions.getValue().onSuccess(returnValues);
   verify(mockFrontendFailureEvent, never())
       .raise(eq(Frontend.class), (FrontendFailureEventArgs) any());
   @SuppressWarnings("rawtypes")
   ArgumentCaptor<ArrayList> failedCaptor = ArgumentCaptor.forClass(ArrayList.class);
   verify(mockEventsHandler)
       .runMultipleActionFailed(eq(VdcActionType.AddLocalStorageDomain), failedCaptor.capture());
   assertEquals("There is one failure", 1, failedCaptor.getValue().size()); // $NON-NLS-1$
   assertEquals(
       "Failures should match",
       returnValues.get(1),
       failedCaptor.getValue().get(0)); // $NON-NLS-1$
   verify(mockMultipleActionCallback).executed(callbackMultipleParam.capture());
   assertEquals(
       "Parameters should match",
       parameters, //$NON-NLS-1$
       callbackMultipleParam.getValue().getParameters());
   assertEquals(
       "Result should match",
       returnValues, //$NON-NLS-1$
       callbackMultipleParam.getValue().getReturnValue());
   assertEquals(
       "States should match",
       testState,
       callbackMultipleParam.getValue().getState()); // $NON-NLS-1$
 }
예제 #2
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a multiple actions, a single action
  *   <li>Force a special failure with an HTTP status code = 0, this is an ignored failure (escape
  *       key pressed)
  *   <li>Check to make sure the failure event is never fired
  * </ol>
  */
 @Test
 public void testrunMultipleActions_ignored_failure_multiple() {
   ArrayList<VdcActionParametersBase> parameters = new ArrayList<VdcActionParametersBase>();
   parameters.add(new VdcActionParametersBase());
   frontend.runMultipleAction(
       VdcActionType.AddLocalStorageDomain, parameters, false, mockMultipleActionCallback, null);
   verify(mockService)
       .runMultipleActions(
           eq(VdcActionType.AddLocalStorageDomain),
           eq(parameters),
           eq(false),
           eq(false),
           callbackMultipleActions.capture());
   StatusCodeException exception = new StatusCodeException(0, "0 status code"); // $NON-NLS-1$
   callbackMultipleActions.getValue().onFailure(exception);
   verify(mockFrontendFailureEvent, never())
       .raise(eq(Frontend.class), (FrontendFailureEventArgs) any());
   verify(mockMultipleActionCallback, never()).executed(callbackMultipleParam.capture());
 }
예제 #3
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a multiple actions, a single action
  *   <li>Force a failure with an HTTP status code = 404
  *   <li>Check to make sure the failure event is fired
  *   <li>Check to make sure the proper values are passed to the callback.
  * </ol>
  */
 @Test
 public void testrunMultipleActions_404_failure_multiple() {
   ArrayList<VdcActionParametersBase> parameters = new ArrayList<VdcActionParametersBase>();
   parameters.add(new VdcActionParametersBase());
   Object testState = new Object();
   frontend.runMultipleAction(
       VdcActionType.AddLocalStorageDomain,
       parameters,
       false,
       mockMultipleActionCallback,
       testState);
   verify(mockService)
       .runMultipleActions(
           eq(VdcActionType.AddLocalStorageDomain),
           eq(parameters),
           eq(false),
           eq(false),
           callbackMultipleActions.capture());
   StatusCodeException exception =
       new StatusCodeException(HttpServletResponse.SC_NOT_FOUND, "404 status code"); // $NON-NLS-1$
   callbackMultipleActions.getValue().onFailure(exception);
   verify(mockFrontendFailureEvent).raise(eq(Frontend.class), (FrontendFailureEventArgs) any());
   verify(mockMultipleActionCallback).executed(callbackMultipleParam.capture());
   assertEquals(
       "ActionType should be 'AddLocalStorageDomain'",
       VdcActionType.AddLocalStorageDomain, // $NON-NLS-1$
       callbackMultipleParam.getValue().getActionType());
   assertEquals(
       "Parameters should match",
       parameters, //$NON-NLS-1$
       callbackMultipleParam.getValue().getParameters());
   assertNull(
       "There should be no result",
       callbackMultipleParam.getValue().getReturnValue()); // $NON-NLS-1$
   assertEquals(
       "States should match",
       testState,
       callbackMultipleParam.getValue().getState()); // $NON-NLS-1$
 }