Search in sources :

Example 46 with OrganizationalUnit

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

the class ProjectScreenTestBase method createProject.

protected WorkspaceProject createProject() {
    final Path rootPath = mock(Path.class);
    doReturn("git://modulePath").when(rootPath).toURI();
    final Module module = mock(Module.class);
    doReturn("mainModuleName").when(module).getModuleName();
    doReturn("modulePath").when(module).getIdentifier();
    doReturn(rootPath).when(module).getRootPath();
    final Path pomPath = mock(Path.class);
    doReturn(pomPath).when(module).getPomXMLPath();
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final Repository repository = mock(Repository.class);
    final Path repositoryRootPath = mock(Path.class);
    doReturn(Optional.of(new Branch("master", repositoryRootPath))).when(repository).getDefaultBranch();
    doReturn("rootpath").when(repositoryRootPath).toURI();
    return new WorkspaceProject(organizationalUnit, repository, new Branch("master", mock(Path.class)), module);
}
Also used : Path(org.uberfire.backend.vfs.Path) 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) Module(org.guvnor.common.services.project.model.Module)

Example 47 with OrganizationalUnit

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

the class EditContributorsPopUpPresenterTest method showWithoutPermissionTest.

@Test
public void showWithoutPermissionTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(organizationalUnit);
    presenter.show(organizationalUnit);
    verify(contributorsManagementPresenter, never()).setup();
    verify(view, never()).append(any());
    verify(view, never()).show(organizationalUnit);
    assertNull(presenter.organizationalUnit);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Test(org.junit.Test)

Example 48 with OrganizationalUnit

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

the class ContributorsListPresenterTest method setupTest.

@Test
public void setupTest() {
    final InOrder order = inOrder(contributorsListItemPresenter);
    final List<String> contributors = new ArrayList<>();
    contributors.add("B");
    contributors.add("c");
    contributors.add("a");
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn("B").when(organizationalUnit).getOwner();
    doReturn(contributors).when(organizationalUnit).getContributors();
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
    presenter.setup();
    verify(view).init(presenter);
    verify(view).clearContributors();
    order.verify(contributorsListItemPresenter).setup("a", "Contributor");
    order.verify(contributorsListItemPresenter).setup("B", "Owner");
    order.verify(contributorsListItemPresenter).setup("c", "Contributor");
    verify(view, times(3)).addContributor(any());
}
Also used : InOrder(org.mockito.InOrder) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 49 with OrganizationalUnit

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

the class ContributorsListPresenterTest method editWithoutPermissionTest.

@Test
public void editWithoutPermissionTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn(Optional.of(organizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    doReturn(false).when(organizationalUnitController).canUpdateOrgUnit(organizationalUnit);
    presenter.edit();
    verify(editContributorsPopUpPresenter, never()).show(organizationalUnit);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Test(org.junit.Test)

Example 50 with OrganizationalUnit

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

the class AddProjectPopUpPresenterTest method newWorkbenchProjectWithAdvancedSettingsIsCreated.

@Test
public void newWorkbenchProjectWithAdvancedSettingsIsCreated() throws Exception {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    doReturn("test").when(view).getName();
    doReturn("description").when(view).getDescription();
    doReturn("groupId").when(view).getGroupId();
    doReturn("artifactId").when(view).getArtifactId();
    doReturn("version").when(view).getVersion();
    doReturn(true).when(view).isAdvancedOptionsSelected();
    presenter.add();
    final ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
    verify(libraryService).createProject(eq(organizationalUnit), pomArgumentCaptor.capture(), eq(DeploymentMode.VALIDATED));
    final POM pom = pomArgumentCaptor.getValue();
    assertEquals("test", pom.getName());
    assertEquals("description", pom.getDescription());
    assertEquals("groupId", pom.getGav().getGroupId());
    assertEquals("artifactId", pom.getGav().getArtifactId());
    assertEquals("version", pom.getGav().getVersion());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

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