Search in sources :

Example 6 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject 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 WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class SocialEventModuleConstraint method hasRestrictions.

@Override
public boolean hasRestrictions(final SocialActivitiesEvent event) {
    try {
        if (!userCDIContextHelper.thereIsALoggedUserInScope()) {
            return false;
        }
        if (event.isVFSLink() || isAModuleEvent(event)) {
            final boolean isRepositoryRestricted = delegate.hasRestrictions(event);
            if (isRepositoryRestricted) {
                return true;
            }
            final WorkspaceProject project = getEventModule(event);
            if (thereIsAProjectAssociatedWithThisEvent(project)) {
                return !authorizationManager.authorize(project.getRepository(), userCDIContextHelper.getUser());
            } else {
                return false;
            }
        } else {
            return false;
        }
    } catch (Exception e) {
        return true;
    }
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject)

Example 8 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject 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 9 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject 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)

Example 10 with WorkspaceProject

use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.

the class ExplorerMenuTest method testOnArchiveActiveRepo.

@Test
public void testOnArchiveActiveRepo() throws Exception {
    final Path rootRepoPath = mock(Path.class);
    final Repository repository = mock(Repository.class);
    when(repository.getDefaultBranch()).thenReturn(Optional.of(new Branch("master", rootRepoPath)));
    final WorkspaceProject project = mock(WorkspaceProject.class);
    when(project.getRepository()).thenReturn(repository);
    when(context.getActiveWorkspaceProject()).thenReturn(Optional.of(project));
    menu.onArchiveActiveRepository();
    verify(view).archive(rootRepoPath);
}
Also used : Path(org.uberfire.backend.vfs.Path) Repository(org.guvnor.structure.repositories.Repository) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Test(org.junit.Test)

Aggregations

WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)67 Test (org.junit.Test)42 Branch (org.guvnor.structure.repositories.Branch)29 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)28 Repository (org.guvnor.structure.repositories.Repository)26 Path (org.uberfire.backend.vfs.Path)26 Module (org.guvnor.common.services.project.model.Module)21 ArrayList (java.util.ArrayList)12 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)12 WorkspaceProjectContextChangeEvent (org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent)10 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)9 Before (org.junit.Before)8 KieModule (org.kie.workbench.common.services.shared.project.KieModule)7 POM (org.guvnor.common.services.project.model.POM)6 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)5 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)5 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)5 Date (java.util.Date)4 HashSet (java.util.HashSet)4 ExampleProject (org.kie.workbench.common.screens.examples.model.ExampleProject)4