use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method queryWithAFilter.
@Test
public void queryWithAFilter() throws Exception {
final WorkspaceProject project = spy(WorkspaceProject.class);
final Branch branch = mock(Branch.class);
final Path path = mockPath("file://the_project");
when(branch.getPath()).thenReturn(path);
when(project.getBranch()).thenReturn(branch);
doReturn(true).when(ioService).exists(any());
final ProjectAssetsQuery query = new ProjectAssetsQuery(project, "helloo", 10, 20, Arrays.asList("xml"));
final PageResponse<RefactoringPageRow> pageRowPageResponse = new PageResponse<>();
pageRowPageResponse.setPageRowList(new ArrayList<>());
when(refactoringQueryService.query(any(RefactoringPageRequest.class))).thenReturn(pageRowPageResponse);
libraryService.getProjectAssets(query);
verify(refactoringQueryService).query(pageRequestArgumentCaptor.capture());
final RefactoringPageRequest pageRequest = pageRequestArgumentCaptor.getValue();
assertEquals(FindAllLibraryAssetsQuery.NAME, pageRequest.getQueryName());
assertEquals(3, pageRequest.getQueryTerms().size());
assertQueryTermsContains(pageRequest.getQueryTerms(), "file://the_project");
assertQueryTermsContains(pageRequest.getQueryTerms(), "*helloo*");
assertQueryTermsContains(pageRequest.getQueryTerms(), ".*(xml)");
assertEquals(10, pageRequest.getStartRowIndex());
assertEquals(20, (int) pageRequest.getPageSize());
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method hasAssetsTest.
@Test
public void hasAssetsTest() {
doReturn(true).when(ioService).exists(any());
final Package package1 = mock(Package.class);
final Module project1 = mock(Module.class);
doReturn(package1).when(moduleService).resolveDefaultPackage(project1);
doReturn(true).when(explorerServiceHelper).hasAssets(package1);
final Package package2 = mock(Package.class);
final Module project2 = mock(Module.class);
doReturn(package2).when(moduleService).resolveDefaultPackage(project2);
doReturn(false).when(explorerServiceHelper).hasAssets(package2);
assertTrue(libraryService.hasAssets(new WorkspaceProject(mock(OrganizationalUnit.class), mock(Repository.class), mock(Branch.class), project1)));
assertFalse(libraryService.hasAssets(new WorkspaceProject(mock(OrganizationalUnit.class), mock(Repository.class), mock(Branch.class), project2)));
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method testGetNumberOfAssets.
@Test
public void testGetNumberOfAssets() throws Exception {
final Path path = mock(Path.class);
final WorkspaceProject project = mock(WorkspaceProject.class);
final ProjectAssetsQuery query = mock(ProjectAssetsQuery.class);
doReturn(project).when(query).getProject();
doReturn(path).when(project).getRootPath();
doReturn("some.unique.uri").when(path).toURI();
libraryService.getNumberOfAssets(query);
verify(refactoringQueryService).queryHitCount(any(RefactoringPageRequest.class));
}
use of org.guvnor.common.services.project.model.WorkspaceProject in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method hasProjectsTest.
@Test
public void hasProjectsTest() {
final Path path = mockPath("file://the_project");
final WorkspaceProject project = mock(WorkspaceProject.class);
when(project.getRootPath()).thenReturn(path);
doReturn(true).when(ioService).exists(any());
final Set<WorkspaceProject> projects = new HashSet<>();
projects.add(project);
doReturn(projects).when(projectService).getAllWorkspaceProjects(ou1);
assertTrue(libraryService.hasProjects(ou1));
}
use of org.guvnor.common.services.project.model.WorkspaceProject 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