예제 #1
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a single action
  *   <li>Return logical failure, canDoAction=true.
  *   <li>Get succeeded is false.
  *   <li>IsSyncronious is true.
  *   <li>showDialog is true.
  *   <li>Check to make sure the failure event is fired
  *   <li>Check to make sure the callback is called
  * </ol>
  *
  * Test just the handler method.
  */
 @Test
 public void testHandleActionResult_SucceededFalse() {
   Object testState = new Object();
   VdcActionParametersBase testParameters = new VdcActionParametersBase();
   VdcReturnValueBase returnValue = new VdcReturnValueBase();
   returnValue.setCanDoAction(true);
   returnValue.setIsSyncronious(true);
   returnValue.setSucceeded(false); // Yes this is the default, but to make sure.
   VdcFault testFault = new VdcFault();
   returnValue.setFault(testFault);
   frontend.handleActionResult(
       VdcActionType.AddDisk, testParameters, returnValue, mockActionCallback, testState, true);
   verify(mockActionCallback).executed(callbackParam.capture());
   assertEquals(
       "Parameters should match",
       testParameters,
       callbackParam.getValue().getParameters()); // $NON-NLS-1$
   assertEquals(
       "Result should match",
       returnValue,
       callbackParam.getValue().getReturnValue()); // $NON-NLS-1$
   assertEquals(
       "States should match", testState, callbackParam.getValue().getState()); // $NON-NLS-1$
   assertEquals(
       "Action type should match",
       VdcActionType.AddDisk, // $NON-NLS-1$
       callbackParam.getValue().getActionType());
   verify(mockEventsHandler).runActionExecutionFailed(VdcActionType.AddDisk, testFault);
 }
예제 #2
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a single action
  *   <li>Return logical failure, canDoAction=false.
  *   <li>isRaiseErrorModalPanel returns true.
  *   <li>Check to make sure the failure event is fired
  *   <li>Check to make sure the callback is called
  * </ol>
  *
  * Test just the handler method.
  */
 @Test
 public void testHandleActionResult_isRaiseErrorModalPanel_withActionMessageSizeGreaterThan1() {
   VdcFault testFault = new VdcFault();
   ArrayList<String> translatedErrors =
       new ArrayList<String>(
           Arrays.asList(
               "Translated Message 1", "Translated Message 2")); // $NON-NLS-1$ //$NON-NLS-2$
   when(mockEventsHandler.isRaiseErrorModalPanel(VdcActionType.AddDisk, testFault))
       .thenReturn(true);
   when(mockCanDoActionErrorsTranslator.translateErrorText(any(ArrayList.class)))
       .thenReturn(translatedErrors);
   Object testState = new Object();
   VdcActionParametersBase testParameters = new VdcActionParametersBase();
   VdcReturnValueBase returnValue = new VdcReturnValueBase();
   returnValue.setFault(testFault);
   returnValue.setDescription("This is a description"); // $NON-NLS-1$
   returnValue.getCanDoActionMessages().add("Message 1"); // $NON-NLS-1$
   returnValue.getCanDoActionMessages().add("Message 2"); // $NON-NLS-1$
   returnValue.setCanDoAction(false); // Yes this is the default, but to make sure.
   frontend.handleActionResult(
       VdcActionType.AddDisk, testParameters, returnValue, mockActionCallback, testState, true);
   verify(mockActionCallback).executed(callbackParam.capture());
   assertEquals(
       "Parameters should match",
       testParameters,
       callbackParam.getValue().getParameters()); // $NON-NLS-1$
   assertEquals(
       "Result should match",
       returnValue,
       callbackParam.getValue().getReturnValue()); // $NON-NLS-1$
   assertEquals(
       "States should match", testState, callbackParam.getValue().getState()); // $NON-NLS-1$
   assertEquals(
       "Action type should match",
       VdcActionType.AddDisk, // $NON-NLS-1$
       callbackParam.getValue().getActionType());
   ArgumentCaptor<FrontendFailureEventArgs> failureCaptor =
       ArgumentCaptor.forClass(FrontendFailureEventArgs.class);
   verify(mockFrontendFailureEvent).raise(eq(Frontend.class), failureCaptor.capture());
   assertEquals(
       "Text should match",
       "Translated Message 1", //$NON-NLS-1$ //$NON-NLS-2$
       failureCaptor.getValue().getMessages().get(0).getText());
   assertEquals(
       "Text should match",
       "Translated Message 2", //$NON-NLS-1$ //$NON-NLS-2$
       failureCaptor.getValue().getMessages().get(1).getText());
 }
