Search in sources :

Example 1 with ProjectAssetsQuery

use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project kie-wb-common by kiegroup.

the class LibraryServiceImplTest method queryingUnindexedProjectGivesUnindexedResult.

@Test
public void queryingUnindexedProjectGivesUnindexedResult() throws Exception {
    Branch branch = new Branch("fake-branch", mockPath("file:///a/b/c"));
    final WorkspaceProject project = new WorkspaceProject(ou1, repo1, branch, mock(Module.class));
    when(indexOracle.isIndexed(project)).thenReturn(false);
    when(ioService.exists(any())).thenReturn(true);
    final ProjectAssetsQuery query = new ProjectAssetsQuery(project, "", 0, 10, Collections.emptyList());
    AssetQueryResult result = libraryService.getProjectAssets(query);
    assertEquals(ResultType.Unindexed, result.getResultType());
    assertFalse(result.getAssetInfos().isPresent());
}
Also used : ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery) Branch(org.guvnor.structure.repositories.Branch) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) AssetQueryResult(org.kie.workbench.common.screens.library.api.AssetQueryResult) Module(org.guvnor.common.services.project.model.Module) Test(org.junit.Test)

Example 2 with ProjectAssetsQuery

use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project kie-wb-common by kiegroup.

the class PopulatedAssetsScreen method resolveAssetsCount.

private void resolveAssetsCount() {
    if (!isProjectNull()) {
        ProjectAssetsQuery query = this.createProjectQuery(filter, filterType, 0, 0);
        assetQueryService.getNumberOfAssets(query).call((Integer numberOfAssets) -> {
            int offset = getOffset();
            this.view.setPageIndicator(offset + 1, this.getAssetsCount(numberOfAssets, offset + this.pageSize), this.getAssetsCount(numberOfAssets, 0));
            this.setTotalPages(numberOfAssets, this.pageSize);
            this.view.setTotalPages(this.getTotalPages());
            this.checkPaginationButtons();
        }, new DefaultErrorCallback());
    }
}
Also used : ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery) DefaultErrorCallback(org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback)

Example 3 with ProjectAssetsQuery

use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project kie-wb-common by kiegroup.

the class PopulatedAssetsScreen method createProjectQuery.

protected ProjectAssetsQuery createProjectQuery(String filter, String filterType, int startIndex, int amount) {
    Category category = categoriesManagerCache.getCategory(filterType);
    List<String> suffixes = this.getSuffixes(category);
    return new ProjectAssetsQuery(libraryPlaces.getActiveWorkspace(), filter, startIndex, amount, suffixes);
}
Also used : Category(org.uberfire.workbench.category.Category) ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)

Example 4 with ProjectAssetsQuery

use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project kie-wb-common by kiegroup.

the class PopulatedAssetsScreenTest method testCreateProjectQuery.

@Test
public void testCreateProjectQuery() {
    List<String> more = Arrays.asList("xml", "java", "dsl");
    String filter = "filter";
    Others other = new Others();
    doReturn(other).when(this.categoriesManagerCache).getCategory(eq(new Others().getName()));
    doReturn(more).when(this.populatedAssetsScreen).getSuffixes(eq(other));
    {
        String filterType = "ALL";
        ProjectAssetsQuery query = this.populatedAssetsScreen.createProjectQuery(filter, filterType, 0, 10);
        assertEquals("filter", query.getFilter());
        assertThat(query.getExtensions(), is(Collections.emptyList()));
    }
    {
        String filterType = new Others().getName();
        ProjectAssetsQuery query = this.populatedAssetsScreen.createProjectQuery(filter, filterType, 0, 10);
        assertEquals("filter", query.getFilter());
        assertThat(query.getExtensions(), is(more));
    }
}
Also used : Others(org.uberfire.workbench.category.Others) ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery) Test(org.junit.Test)

Example 5 with ProjectAssetsQuery

use of org.kie.workbench.common.screens.library.api.ProjectAssetsQuery in project drools-wb by kiegroup.

the class ScenarioSimulationAssetsDropdownProviderTest method createProjectQuery.

@Test
public void createProjectQuery() {
    scenarioSimulationAssetsDropdownProvider = spy(new ScenarioSimulationAssetsDropdownProviderBCImpl(scenarioSimulationServiceCallerMock, libraryPlacesMock, assetQueryServiceMock) {
    });
    final ProjectAssetsQuery retrieved = scenarioSimulationAssetsDropdownProvider.createProjectQuery();
    assertEquals(1000, retrieved.getAmount());
    assertEquals(0, retrieved.getStartIndex());
    assertEquals("", retrieved.getFilter());
    assertEquals(workspaceProjectMock, retrieved.getProject());
}
Also used : ProjectAssetsQuery(org.kie.workbench.common.screens.library.api.ProjectAssetsQuery) Test(org.junit.Test)

Aggregations

ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)13 Test (org.junit.Test)8 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)6 Branch (org.guvnor.structure.repositories.Branch)5 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)5 Path (org.uberfire.backend.vfs.Path)5 RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)4 PageResponse (org.uberfire.paging.PageResponse)4 AssetQueryResult (org.kie.workbench.common.screens.library.api.AssetQueryResult)3 ArrayList (java.util.ArrayList)2 AssetInfo (org.kie.workbench.common.screens.library.api.AssetInfo)2 DefaultErrorCallback (org.uberfire.ext.widgets.common.client.callbacks.DefaultErrorCallback)2 NoSuchFileException (org.uberfire.java.nio.file.NoSuchFileException)2 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1