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();
}
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();
}
}
}
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());
}
Aggregations