use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryToolbarPresenterTest method selectorVisibleWhenMoreThanOneBranch.
@Test
public void selectorVisibleWhenMoreThanOneBranch() throws Exception {
final Repository repository = mock(Repository.class);
final ArrayList<Branch> branches = new ArrayList<>();
branches.add(new Branch());
branches.add(new Branch());
doReturn(branches).when(repository).getBranches();
doReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(KieModule.class)))).when(projectContext).getActiveWorkspaceProject();
presenter.setUpBranches();
verify(view).clearBranches();
verify(view).setBranchSelectorVisibility(true);
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraint method hasRestrictions.
@Override
public boolean hasRestrictions(final SocialActivitiesEvent event) {
try {
if (!userCDIContextHelper.thereIsALoggedUserInScope()) {
return false;
}
if (event.isVFSLink() || isAModuleEvent(event)) {
final boolean isRepositoryRestricted = delegate.hasRestrictions(event);
if (isRepositoryRestricted) {
return true;
}
final WorkspaceProject project = getEventModule(event);
if (thereIsAProjectAssociatedWithThisEvent(project)) {
return !authorizationManager.authorize(project.getRepository(), userCDIContextHelper.getUser());
} else {
return false;
}
} else {
return false;
}
} catch (Exception e) {
return true;
}
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class SocialEventModuleConstraintTest method hasRestrictionsTest.
@Test
public void hasRestrictionsTest() throws Exception {
final WorkspaceProject project = mock(WorkspaceProject.class);
Repository repository = mock(Repository.class);
doReturn(repository).when(project).getRepository();
when(authorizationManager.authorize(repository, user)).thenReturn(false);
eventProject = project;
final SocialActivitiesEvent event = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.VFS);
socialEventModuleConstraint.init();
assertTrue(socialEventModuleConstraint.hasRestrictions(event));
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class ProjectExplorerContentResolverTest method createModule.
private Module createModule(final String branchName, final Branch branch, final String moduleName) {
final POM pom = mock(POM.class);
when(pom.getName()).thenReturn(moduleName);
final Module module = new Module(createMockPath(branchName, moduleName), createMockPath(branchName, moduleName), pom);
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn("demo").when(organizationalUnit).getName();
doReturn(new WorkspaceProject(organizationalUnit, repository, branch, module)).when(projectService).resolveProject(space, branch);
return module;
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class ExplorerMenuTest method testOnArchiveActiveRepo.
@Test
public void testOnArchiveActiveRepo() throws Exception {
final Path rootRepoPath = mock(Path.class);
final Repository repository = mock(Repository.class);
when(repository.getDefaultBranch()).thenReturn(Optional.of(new Branch("master", rootRepoPath)));
final WorkspaceProject project = mock(WorkspaceProject.class);
when(project.getRepository()).thenReturn(repository);
when(context.getActiveWorkspaceProject()).thenReturn(Optional.of(project));
menu.onArchiveActiveRepository();
verify(view).archive(rootRepoPath);
}
Aggregations