Search in sources :

Example 1 with Callback

use of org.uberfire.client.callbacks.Callback in project kie-wb-common by kiegroup.

the class PipelineParamsPagePresenterTest method testIsComplete.

@Test
public void testIsComplete() {
    presenter.setPipelineParamsForm(paramsForm);
    Callback callback = mock(Callback.class);
    presenter.isComplete(callback);
    verify(paramsForm, times(1)).isComplete(callback);
}
Also used : Callback(org.uberfire.client.callbacks.Callback) Test(org.junit.Test)

Example 2 with Callback

use of org.uberfire.client.callbacks.Callback in project kie-wb-common by kiegroup.

the class KieMultipleDocumentEditorTest method testOpenDocumentInEditor_OneDocumentNotAlreadyRegistered.

@Test
@SuppressWarnings("unchecked")
public void testOpenDocumentInEditor_OneDocumentNotAlreadyRegistered() {
    // Mock two documents being available, one is already registered; the other is not.
    final TestDocument document = createTestDocument();
    final ObservablePath currentPath = document.getCurrentPath();
    registerDocument(document);
    final Path newDocumentPath = mock(Path.class);
    doAnswer((invocation) -> {
        final Callback<List<Path>> callback = (Callback) invocation.getArguments()[0];
        callback.callback(new ArrayList<Path>() {

            {
                add(currentPath);
                add(newDocumentPath);
            }
        });
        return null;
    }).when(editor).getAvailableDocumentPaths(any(Callback.class));
    editor.openDocumentInEditor();
    final ArgumentCaptor<List> pathsArgumentCaptor = ArgumentCaptor.forClass(List.class);
    verify(kieEditorWrapperView, times(1)).showAdditionalDocuments(pathsArgumentCaptor.capture());
    final List<Path> paths = pathsArgumentCaptor.getValue();
    assertNotNull(paths);
    assertEquals(1, paths.size());
    assertEquals(newDocumentPath, paths.get(0));
}
Also used : Path(org.uberfire.backend.vfs.Path) ObservablePath(org.uberfire.backend.vfs.ObservablePath) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Callback(org.uberfire.client.callbacks.Callback) ArrayList(java.util.ArrayList) List(java.util.List) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 3 with Callback

use of org.uberfire.client.callbacks.Callback in project kie-wb-common by kiegroup.

the class KieMultipleDocumentEditorTest method testOpenDocumentInEditor_OneDocumentAlreadyRegistered.

@Test
@SuppressWarnings("unchecked")
public void testOpenDocumentInEditor_OneDocumentAlreadyRegistered() {
    // Mock one document being available, but it's the same as already registered.
    final TestDocument document = createTestDocument();
    final ObservablePath currentPath = document.getCurrentPath();
    registerDocument(document);
    doAnswer((invocation) -> {
        final Callback<List<Path>> callback = (Callback) invocation.getArguments()[0];
        callback.callback(new ArrayList<Path>() {

            {
                add(currentPath);
            }
        });
        return null;
    }).when(editor).getAvailableDocumentPaths(any(Callback.class));
    editor.openDocumentInEditor();
    verify(kieEditorWrapperView, times(1)).showNoAdditionalDocuments();
    verify(kieEditorWrapperView, never()).showAdditionalDocuments(any(List.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) ObservablePath(org.uberfire.backend.vfs.ObservablePath) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) Callback(org.uberfire.client.callbacks.Callback) ArrayList(java.util.ArrayList) List(java.util.List) ObservablePath(org.uberfire.backend.vfs.ObservablePath) Test(org.junit.Test)

Example 4 with Callback

use of org.uberfire.client.callbacks.Callback in project kie-wb-common by kiegroup.

the class ExternalLinkPresenterTest method edit.

@Test
public void edit() throws Exception {
    final Callback callback = mock(Callback.class);
    presenter.addChangeCallback(callback);
    presenter.onTextChange("hello");
    verify(callback).callback("hello");
}
Also used : Callback(org.uberfire.client.callbacks.Callback) Test(org.junit.Test)

Example 5 with Callback

use of org.uberfire.client.callbacks.Callback in project drools-wb by kiegroup.

the class BaseEnumSingleSelectUiColumnTest method setupEnums.

@SuppressWarnings("unchecked")
private void setupEnums(final String cellValue, final String... values) {
    final Map<String, String> enums = new HashMap<>();
    for (String value : values) {
        enums.put(value, value);
    }
    doAnswer((InvocationOnMock invocation) -> {
        final Callback<Map<String, String>> callback = (Callback<Map<String, String>>) invocation.getArguments()[3];
        callback.callback(enums);
        return null;
    }).when(presenter).getEnumLookups(anyString(), anyString(), any(DependentEnumsUtilities.Context.class), any(Callback.class));
    when(multiValueFactory.convert(eq(cellValue))).thenReturn(cellValue);
}
Also used : GridBodyCellRenderContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellRenderContext) Callback(org.uberfire.client.callbacks.Callback) HashMap(com.google.gwt.dev.util.collect.HashMap) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Mockito.anyString(org.mockito.Mockito.anyString) HashMap(com.google.gwt.dev.util.collect.HashMap) Map(java.util.Map)

Aggregations

Callback (org.uberfire.client.callbacks.Callback)26 Test (org.junit.Test)17 Map (java.util.Map)5 List (java.util.List)4 Path (org.uberfire.backend.vfs.Path)4 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)3 GuidedDecisionTablePresenter (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTablePresenter)3 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)3 Caller (org.jboss.errai.common.client.api.Caller)3 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)3 Assert.assertEquals (org.junit.Assert.assertEquals)3 Assert.assertFalse (org.junit.Assert.assertFalse)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 Before (org.junit.Before)3 RunWith (org.junit.runner.RunWith)3 DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)3 EnumDropdownService (org.kie.workbench.common.services.shared.enums.EnumDropdownService)3 Mock (org.mockito.Mock)3 Mockito.any (org.mockito.Mockito.any)3