Ejemplo n.º 1
0
  @Test
  public void testAddButtonClicked() {
    ToolAdminViewImpl spy = spy(uut);

    SelectEvent mockEvent = mock(SelectEvent.class);

    /** CALL METHOD UNDER TEST * */
    spy.addButtonClicked(mockEvent);
    verify(toolDetailsDialogMock).get(asyncCallbackDialogCaptor.capture());

    AsyncCallback<ToolAdminDetailsDialog> asyncCallback = asyncCallbackDialogCaptor.getValue();
    ToolAdminDetailsDialog resultMock = mock(ToolAdminDetailsDialog.class);

    /** CALL METHOD UNDER TEST * */
    asyncCallback.onSuccess(resultMock);
    verify(resultMock).show();
    verify(resultMock)
        .addSaveToolSelectedEventHandler(saveToolSelectedEventHandlerArgumentCaptor.capture());

    SaveToolSelectedEvent.SaveToolSelectedEventHandler saveHandlerMock =
        saveToolSelectedEventHandlerArgumentCaptor.getValue();
    SaveToolSelectedEvent saveEventMock = mock(SaveToolSelectedEvent.class);

    /** CALL METHOD UNDER TEST * */
    saveHandlerMock.onSaveToolSelected(saveEventMock);

    verify(spy).fireEvent(isA(AddToolSelectedEvent.class));
    verify(resultMock).hide();
  }
Ejemplo n.º 2
0
  @Test
  public void testEditToolDetails_saveEvent() {

    ToolAdminViewImpl spy = spy(uut);

    /** CALL METHOD UNDER TEST * */
    spy.editToolDetails(toolMock);
    verify(toolDetailsDialogMock).get(asyncCallbackDialogCaptor.capture());

    AsyncCallback<ToolAdminDetailsDialog> asyncCallback = asyncCallbackDialogCaptor.getValue();
    ToolAdminDetailsDialog resultMock = mock(ToolAdminDetailsDialog.class);

    /** CALL METHOD UNDER TEST * */
    asyncCallback.onSuccess(resultMock);
    verify(resultMock).show(eq(toolMock));
    verify(resultMock)
        .addSaveToolSelectedEventHandler(saveToolSelectedEventHandlerArgumentCaptor.capture());

    SaveToolSelectedEvent.SaveToolSelectedEventHandler saveHandlerMock =
        saveToolSelectedEventHandlerArgumentCaptor.getValue();
    SaveToolSelectedEvent saveEventMock = mock(SaveToolSelectedEvent.class);

    /** CALL METHOD UNDER TEST * */
    saveHandlerMock.onSaveToolSelected(saveEventMock);

    verify(spy).fireEvent(isA(SaveToolSelectedEvent.class));
    verify(resultMock).hide();
    verify(toolGridMock.getSelectionModel()).deselect(eq(toolMock));
  }