Search in sources :

Example 21 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method createProjectFromBaseKieTemplateWithRemoteUrlTest.

@Test
public void createProjectFromBaseKieTemplateWithRemoteUrlTest() {
    final String remoteRepositoryUrl = "myRemoteUrl";
    final List<Contributor> spaceContributors = new ArrayList<>();
    spaceContributors.add(new Contributor("user1", ContributorType.OWNER));
    spaceContributors.add(new Contributor("user2", ContributorType.ADMIN));
    spaceContributors.add(new Contributor("admin", ContributorType.CONTRIBUTOR));
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn("ou").when(organizationalUnit).getName();
    doReturn("org.ou").when(organizationalUnit).getDefaultGroupId();
    doReturn(spaceContributors).when(organizationalUnit).getContributors();
    doReturn(organizationalUnit).when(ouService).getOrganizationalUnit("ou");
    final Repository kieBaseTemplate = mock(Repository.class);
    doReturn(Optional.of(kieBaseTemplate)).when(archetypeService).getBaseKieTemplateRepository();
    final Archetype baseKieArchetype = mock(Archetype.class);
    doReturn(Optional.of(baseKieArchetype)).when(archetypeService).getBaseKieArchetype();
    libraryService.createProject(organizationalUnit, remoteRepositoryUrl, "myRemoteRepository");
    final List<Contributor> projectContributors = new ArrayList<>();
    projectContributors.add(new Contributor("user1", ContributorType.OWNER));
    projectContributors.add(new Contributor("user2", ContributorType.ADMIN));
    projectContributors.add(new Contributor("admin", ContributorType.OWNER));
    verify(archetypeService).getBaseKieArchetype();
    verify(projectService).newProject(eq(organizationalUnit), any(POM.class), eq(DeploymentMode.VALIDATED), eq(projectContributors), eq(kieBaseTemplate), eq(remoteRepositoryUrl));
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Archetype(org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype) ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 22 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class SpacesScreenServiceImpl method getContributors.

private List<Contributor> getContributors() {
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor(sessionInfo.getIdentity().getIdentifier(), ContributorType.OWNER));
    return contributors;
}
Also used : ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor)

Example 23 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class SpacesScreenServiceImplTest method testSaveSpace.

@Test
public void testSaveSpace() {
    final SpacesScreenService.NewSpace space = new SpacesScreenService.NewSpace() {

        {
            name = "test";
            groupId = "com.test";
            description = "Test space";
        }
    };
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor(sessionInfo.getIdentity().getIdentifier(), ContributorType.OWNER));
    assertEquals(201, spacesScreenService.postSpace(space).getStatus());
    verify(organizationalUnitService).createOrganizationalUnit("test", "com.test", new ArrayList<>(), contributors, "Test space");
}
Also used : ArrayList(java.util.ArrayList) SpacesScreenService(org.kie.workbench.common.screens.library.api.SpacesScreenService) Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 24 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class SpaceContributorsListServiceImplTest method getContributorsTest.

@Test
public void getContributorsTest() {
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor("owner", ContributorType.OWNER));
    contributors.add(new Contributor("contributor", ContributorType.CONTRIBUTOR));
    contributors.add(new Contributor("admin", ContributorType.ADMIN));
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn(contributors).when(organizationalUnit).getContributors();
    doReturn(organizationalUnit).when(organizationalUnitService).getOrganizationalUnit(Mockito.<String>any());
    service.getContributors(repositoryContributors -> {
        assertEquals(3, repositoryContributors.size());
    });
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Example 25 with Contributor

use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.

the class SpaceContributorsListServiceImplTest method ownerCanEditContributors.

@Test
public void ownerCanEditContributors() {
    doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(any());
    final List<Contributor> contributors = new ArrayList<>();
    contributors.add(new Contributor("owner", ContributorType.OWNER));
    service.canEditContributors(contributors, ContributorType.OWNER).then(canEditContributors -> {
        assertTrue(canEditContributors);
        return promises.resolve();
    });
    service.canEditContributors(contributors, ContributorType.ADMIN).then(canEditContributors -> {
        assertTrue(canEditContributors);
        return promises.resolve();
    });
    service.canEditContributors(contributors, ContributorType.CONTRIBUTOR).then(canEditContributors -> {
        assertTrue(canEditContributors);
        return promises.resolve();
    });
}
Also used : ArrayList(java.util.ArrayList) Contributor(org.uberfire.security.Contributor) Test(org.junit.Test)

Aggregations

Contributor (org.uberfire.security.Contributor)31 ArrayList (java.util.ArrayList)25 Test (org.junit.Test)22 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)11 Repository (org.guvnor.structure.repositories.Repository)8 POM (org.guvnor.common.services.project.model.POM)6 Consumer (java.util.function.Consumer)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)4 List (java.util.List)3 Branch (org.guvnor.structure.repositories.Branch)3 Before (org.junit.Before)3 Collections (java.util.Collections)2 Map (java.util.Map)2 Module (org.guvnor.common.services.project.model.Module)2 BranchPermissions (org.guvnor.structure.organizationalunit.config.BranchPermissions)2 UnauthorizedException (org.jboss.errai.security.shared.exception.UnauthorizedException)2 Archetype (org.kie.workbench.common.screens.archetype.mgmt.shared.model.Archetype)2 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)2 LibraryPreferences (org.kie.workbench.common.screens.library.api.preferences.LibraryPreferences)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2