Search in sources :

Example 6 with OrganizationalUnitImpl

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

the class OrganizationalUnitPopUpPresenterTest method setup.

@Before
public void setup() {
    doReturn(true).when(organizationalUnitController).canReadOrgUnits();
    doReturn(true).when(organizationalUnitController).canReadOrgUnit(any());
    doReturn(true).when(organizationalUnitController).canUpdateOrgUnit(any());
    doReturn(true).when(organizationalUnitController).canCreateOrgUnits();
    doReturn(true).when(organizationalUnitController).canDeleteOrgUnit(any());
    organizationalUnitServiceCaller = new CallerMock<>(organizationalUnitService);
    doReturn(true).when(organizationalUnitService).isValidGroupId(anyString());
    doReturn(null).when(organizationalUnitService).getOrganizationalUnit(anyString());
    doAnswer(invocationOnMock -> new OrganizationalUnitImpl((String) invocationOnMock.getArguments()[0], (String) invocationOnMock.getArguments()[1], (String) invocationOnMock.getArguments()[2])).when(organizationalUnitService).createOrganizationalUnit(anyString(), anyString(), anyString(), any(), any());
    doReturn(mock(ContributorsManagementPresenter.View.class)).when(contributorsManagementPresenter).getView();
    presenter = spy(new OrganizationalUnitPopUpPresenter(view, organizationalUnitServiceCaller, afterCreateOrganizationalUnitEvent, afterEditOrganizationalUnitEvent, notificationEvent, organizationalUnitController, contributorsManagementPresenter, sessionInfo));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) Before(org.junit.Before)

Example 7 with OrganizationalUnitImpl

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

the class ExamplesServiceImplRepositoryNamesTest method setup.

@Before
public void setup() {
    service = spy(new ExamplesServiceImpl(ioService, configurationFactory, repositoryFactory, moduleService, repositoryService, repositoryCopier, ouService, projectService, metadataService, spaces, newProjectEvent, projectScreenService));
    when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {

        {
            add(new OrganizationalUnitImpl("ou1Name", "ou1Owner", "ou1GroupId"));
        }
    });
    when(moduleService.resolveModule(any(Path.class))).thenAnswer(new Answer<KieModule>() {

        @Override
        public KieModule answer(final InvocationOnMock invocationOnMock) throws Throwable {
            final Path path = (Path) invocationOnMock.getArguments()[0];
            final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
            return module;
        }
    });
    when(sessionInfo.getId()).thenReturn("sessionId");
    when(sessionInfo.getIdentity()).thenReturn(user);
    when(user.getIdentifier()).thenReturn("user");
    when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString())).thenReturn(mock(ConfigGroup.class));
    final ExampleProject exProject1 = mock(ExampleProject.class);
    exampleProjects = new ArrayList<ExampleProject>() {

        {
            add(exProject1);
        }
    };
    final OrganizationalUnit ou = mock(OrganizationalUnit.class);
    doReturn("ou").when(ou).getName();
    final GitRepository repository1 = mock(GitRepository.class);
    final Path repositoryRoot = mock(Path.class);
    final Path module1Root = mock(Path.class);
    when(exampleOrganizationalUnit.getName()).thenReturn("ou");
    when(exProject1.getName()).thenReturn("module1");
    when(exProject1.getRoot()).thenReturn(module1Root);
    when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot)));
    final Optional<Branch> master = Optional.of(new Branch("master", PathFactory.newPath("testFile", "file:///")));
    when(repository1.getDefaultBranch()).thenReturn(master);
    when(repositoryRoot.toURI()).thenReturn("default:///");
    when(module1Root.toURI()).thenReturn("default:///module1");
    when(ouService.getOrganizationalUnit(eq("ou"))).thenReturn(ou);
    doReturn("module1").when(repository1).getAlias();
    doReturn(repository1).when(repositoryCopier).copy(eq(ou), anyString(), eq(module1Root));
    final WorkspaceProject project = spy(new WorkspaceProject());
    doReturn(repository1.getAlias()).when(project).getName();
    doReturn(mock(Module.class)).when(project).getMainModule();
    doReturn(mock(OrganizationalUnit.class)).when(project).getOrganizationalUnit();
    doReturn(project).when(projectService).resolveProject(repository1);
    doReturn(project).when(projectService).resolveProject(any(Path.class));
    final ProjectScreenModel model = new ProjectScreenModel();
    model.setPOM(new POM());
    doReturn(model).when(projectScreenService).load(any());
}
Also used : Path(org.uberfire.backend.vfs.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) POM(org.guvnor.common.services.project.model.POM) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Branch(org.guvnor.structure.repositories.Branch) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) Module(org.guvnor.common.services.project.model.Module) KieModule(org.kie.workbench.common.services.shared.project.KieModule) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) ConfigType(org.guvnor.structure.server.config.ConfigType) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Before(org.junit.Before)

