Search in sources :

Example 6 with Repository

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);
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Test(org.junit.Test)

Example 7 with Repository

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;
    }
}
Also used : Repository(org.guvnor.structure.repositories.Repository)

Example 8 with Repository

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;
}
Also used : Repository(org.guvnor.structure.repositories.Repository) ArrayList(java.util.ArrayList)

Example 9 with Repository

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));
}
Also used : Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Example 10 with Repository

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();
}
Also used : Space(org.uberfire.spaces.Space) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Aggregations

Repository (org.guvnor.structure.repositories.Repository)51 Test (org.junit.Test)25 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)21 Branch (org.guvnor.structure.repositories.Branch)21 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)20 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)15 Module (org.guvnor.common.services.project.model.Module)14 ArrayList (java.util.ArrayList)13 Path (org.uberfire.backend.vfs.Path)13 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)10 POM (org.guvnor.common.services.project.model.POM)7 KieModule (org.kie.workbench.common.services.shared.project.KieModule)7 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)5 HashMap (java.util.HashMap)4 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)4 Before (org.junit.Before)4 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)3 RepositoryEnvironmentConfigurations (org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations)3 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)3 Space (org.uberfire.spaces.Space)3