use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery 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.kie.workbench.common.screens.library.api.ProjectAssetsQuery 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.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method queryAnItemThatIsInLuceneIndexButAlreadyDeletedFromGitRepository.
@Test
public void queryAnItemThatIsInLuceneIndexButAlreadyDeletedFromGitRepository() throws Exception {
final Path path = mockPath("file://the_project");
final WorkspaceProject project = spy(WorkspaceProject.class);
final Branch branch = mock(Branch.class);
when(project.getBranch()).thenReturn(branch);
when(branch.getPath()).thenReturn(path);
doReturn(true).when(ioService).exists(any());
final ProjectAssetsQuery query = new ProjectAssetsQuery(project, "", 10, 20, Collections.emptyList());
final PageResponse<RefactoringPageRow> pageRowPageResponse = new PageResponse<>();
final ArrayList<RefactoringPageRow> assetPageRowList = new ArrayList<>();
final RefactoringPageRow pageRow = mock(RefactoringPageRow.class);
final Path filePath = mockPath("file://the_project/delete.me");
when(filePath.getFileName()).thenReturn("delete.me");
when(pageRow.getValue()).thenReturn(filePath);
assetPageRowList.add(pageRow);
pageRowPageResponse.setPageRowList(assetPageRowList);
when(refactoringQueryService.query(any(RefactoringPageRequest.class))).thenReturn(pageRowPageResponse);
when(ioService.readAttributes(any())).thenThrow(new NoSuchFileException());
final AssetQueryResult result = libraryService.getProjectAssets(query);
assertEquals(ResultType.Normal, result.getResultType());
assertTrue(result.getAssetInfos().isPresent());
List<AssetInfo> projectAssets = result.getAssetInfos().get();
assertTrue(projectAssets.isEmpty());
}
use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method emptyFirstPage.
@Test
public void emptyFirstPage() throws Exception {
final WorkspaceProject project = spy(WorkspaceProject.class);
final Branch branch = mock(Branch.class);
final Path path = mock(Path.class);
when(project.getBranch()).thenReturn(branch);
when(branch.getPath()).thenReturn(path);
when(path.toURI()).thenReturn("file://a/b/c");
doReturn(true).when(ioService).exists(any());
final ProjectAssetsQuery query = new ProjectAssetsQuery(project, "", 0, 10, Collections.emptyList());
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(1, pageRequest.getQueryTerms().size());
assertEquals("file://a/b/c", pageRequest.getQueryTerms().iterator().next().getValue());
assertEquals(0, pageRequest.getStartRowIndex());
assertEquals(10, (int) pageRequest.getPageSize());
}
use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project kie-wb-common by kiegroup.
the class PopulatedAssetsScreen method getAssets.
private void getAssets(String filter, String filterType, int startIndex, int amount, RemoteCallback<AssetQueryResult> callback) {
if (!isProjectNull()) {
ProjectAssetsQuery query = this.createProjectQuery(filter, filterType, startIndex, amount);
assetQueryService.getAssets(query).call(callback, new DefaultErrorCallback());
}
}
Aggregations