Example 8 with OrganizationalUnitImpl

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

the class ExamplesServiceImplTest method setup.

@Before
public void setup() {
    service = spy(new ExamplesServiceImpl(ioService, configurationFactory, repositoryFactory, moduleService, repositoryService, repositoryCopier, ouService, projectService, metadataService, spaces, newProjectEvent, projectScreenService));
    when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {

        {
            add(new OrganizationalUnitImpl("ou1Name", "ou1Owner", "ou1GroupId"));
            add(new OrganizationalUnitImpl("ou2Name", "ou2Owner", "ou2GroupId"));
        }
    });
    when(moduleService.resolveModule(any(Path.class))).thenAnswer(new Answer<KieModule>() {

        @Override
        public KieModule answer(final InvocationOnMock invocationOnMock) throws Throwable {
            final Path path = (Path) invocationOnMock.getArguments()[0];
            final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
            return module;
        }
    });
    when(sessionInfo.getId()).thenReturn("sessionId");
    when(sessionInfo.getIdentity()).thenReturn(user);
    when(user.getIdentifier()).thenReturn("user");
    when(configurationFactory.newConfigGroup(any(ConfigType.class), anyString(), anyString(), anyString())).thenReturn(mock(ConfigGroup.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConfigGroup(org.guvnor.structure.server.config.ConfigGroup) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) ConfigType(org.guvnor.structure.server.config.ConfigType) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Before(org.junit.Before)

Example 9 with OrganizationalUnitImpl

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

the class DefExplorerQueryServiceTest method createOrganizationalUnits.

private void createOrganizationalUnits() {
    organizationalUnits = new ArrayList<>();
    o1 = new OrganizationalUnitImpl("o1", "owner1", "group1");
    repo_o1_1 = new RepositoryMock("repo_o1_1", "repo_o1_1");
    repo_o1_2 = new RepositoryMock("repo_o1_2", "repo_o1_2");
    repo_o1_3 = new RepositoryMock("repo_o1_3", "repo_o1_3");
    o1.getRepositories().add(repo_o1_1);
    o1.getRepositories().add(repo_o1_2);
    o1.getRepositories().add(repo_o1_3);
    organizationalUnits.add(o1);
    o2 = new OrganizationalUnitImpl("o2", "owner2", "group2");
    repo_o2_1 = new RepositoryMock("repo_o2_1", "repo_o2_1");
    repo_o2_2 = new RepositoryMock("repo_o2_2", "repo_o2_2");
    o2.getRepositories().add(repo_o2_1);
    o2.getRepositories().add(repo_o2_2);
    organizationalUnits.add(o2);
    o3 = new OrganizationalUnitImpl("o3", "owner3", "group3");
    repo_o3_1 = new RepositoryMock("repo_o3_1", "repo_o3_1");
    repo_o3_2 = new RepositoryMock("repo_o3_2", "repo_o3_2");
    repo_o3_3 = new RepositoryMock("repo_o3_3", "repo_o3_3");
    o3.getRepositories().add(repo_o3_1);
    o3.getRepositories().add(repo_o3_2);
    o3.getRepositories().add(repo_o3_3);
    organizationalUnits.add(o3);
}
Also used : OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl)

Example 10 with OrganizationalUnitImpl

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

the class SocialEventModuleConstraintTest 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);
    socialEventModuleConstraint = createSocialEventModuleConstraint();
}
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

OrganizationalUnitImpl (org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl)10 Before (org.junit.Before)9 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)6 ArrayList (java.util.ArrayList)4 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)3 Repository (org.guvnor.structure.repositories.Repository)2 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)2 ConfigType (org.guvnor.structure.server.config.ConfigType)2 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)2 KieModule (org.kie.workbench.common.services.shared.project.KieModule)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Path (org.uberfire.backend.vfs.Path)2 Space (org.uberfire.spaces.Space)2 WorkspaceProjectContext (org.guvnor.common.services.project.client.context.WorkspaceProjectContext)1 Module (org.guvnor.common.services.project.model.Module)1 POM (org.guvnor.common.services.project.model.POM)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 Branch (org.guvnor.structure.repositories.Branch)1 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)1