Search in sources :

Example 16 with Command

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

the class WorkItemDefinitionMetadataRegistryTest method testLoad.

@Test
@SuppressWarnings("unchecked")
public void testLoad() {
    Path path = mock(Path.class);
    Metadata metadata = mock(Metadata.class);
    Command callback = mock(Command.class);
    when(metadata.getRoot()).thenReturn(path);
    tested.load(metadata, callback);
    verify(workItemsByPathSupplier, times(1)).accept(eq(path), any(Consumer.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) Consumer(java.util.function.Consumer) BiConsumer(java.util.function.BiConsumer) Command(org.uberfire.mvp.Command) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 17 with Command

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

the class MetadataWidget method onForceUnlock.

@UiHandler("unlock")
public void onForceUnlock(ClickEvent e) {
    final YesNoCancelPopup yesNoCancelPopup = YesNoCancelPopup.newYesNoCancelPopup(MetadataConstants.INSTANCE.ForceUnlockConfirmationTitle(), MetadataConstants.INSTANCE.ForceUnlockConfirmationText(metadata.getLockInfo().lockedBy()), new Command() {

        @Override
        public void execute() {
            forceUnlockHandler.run();
            unlock.setEnabled(false);
        }
    }, new Command() {

        @Override
        public void execute() {
        }
    }, null);
    yesNoCancelPopup.setClosable(false);
    yesNoCancelPopup.show();
}
Also used : Command(org.uberfire.mvp.Command) YesNoCancelPopup(org.uberfire.ext.widgets.common.client.common.popups.YesNoCancelPopup) UiHandler(com.google.gwt.uibinder.client.UiHandler)

Example 18 with Command

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

the class KieEditorTest method testAddRenameWhenSaveAndRenameIsEnabled.

@Test
public void testAddRenameWhenSaveAndRenameIsEnabled() {
    final Caller saveAndRenameCaller = mock(Caller.class);
    final Command command = mock(Command.class);
    doReturn(saveAndRenameCaller).when(presenter).getSaveAndRenameServiceCaller();
    doReturn(command).when(presenter).getSaveAndRename();
    presenter.addRename(fileMenuBuilder);
    verify(fileMenuBuilder).addRename(command);
}
Also used : Caller(org.jboss.errai.common.client.api.Caller) Command(org.uberfire.mvp.Command) Test(org.junit.Test)

Example 19 with Command

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

the class KieEditorTest method testAddSave.

@Test
public void testAddSave() {
    final MenuItem menuItem = mock(MenuItem.class);
    final Command command = mock(Command.class);
    doReturn(command).when(presenter).getSaveActionCommand();
    doReturn(menuItem).when(versionRecordManager).newSaveMenuItem(command);
    presenter.addSave(fileMenuBuilder);
    verify(fileMenuBuilder).addSave(menuItem);
}
Also used : Command(org.uberfire.mvp.Command) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Example 20 with Command

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

the class KieMultipleDocumentEditorTest method testDeleteCommand.

@Test
public void testDeleteCommand() {
    final TestDocument document = createTestDocument();
    final ObservablePath path = document.getLatestPath();
    editor.setupMenuBar();
    registerDocument(document);
    final ArgumentCaptor<Command> deleteCommandCaptor = ArgumentCaptor.forClass(Command.class);
    verify(path, times(1)).onDelete(deleteCommandCaptor.capture());
    final Command deleteCommand = deleteCommandCaptor.getValue();
    assertNotNull(deleteCommand);
    deleteCommand.execute();
    verify(editor, times(1)).enableMenus(eq(false));
    verify(editor, times(4)).enableMenuItem(eq(false), any(MenuItems.class));
    verify(saveMenuItem, times(1)).setEnabled(eq(false));
    verify(versionManagerMenuItem, times(1)).setEnabled(eq(false));
    verify(editor, times(1)).removeDocument(eq(document));
    verify(registeredDocumentsMenuBuilder, times(1)).deregisterDocument(document);
}
Also used : ParameterizedCommand(org.uberfire.mvp.ParameterizedCommand) Command(org.uberfire.mvp.Command) MenuItems(org.uberfire.ext.editor.commons.client.menu.MenuItems) ObservablePath(org.uberfire.backend.vfs.ObservablePath) 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