Search in sources :

Example 1 with NewWorkspaceProjectHandler

use of org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler in project kie-wb-common by kiegroup.

the class AddProjectButtonPresenterTest method testAddNewProjectHandler.

@Test
public void testAddNewProjectHandler() {
    doAnswer(invocation -> {
        ((Command) invocation.getArguments()[1]).execute();
        return null;
    }).when(menuResourceHandlerWidget).init(any(), any());
    doAnswer(invocation -> {
        ((Command) invocation.getArguments()[0]).execute();
        return null;
    }).when(libraryPlaces).closeAllPlacesOrNothing(any());
    final NewWorkspaceProjectHandler projectHandler = mock(NewWorkspaceProjectHandler.class);
    final Command command = mock(Command.class);
    when(projectHandler.getCommand(any())).thenReturn(command);
    presenter.addNewProjectHandler(projectHandler);
    verify(projectHandler).setOpenEditorOnCreation(false);
    verify(projectHandler).setCreationSuccessCallback(any());
    verify(command).execute();
}
Also used : Command(org.uberfire.mvp.Command) NewWorkspaceProjectHandler(org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler) Test(org.junit.Test)

Example 2 with NewWorkspaceProjectHandler

use of org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler in project kie-wb-common by kiegroup.

the class AddProjectButtonPresenter method setupOtherProjects.

private void setupOtherProjects() {
    if (userCanCreateProjects()) {
        boolean hasOtherProjects = false;
        for (NewWorkspaceProjectHandler newWorkspaceProjectHandler : getNewProjectHandlers()) {
            if (!ResourceUtils.isDefaultProjectHandler(newWorkspaceProjectHandler) && newWorkspaceProjectHandler.canCreate()) {
                addNewProjectHandler(newWorkspaceProjectHandler);
                hasOtherProjects = true;
            }
        }
        if (!hasOtherProjects) {
            view.hideOtherProjects();
        }
    }
}
Also used : NewWorkspaceProjectHandler(org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler)

Example 3 with NewWorkspaceProjectHandler

use of org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler in project kie-wb-common by kiegroup.

the class AddProjectButtonPresenterTest method initTest.

@Test
public void initTest() {
    NewWorkspaceProjectHandler otherNewWorkspaceProjectHandler1 = mock(NewWorkspaceProjectHandler.class);
    doReturn(true).when(otherNewWorkspaceProjectHandler1).canCreate();
    NewWorkspaceProjectHandler otherNewWorkspaceProjectHandler2 = mock(NewWorkspaceProjectHandler.class);
    doReturn(false).when(otherNewWorkspaceProjectHandler2).canCreate();
    List<NewResourceHandler> handlers = new ArrayList<>();
    handlers.add(otherNewWorkspaceProjectHandler1);
    handlers.add(otherNewWorkspaceProjectHandler2);
    doReturn(handlers).when(presenter).getNewProjectHandlers();
    presenter.init();
    verify(view, never()).hideOtherProjects();
    verify(presenter).addNewProjectHandler(otherNewWorkspaceProjectHandler1);
    verify(view).addOtherProject(any());
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) ArrayList(java.util.ArrayList) NewWorkspaceProjectHandler(org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler) Test(org.junit.Test)

Aggregations

NewWorkspaceProjectHandler (org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler)3 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 NewResourceHandler (org.kie.workbench.common.widgets.client.handlers.NewResourceHandler)1 Command (org.uberfire.mvp.Command)1