Search in sources :

Example 26 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method importProjectWithoutCredentialsTest.

@Test
public void importProjectWithoutCredentialsTest() {
    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 = null;
    final String password = null;
    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 27 with Repository

use of org.guvnor.structure.repositories.Repository 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 28 with Repository

use of org.guvnor.structure.repositories.Repository 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 29 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class ContributorsManagerTest method makeRepository.

private Repository makeRepository(final String repositoryAlias) {
    final Repository repository = mock(Repository.class);
    when(repository.getAlias()).thenReturn(repositoryAlias);
    return repository;
}
Also used : Repository(org.guvnor.structure.repositories.Repository)

Example 30 with Repository

use of org.guvnor.structure.repositories.Repository in project kie-wb-common by kiegroup.

the class LibraryToolbarPresenter method onUpdateSelectedBranch.

void onUpdateSelectedBranch() {
    if (placeManager.closeAllPlacesOrNothing()) {
        Repository repository = projectContext.getActiveWorkspaceProject().map(workspaceProject -> workspaceProject.getRepository()).orElseThrow(() -> new IllegalStateException("Cannot get repository without an active workspace project"));
        projectService.call(new RemoteCallback<WorkspaceProject>() {

            @Override
            public void callback(WorkspaceProject project) {
                libraryPlaces.goToProject(project);
                setBranchSelectorVisibility();
            }
        }).resolveProject(repository.getSpace(), repository.getBranch(view.getSelectedBranch()).get());
    } else {
        setUpBranches();
    }
}
Also used : Repository(org.guvnor.structure.repositories.Repository) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) PlaceManager(org.uberfire.client.mvp.PlaceManager) WorkspaceProjectService(org.guvnor.common.services.project.service.WorkspaceProjectService) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) Inject(javax.inject.Inject) Caller(org.jboss.errai.common.client.api.Caller) ApplicationScoped(javax.enterprise.context.ApplicationScoped) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) UberElement(org.uberfire.client.mvp.UberElement) Command(org.uberfire.mvp.Command) Branch(org.guvnor.structure.repositories.Branch) Repository(org.guvnor.structure.repositories.Repository) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Aggregations

Repository (org.guvnor.structure.repositories.Repository)51 Test (org.junit.Test)25 OrganizationalUnit (org.guvnor.structure.organizationalunit.OrganizationalUnit)21 Branch (org.guvnor.structure.repositories.Branch)21 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)20 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)15 Module (org.guvnor.common.services.project.model.Module)14 ArrayList (java.util.ArrayList)13 Path (org.uberfire.backend.vfs.Path)13 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)10 POM (org.guvnor.common.services.project.model.POM)7 KieModule (org.kie.workbench.common.services.shared.project.KieModule)7 ExampleOrganizationalUnit (org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit)5 HashMap (java.util.HashMap)4 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)4 Before (org.junit.Before)4 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)3 RepositoryEnvironmentConfigurations (org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations)3 ConfigGroup (org.guvnor.structure.server.config.ConfigGroup)3 Space (org.uberfire.spaces.Space)3