use of org.kie.workbench.common.screens.library.api.LibraryService 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();
}
use of org.kie.workbench.common.screens.library.api.LibraryService in project kie-wb-common by kiegroup.
the class BranchManagementPresenterTest method setupWithUpdatableBranchesTest.
@Test
public void setupWithUpdatableBranchesTest() {
final Map<String, RolePermissions> permissionsByRole = new HashMap<>();
permissionsByRole.put("CONTRIBUTOR", new RolePermissions("CONTRIBUTOR", true, false, true, true));
doReturn(new BranchPermissions("myBranch", permissionsByRole)).when(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch");
doReturn(promises.resolve(Arrays.asList(new Branch("main", mock(Path.class)), new Branch("myBranch", mock(Path.class))))).when(projectController).getUpdatableBranches(any());
presenter.setup(mock(ProjectScreenModel.class)).then(v -> {
assertEquals("myBranch", presenter.selectedBranch);
verify(view).init(presenter);
verify(view, never()).showEmptyState();
verify(view).setupBranchSelect(any(), any(), any());
verify(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch");
return promises.resolve();
}).catch_(error -> {
fail();
return promises.resolve();
});
}
Aggregations