Search in sources :

Example 1 with LibraryInfo

use of org.kie.workbench.common.screens.library.api.LibraryInfo in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method getLibraryInfoTest.

@Test
public void getLibraryInfoTest() {
    final Path path = mockPath("file://the_project");
    final WorkspaceProject project = mock(WorkspaceProject.class);
    when(project.getRootPath()).thenReturn(path);
    doReturn(true).when(ioService).exists(any());
    final Set<WorkspaceProject> projects = new HashSet<>();
    projects.add(project);
    doReturn(projects).when(projectService).getAllWorkspaceProjects(ou1);
    final LibraryInfo libraryInfo = libraryService.getLibraryInfo(ou1);
    assertEquals(new HashSet<>(projects), libraryInfo.getProjects());
}
Also used : Path(org.uberfire.backend.vfs.Path) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with LibraryInfo

use of org.kie.workbench.common.screens.library.api.LibraryInfo 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, projectDetailEvent, libraryServiceCaller, projectController, projectContext, tileWidgets, addProjectButtonPresenter));
    doReturn(true).when(projectController).canCreateProjects();
    project1 = mockProject("project1Name");
    project2 = mockProject("project2Name");
    project3 = mockProject("project3Name");
    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();
    doReturn(tileWidget).when(tileWidgets).get();
    doReturn(mock(AddProjectButtonPresenter.View.class)).when(addProjectButtonPresenter).getView();
    libraryScreen.setup();
}
Also used : LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 3 with LibraryInfo

use of org.kie.workbench.common.screens.library.api.LibraryInfo in project kie-wb-common by kiegroup.

the class AddProjectPopUpPresenterTest method setup.

@Before
public void setup() {
    libraryServiceCaller = new CallerMock<>(libraryService);
    validationServiceCaller = new CallerMock<>(validationService);
    sessionInfo = new SessionInfoMock();
    selectedOrganizationalUnit = mock(OrganizationalUnit.class);
    doReturn("selectedOrganizationalUnit").when(selectedOrganizationalUnit).getIdentifier();
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(selectedOrganizationalUnit));
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
    presenter = spy(new AddProjectPopUpPresenter(libraryServiceCaller, busyIndicatorView, notificationEvent, libraryPlaces, projectContext, view, sessionInfo, newProjectEvent, libraryPreferences, conflictingRepositoriesPopup, validationServiceCaller));
    doReturn("baseUrl").when(presenter).getBaseURL();
    doReturn("emptyNameMessage").when(view).getEmptyNameMessage();
    doReturn("invalidNameMessage").when(view).getInvalidNameMessage();
    doReturn("duplicatedProjectMessage").when(view).getDuplicatedProjectMessage();
    libraryInfo = new LibraryInfo(new ArrayList<>());
    doReturn(libraryInfo).when(libraryService).getLibraryInfo(selectedOrganizationalUnit);
    doReturn(true).when(validationService).isProjectNameValid(any());
    doReturn(true).when(validationService).validateGroupId(any());
    doReturn(true).when(validationService).validateArtifactId(any());
    doReturn(true).when(validationService).validateGAVVersion(any());
    presenter.setup();
}
Also used : SessionInfoMock(org.uberfire.mocks.SessionInfoMock) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Aggregations

LibraryInfo (org.kie.workbench.common.screens.library.api.LibraryInfo)3 ArrayList (java.util.ArrayList)2 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)2 Before (org.junit.Before)2 HashSet (java.util.HashSet)1 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)1 Test (org.junit.Test)1 Path (org.uberfire.backend.vfs.Path)1 SessionInfoMock (org.uberfire.mocks.SessionInfoMock)1