use of org.guvnor.structure.repositories.Repository 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.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class SocialEventRepositoryConstraint method hasRestrictions.
public boolean hasRestrictions(SocialActivitiesEvent event) {
try {
if (!userCDIContextHelper.thereIsALoggedUserInScope()) {
return false;
}
if (event.isVFSLink() || isAModuleEvent(event)) {
Repository repository = getEventRepository(event);
final boolean userHasAccessToRepo = authorizedRepos.contains(repository);
return !userHasAccessToRepo;
} else {
return false;
}
} catch (Exception e) {
return true;
}
}
use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class RepositoryListServiceImpl method getRepositories.
@Override
public List<String> getRepositories() {
List<String> repositoriesName = new ArrayList<String>();
final Collection<Repository> repositories = repositoryConstraint.getAuthorizedRepositories();
for (Repository repository : repositories) {
repositoriesName.add(repository.getAlias());
}
return repositoriesName;
}
use of org.guvnor.structure.repositories.Repository 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.structure.repositories.Repository in project kie-wb-common by kiegroup.
the class SocialEventRepositoryConstraintTest method setUp.
@Before
public void setUp() throws Exception {
Collection<OrganizationalUnit> ous = new ArrayList<OrganizationalUnit>();
final OrganizationalUnitImpl ou = new OrganizationalUnitImpl("ouname", "owner", "groupid");
final OrganizationalUnitImpl ouSpy = spy(ou);
Collection<Repository> repositories = new ArrayList<Repository>();
repository = new GitRepository("repo", new Space("space"));
repositories.add(repository);
ous.add(ouSpy);
when(ouSpy.getRepositories()).thenReturn(repositories);
when(organizationalUnitService.getOrganizationalUnits()).thenReturn(ous);
when(authorizationManager.authorize(ou, user)).thenReturn(true);
when(authorizationManager.authorize(repository, user)).thenReturn(true);
when(userCDIContextHelper.getUser()).thenReturn(user);
when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(true);
socialEventRepositoryConstraint = createSocialEventRepositoryContraint();
}
Aggregations