Search in sources :

Example 1 with AddProjectButtonPresenter

use of org.kie.workbench.common.screens.library.client.widgets.library.AddProjectButtonPresenter in project kie-wb-common by kiegroup.

the class PopulatedLibraryScreenTest method setup.

@Before
public void setup() {
    libraryServiceCaller = new CallerMock<>(libraryService);
    libraryScreen = spy(new PopulatedLibraryScreen(view, libraryPlaces, libraryServiceCaller, projectController, projectContext, tileWidgets, addProjectButtonPresenter, projectCountUpdateEvent));
    doReturn(true).when(projectController).canCreateProjects(any());
    project1 = mockProject(PROJECT_1);
    project2 = mockProject(PROJECT_2);
    project3 = mockProject(PROJECT_3);
    final List<WorkspaceProject> projects = new ArrayList<>();
    projects.add(project1);
    projects.add(project2);
    projects.add(project3);
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
    final LibraryInfo libraryInfo = new LibraryInfo(projects);
    doReturn(libraryInfo).when(libraryService).getLibraryInfo(organizationalUnit);
    doReturn(mock(TileWidget.View.class)).when(tileWidget).getView();
    when(tileWidgets.get()).thenAnswer((Answer<TileWidget<WorkspaceProject>>) invocationOnMock -> {
        TileWidget tile = mock(TileWidget.class);
        doReturn(mock(TileWidget.View.class)).when(tile).getView();
        doAnswer((Answer<Void>) invocationOnMock1 -> {
            when(tile.getContent()).thenReturn(invocationOnMock1.getArgument(0, WorkspaceProject.class));
            return null;
        }).when(tile).setContent(any());
        return tile;
    });
    doReturn(mock(AddProjectButtonPresenter.View.class)).when(addProjectButtonPresenter).getView();
    libraryScreen.setup();
}
Also used : TileWidget(org.kie.workbench.common.screens.library.client.widgets.common.TileWidget) CallerMock(org.uberfire.mocks.CallerMock) Space(org.uberfire.spaces.Space) Mock(org.mockito.Mock) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) RunWith(org.junit.runner.RunWith) ProjectAssetListUpdated(org.kie.workbench.common.screens.library.api.ProjectAssetListUpdated) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Module(org.guvnor.common.services.project.model.Module) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) NewProjectEvent(org.guvnor.common.services.project.events.NewProjectEvent) Repository(org.guvnor.structure.repositories.Repository) Answers(org.mockito.Answers) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) Mockito.verify(org.mockito.Mockito.verify) RepositoryRemovedEvent(org.guvnor.structure.repositories.RepositoryRemovedEvent) List(java.util.List) Mockito.never(org.mockito.Mockito.never) Caller(org.jboss.errai.common.client.api.Caller) ProjectController(org.guvnor.common.services.project.client.security.ProjectController) AddProjectButtonPresenter(org.kie.workbench.common.screens.library.client.widgets.library.AddProjectButtonPresenter) Optional(java.util.Optional) Mockito.anyInt(org.mockito.Mockito.anyInt) Assert(org.junit.Assert) Mockito.any(org.mockito.Mockito.any) ProjectCountUpdate(org.kie.workbench.common.screens.library.api.ProjectCountUpdate) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.eq(org.mockito.Mockito.eq) Mockito.mock(org.mockito.Mockito.mock) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) TileWidget(org.kie.workbench.common.screens.library.client.widgets.common.TileWidget) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Event (javax.enterprise.event.Event)1 WorkspaceProjectContext (org.guvnor.common.services.project.client.context.WorkspaceProjectContext)1 ProjectController (org.guvnor.common.services.project.client.security.ProjectController)1 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)1 Module (org.guvnor.common.services.project.model.Module)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 Repository (org.guvnor.structure.repositories.Repository)1 RepositoryRemovedEvent (org.guvnor.structure.repositories.RepositoryRemovedEvent)1 Caller (org.jboss.errai.common.client.api.Caller)1 ManagedInstance (org.jboss.errai.ioc.client.api.ManagedInstance)1 Assert (org.junit.Assert)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RunWith (org.junit.runner.RunWith)1 LibraryInfo (org.kie.workbench.common.screens.library.api.LibraryInfo)1