Search in sources :

Example 86 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class KSessionSelectorTest method onSelectionChange.

@Test
public void onSelectionChange() {
    Command command = mock(Command.class);
    selector.setSelectionChangeHandler(command);
    selector.onSelectionChange();
    verify(command, times(1)).execute();
}
Also used : Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 87 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class KieEditorTest method testAddCommonActions.

@Test
public void testAddCommonActions() {
    final Command onValidate = mock(Command.class);
    final MenuItem buildMenu = mock(MenuItem.class);
    final MenuItem build = mock(MenuItem.class);
    doReturn(onValidate).when(presenter).onValidate();
    doReturn(buildMenu).when(versionRecordManager).buildMenu();
    doReturn(build).when(alertsButtonMenuItemBuilder).build();
    presenter.addCommonActions(fileMenuBuilder);
    verify(fileMenuBuilder).addValidate(onValidate);
    verify(fileMenuBuilder).addNewTopLevelMenu(buildMenu);
    verify(fileMenuBuilder).addNewTopLevelMenu(build);
}
Also used : Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Example 88 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class KieMultipleDocumentEditorTest method testSave.

@Test
public void testSave() {
    doReturn(Optional.of(mock(WorkspaceProject.class))).when(workbenchContext).getActiveWorkspaceProject();
    doReturn(true).when(projectController).canUpdateProject(any());
    final TestDocument document = createTestDocument();
    registerDocument(document);
    activateDocument(document);
    editor.getSaveMenuItem();
    final ArgumentCaptor<Command> saveCommandCaptor = ArgumentCaptor.forClass(Command.class);
    verify(versionRecordManager, times(1)).newSaveMenuItem(saveCommandCaptor.capture());
    final Command saveCommand = saveCommandCaptor.getValue();
    assertNotNull(saveCommand);
    saveCommand.execute();
    verify(editorView, times(1)).showSaving();
    verify(editor, times(1)).doSave(eq(document));
    verify(editor, times(1)).doSaveCheckForAndHandleConcurrentUpdate(eq(document));
    verify(editor, times(1)).onSave(eq(document), eq("commit"));
    verify(document, times(1)).setConcurrentUpdateSessionInfo(eq(null));
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 89 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class KieMultipleDocumentEditorTest method testRenameCommand.

@Test
public void testRenameCommand() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    registerDocument(document);
    final ArgumentCaptor<Command> renameCommandCaptor = ArgumentCaptor.forClass(Command.class);
    verify(path, times(1)).onRename(renameCommandCaptor.capture());
    final Command renameCommand = renameCommandCaptor.getValue();
    assertNotNull(renameCommand);
    renameCommand.execute();
    verify(editorView, times(2)).refreshTitle(any(String.class));
    verify(editorView, times(1)).showBusyIndicator(any(String.class));
    verify(editor, times(2)).getDocumentTitle(eq(document));
    verify(editor, times(1)).refreshDocument(eq(document));
    verify(changeTitleEvent, times(1)).fire(any(ChangeTitleWidgetEvent.class));
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) ObservablePath(org.uberfire.backend.vfs.ObservablePath) ChangeTitleWidgetEvent(org.uberfire.client.workbench.events.ChangeTitleWidgetEvent) Test(org.junit.Test)

Example 90 with Command

use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.

the class RegisteredDocumentsMenuBuilderTest method testRegisterDocument.

@Test
public void testRegisterDocument() {
    final KieDocument document = makeKieDocument();
    builder.registerDocument(document);
    verify(documentMenuItem, times(1)).setName("filename");
    verify(documentMenuItem, times(1)).setRemoveDocumentCommand(removeDocumentCommandCaptor.capture());
    verify(documentMenuItem, times(1)).setActivateDocumentCommand(activateDocumentCommandCaptor.capture());
    verify(view, times(1)).addDocument(eq(documentMenuItem));
    final Command removeDocumentCommand = removeDocumentCommandCaptor.getValue();
    assertNotNull(removeDocumentCommand);
    removeDocumentCommand.execute();
    verify(builder, times(1)).onRemoveDocument(document);
    final Command activateDocumentCommand = activateDocumentCommandCaptor.getValue();
    assertNotNull(activateDocumentCommand);
    activateDocumentCommand.execute();
    verify(builder, times(1)).onActivateDocument(document);
}
Also used : KieDocument(org.kie.workbench.common.widgets.metadata.client.KieDocument) ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Aggregations

Command (org.uberfire.mvp.Command)117 Test (org.junit.Test)66 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)15 ClientSessionCommand (org.kie.workbench.common.stunner.core.client.session.command.ClientSessionCommand)11 Group (com.ait.lienzo.client.core.shape.Group)9 YesNoCancelPopup (org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup)9 Before (org.junit.Before)8 HasListSelectorControl (org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl)7 Path (org.uberfire.backend.vfs.Path)7 ArrayList (java.util.ArrayList)6 Collection (java.util.Collection)6 PlaceRequest (org.uberfire.mvp.PlaceRequest)5 MenuItem (org.uberfire.workbench.model.menu.MenuItem)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)4 Inject (javax.inject.Inject)4 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)4 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)4 DeleteHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.DeleteHeaderValueCommand)4 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)4 SetHeaderValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetHeaderValueCommand)4