Search in sources :

Example 1 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class SocialEventOUConstraint method getAuthorizedOrganizationUnits.

Collection<OrganizationalUnit> getAuthorizedOrganizationUnits() {
    final Collection<OrganizationalUnit> organizationalUnits = organizationalUnitService.getOrganizationalUnits();
    final Collection<OrganizationalUnit> authorizedOrganizationalUnits = new ArrayList<OrganizationalUnit>();
    for (OrganizationalUnit ou : organizationalUnits) {
        if (authorizationManager.authorize(ou, userCDIContextHelper.getUser())) {
            authorizedOrganizationalUnits.add(ou);
        }
    }
    return authorizedOrganizationalUnits;
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList)

Example 2 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class SocialEventRepositoryConstraint method getAuthorizedOrganizationUnits.

private Collection<OrganizationalUnit> getAuthorizedOrganizationUnits() {
    final Collection<OrganizationalUnit> organizationalUnits = organizationalUnitService.getOrganizationalUnits();
    final Collection<OrganizationalUnit> authorizedOrganizationalUnits = new ArrayList<OrganizationalUnit>();
    for (OrganizationalUnit ou : organizationalUnits) {
        if (authorizationManager.authorize(ou, userCDIContextHelper.getUser())) {
            authorizedOrganizationalUnits.add(ou);
        }
    }
    return authorizedOrganizationalUnits;
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList)

Example 3 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit in project kie-wb-common by kiegroup.

the class SocialEventOUConstraintTest method setUp.

@Before
public void setUp() throws Exception {
    Collection<OrganizationalUnit> ous = new ArrayList<OrganizationalUnit>();
    final OrganizationalUnitImpl ou = new OrganizationalUnitImpl("ouname", "owner", "groupid");
    ous.add(ou);
    when(organizationalUnitService.getOrganizationalUnits()).thenReturn(ous);
    when(authorizationManager.authorize(ou, user)).thenReturn(true);
    when(userCDIContextHelper.getUser()).thenReturn(user);
    when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(true);
    socialEventOUConstraint = new SocialEventOUConstraint(organizationalUnitService, authorizationManager, repositoryService, userCDIContextHelper);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Example 4 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit 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)

Example 5 with OrganizationalUnit

use of org.guvnor.structure.organizationalunit.OrganizationalUnit 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;
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Module(org.guvnor.common.services.project.model.Module) POM(org.guvnor.common.services.project.model.POM)

Aggregations

OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)60 Test (org.junit.Test)33 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)19 ArrayList (java.util.ArrayList)18 Repository (org.guvnor.structure.repositories.Repository)17 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)13 Module (org.guvnor.common.services.project.model.Module)11 POM (org.guvnor.common.services.project.model.POM)10 Branch (org.guvnor.structure.repositories.Branch)10 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)10 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)9 Before (org.junit.Before)8 Path (org.uberfire.backend.vfs.Path)7 OrganizationalUnitImpl (org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl)6 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)6 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 NewProjectEvent (org.guvnor.common.services.project.events.NewProjectEvent)3 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Command (org.uberfire.mvp.Command)3