Search in sources :

Example 6 with Callback

use of com.google.gwt.core.client.Callback in project kie-wb-common by kiegroup.

the class NewResourcesMenuTest method testOnWorkspaceProjectContextChangedEnabled.

@Test
@SuppressWarnings("unchecked")
public void testOnWorkspaceProjectContextChangedEnabled() {
    doAnswer(new Answer() {

        @Override
        public Object answer(final InvocationOnMock invocation) {
            final Object[] args = invocation.getArguments();
            final Callback callback = (Callback) args[0];
            callback.onSuccess(true);
            return null;
        }
    }).when(handler).acceptContext(any(Callback.class));
    // Arguments aren't actually used
    menu.onChange(null, null);
    verify(handler, times(1)).acceptContext(any(Callback.class));
    final List<MenuItem> menus = menu.getMenuItems();
    verify(handler, times(2)).acceptContext(any(Callback.class));
    final MenuItem mi = menus.get(0);
    assertTrue(mi.isEnabled());
}
Also used : Answer(org.mockito.stubbing.Answer) Callback(com.google.gwt.core.client.Callback) InvocationOnMock(org.mockito.invocation.InvocationOnMock) MenuItem(org.uberfire.workbench.model.menu.MenuItem) Test(org.junit.Test)

Aggregations

Callback (com.google.gwt.core.client.Callback)6 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)2 Test (org.junit.Test)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 MenuItem (org.uberfire.workbench.model.menu.MenuItem)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Sets (com.google.common.collect.Sets)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Singleton (com.google.inject.Singleton)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 HandlerRegistration (com.google.web.bindery.event.shared.HandlerRegistration)1 ArrayList (java.util.ArrayList)1 Arrays.binarySearch (java.util.Arrays.binarySearch)1 Arrays.copyOf (java.util.Arrays.copyOf)1 Arrays.sort (java.util.Arrays.sort)1 HashMap (java.util.HashMap)1