use of org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations in project kie-wb-common by kiegroup.
the class LibraryServiceImpl method importProject.
@Override
public WorkspaceProject importProject(final OrganizationalUnit targetOU, final String repositoryURL, final String username, final String password) {
final RepositoryEnvironmentConfigurations config = new RepositoryEnvironmentConfigurations();
config.setOrigin(repositoryURL);
if (username != null && password != null) {
config.setUserName(username);
config.setPassword(password);
}
final String targetProjectName = inferProjectName(repositoryURL);
final Repository repo = repoService.createRepository(targetOU, GitRepository.SCHEME.toString(), targetProjectName, config);
return projectService.resolveProject(repo);
}
use of org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations 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);
}
use of org.guvnor.structure.repositories.RepositoryEnvironmentConfigurations 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);
}
Aggregations