Search in sources :

Example 41 with OrganizationalUnit

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

the class LibraryServiceImplTest method importProjectFromExampleTest.

@Test
public void importProjectFromExampleTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final ExampleProject exampleProject = mock(ExampleProject.class);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final Module module = mock(Module.class);
    doReturn(module).when(project).getMainModule();
    final WorkspaceProjectContextChangeEvent projectContextChangeEvent = mock(WorkspaceProjectContextChangeEvent.class);
    doReturn(project).when(projectContextChangeEvent).getWorkspaceProject();
    doReturn(projectContextChangeEvent).when(examplesService).setupExamples(any(ExampleOrganizationalUnit.class), anyList());
    final WorkspaceProject importedProject = libraryService.importProject(organizationalUnit, exampleProject);
    assertEquals(module, importedProject.getMainModule());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) Module(org.guvnor.common.services.project.model.Module) ExampleProject(org.kie.workbench.common.screens.examples.model.ExampleProject) Test(org.junit.Test)

Example 42 with OrganizationalUnit

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

the class LibraryServiceImplTest method createPOM.

@Test
public void createPOM() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    when(organizationalUnit.getDefaultGroupId()).thenReturn("ouGroupID");
    when(preferences.getProjectPreferences().getVersion()).thenReturn("1.0");
    when(preferences.getProjectPreferences().getDescription()).thenReturn("desc");
    GAV gav = libraryService.createGAV("proj", organizationalUnit);
    POM proj = libraryService.createPOM("proj", "description", gav);
    assertEquals("proj", proj.getName());
    assertEquals("description", proj.getDescription());
    assertEquals(gav, proj.getGav());
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) GAV(org.guvnor.common.services.project.model.GAV) POM(org.guvnor.common.services.project.model.POM) Test(org.junit.Test)

Example 43 with OrganizationalUnit

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

the class LibraryServiceImplTest method importProjectWithCredentialsTest.

@Test
public void importProjectWithCredentialsTest() {
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    final Repository repo = mock(Repository.class);
    final WorkspaceProject project = mock(WorkspaceProject.class);
    final String repositoryURL = "file:///some/path/to/fake-repo.git";
    final String username = "fakeUser";
    final String password = "fakePassword";
    final ArgumentCaptor<RepositoryEnvironmentConfigurations> configCaptor = ArgumentCaptor.forClass(RepositoryEnvironmentConfigurations.class);
    when(repositoryService.createRepository(any(), any(), any(), configCaptor.capture())).thenReturn(repo);
    when(projectService.resolveProject(any(Repository.class))).thenReturn(project);
    final WorkspaceProject observedProject = libraryService.importProject(organizationalUnit, repositoryURL, username, password);
    verify(repositoryService).createRepository(same(organizationalUnit), eq(GitRepository.SCHEME.toString()), eq("fake-repo"), any());
    RepositoryEnvironmentConfigurations observedConfig = configCaptor.getValue();
    assertEquals(username, observedConfig.getUserName());
    assertEquals(password, observedConfig.getPassword());
    assertEquals(repositoryURL, observedConfig.getOrigin());
    verify(projectService).resolveProject(same(repo));
    assertSame(project, observedProject);
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) RepositoryEnvironmentConfigurations(org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Test(org.junit.Test)

Example 44 with OrganizationalUnit

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

the class ContributorsManagerTest method setUp.

@Before
public void setUp() throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    List<VersionRecord> repositoryHistory1 = new ArrayList<>();
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/01/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da04471@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/06/2017"), "default://3da0447b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0445b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/06/2017"), "default://3da0457b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/03/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/04/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/0/2017"), "default://3da04474@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0445b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0446b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/09/2016"), "default://3da0447b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/10/2016"), "default://3da0445b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/11/2016"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/11/2016"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/12/2016"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/12/2016"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0444b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0443b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/01/2017"), "default://3da0442b@project1/file"));
    repositoryHistory1.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0443b@project1/file"));
    List<VersionRecord> repositoryHistory2 = new ArrayList<>();
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da04471@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/06/2017"), "default://3da0447b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0445b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/06/2017"), "default://3da0457b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/06/2017"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/03/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/04/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/05/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/06/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/0/2017"), "default://3da04474@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0445b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/08/2016"), "default://3da0446b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/09/2016"), "default://3da0447b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/10/2016"), "default://3da0445b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Pere", null, "", sdf.parse("01/11/2016"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/11/2016"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("01/12/2016"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("01/12/2016"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "David", null, "", sdf.parse("02/01/2017"), "default://3da0441b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/02/2017"), "default://3da0442b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/03/2017"), "default://3da0443b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("02/03/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/04/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Roger", null, "", sdf.parse("02/05/2017"), "default://3da0444b@project2/file"));
    repositoryHistory2.add(new PortableVersionRecord(null, "Mark", null, "", sdf.parse("01/02/2017"), "default://3da0443b@project2/file"));
    System.out.println("SUM = " + (repositoryHistory1.size() + repositoryHistory2.size()));
    final Repository repo1 = makeRepository("testRepo1");
    final Repository repo2 = makeRepository("testRepo2");
    final OrganizationalUnit org1 = makeOrganizationalUnit("test1", Arrays.asList(repo1, repo2));
    when(organizationalUnitService.getOrganizationalUnits()).thenReturn(Arrays.asList(org1));
    final Set<WorkspaceProject> projects = new HashSet<>();
    projects.add(makeProject(repo1, org1, "project1"));
    projects.add(makeProject(repo2, org1, "project2"));
    when(projectService.getAllWorkspaceProjects(eq(org1))).thenReturn(projects);
    when(recordService.loadVersionRecords(any())).thenReturn(repositoryHistory1).thenReturn(repositoryHistory2);
}
Also used : Repository(org.guvnor.structure.repositories.Repository) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) VersionRecord(org.uberfire.java.nio.base.version.VersionRecord) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) PortableVersionRecord(org.uberfire.ext.editor.commons.version.impl.PortableVersionRecord) SimpleDateFormat(java.text.SimpleDateFormat) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 45 with OrganizationalUnit

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

the class LibraryScreenTest method setup.

@Before
public void setup() {
    doReturn(editContributorsPopUpPresenter).when(editContributorsPopUpPresenters).get();
    doReturn(deleteOrganizationalUnitPopUpPresenter).when(deleteOrganizationalUnitPopUpPresenters).get();
    doReturn(orgUnitsMetricsView).when(orgUnitsMetricsScreen).getView();
    doReturn(true).when(projectController).canCreateProjects();
    doReturn(true).when(organizationalUnitController).canUpdateOrgUnit(any());
    doReturn(true).when(organizationalUnitController).canDeleteOrgUnit(any());
    doReturn(mock(PopulatedLibraryScreen.View.class)).when(populatedLibraryScreen).getView();
    doReturn(mock(EmptyLibraryScreen.View.class)).when(emptyLibraryScreen).getView();
    final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
    doReturn(Optional.of(organizationalUnit)).when(projectContext).getActiveOrganizationalUnit();
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
    libraryScreen = new LibraryScreen(view, deleteOrganizationalUnitPopUpPresenters, editContributorsPopUpPresenters, projectContext, organizationalUnitController, projectController, emptyLibraryScreen, populatedLibraryScreen, orgUnitsMetricsScreen, contributorsListPresenter, new CallerMock<>(libraryService), libraryPlaces);
}
Also used : OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) CallerMock(org.uberfire.mocks.CallerMock) Before(org.junit.Before)

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