예제 #3
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a single action
  *   <li>Return logical failure, canDoAction=false.
  *   <li>isRaiseErrorModalPanel returns true.
  *   <li>Check to make sure the failure event is fired
  *   <li>Check to make sure the callback is called
  * </ol>
  *
  * Test just the handler method.
  */
 @Test
 public void testHandleActionResult_isRaiseErrorModalPanel_actionMessageSize_1_or_less() {
   VdcFault testFault = new VdcFault();
   when(mockEventsHandler.isRaiseErrorModalPanel(VdcActionType.AddDisk, testFault))
       .thenReturn(true);
   Object testState = new Object();
   VdcActionParametersBase testParameters = new VdcActionParametersBase();
   VdcReturnValueBase returnValue = new VdcReturnValueBase();
   returnValue.setFault(testFault);
   returnValue.setDescription("This is a description"); // $NON-NLS-1$
   returnValue.setCanDoAction(false); // Yes this is the default, but to make sure.
   frontend.handleActionResult(
       VdcActionType.AddDisk, testParameters, returnValue, mockActionCallback, testState, true);
   verify(mockActionCallback).executed(callbackParam.capture());
   assertEquals(
       "Parameters should match",
       testParameters,
       callbackParam.getValue().getParameters()); // $NON-NLS-1$
   assertEquals(
       "Result should match",
       returnValue,
       callbackParam.getValue().getReturnValue()); // $NON-NLS-1$
   assertEquals(
       "States should match", testState, callbackParam.getValue().getState()); // $NON-NLS-1$
   assertEquals(
       "Action type should match",
       VdcActionType.AddDisk, // $NON-NLS-1$
       callbackParam.getValue().getActionType());
   ArgumentCaptor<FrontendFailureEventArgs> failureCaptor =
       ArgumentCaptor.forClass(FrontendFailureEventArgs.class);
   verify(mockFrontendFailureEvent).raise(eq(Frontend.class), failureCaptor.capture());
   assertEquals(
       "Descriptions should match",
       "This is a description", //$NON-NLS-1$ //$NON-NLS-2$
       failureCaptor.getValue().getMessages().get(0).getDescription());
   assertEquals(
       "Text should match",
       NO_MESSAGE, //$NON-NLS-1$ //$NON-NLS-2$
       failureCaptor.getValue().getMessages().get(0).getText());
 }
예제 #4
0
 /**
  * Run the following test case.
  *
  * <ol>
  *   <li>Run a single action
  *   <li>Return logical failure, canDoAction=false.
  *   <li>Check to make sure the failure event is fired
  *   <li>Check to make sure the callback is called
  * </ol>
  *
  * Test just the handler method.
  */
 @Test
 public void testHandleActionResult() {
   Object testState = new Object();
   VdcActionParametersBase testParameters = new VdcActionParametersBase();
   VdcReturnValueBase returnValue = new VdcReturnValueBase();
   returnValue.setCanDoAction(false); // Yes this is the default, but to make sure.
   frontend.handleActionResult(
       VdcActionType.AddDisk, testParameters, returnValue, mockActionCallback, testState, false);
   verify(mockActionCallback).executed(callbackParam.capture());
   assertEquals(
       "Parameters should match",
       testParameters,
       callbackParam.getValue().getParameters()); // $NON-NLS-1$
   assertEquals(
       "Result should match",
       returnValue,
       callbackParam.getValue().getReturnValue()); // $NON-NLS-1$
   assertEquals(
       "States should match", testState, callbackParam.getValue().getState()); // $NON-NLS-1$
   assertEquals(
       "Action type should match",
       VdcActionType.AddDisk, // $NON-NLS-1$
       callbackParam.getValue().getActionType());
 }