Search in sources :

Example 21 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class FormDefinitionIndexerTest method testFormsIndexing.

@Test
public void testFormsIndexing() throws Exception {
    List<Path> pathList = new ArrayList<>();
    ioService().startBatch(ioService().getFileSystem(basePath.toUri()));
    for (String formFile : FORMS) {
        Path path = basePath.resolve(formFile);
        pathList.add(path);
        String formContent = loadText(formFile);
        ioService().write(path, formContent);
    }
    ioService().endBatch();
    Path[] paths = pathList.toArray(new Path[pathList.size()]);
    {
        PageResponse<RefactoringPageRow> response = null;
        try {
            for (int i = 0; i < MAX_WAIT_TIMES; i++) {
                Thread.sleep(WAIT_TIME_MILLIS);
                response = getFormResources();
                if (response != null && response.getPageRowList() != null && response.getPageRowList().size() >= paths.length) {
                    break;
                }
            }
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
        assertNotNull(response);
        Set<RefactoringPageRow> result = new HashSet(response.getPageRowList());
        assertEquals(paths.length, result.size());
    }
    {
        final Set<ValueIndexTerm> queryTerms = new HashSet<ValueIndexTerm>() {

            {
                add(new ValueResourceIndexTerm("*", ResourceType.FORM, ValueIndexTerm.TermSearchType.WILDCARD));
            }
        };
        try {
            Set<RefactoringPageRow> response = new HashSet(service.query(FindFormDefinitionIdsQuery.NAME, queryTerms));
            assertNotNull(response);
            assertEquals(paths.length, response.size());
            for (String expectedId : FORMS) {
                boolean foundId = false;
                for (RefactoringPageRow row : response) {
                    Map<String, org.uberfire.backend.vfs.Path> mapRow = (Map<String, org.uberfire.backend.vfs.Path>) row.getValue();
                    for (String rKey : mapRow.keySet()) {
                        assertTrue(Arrays.asList(FORMS).contains(rKey));
                        foundId = true;
                    }
                }
                if (!foundId) {
                    fail("FormDefinition with ID <" + expectedId + " not found in results for " + FindFormDefinitionIdsQuery.NAME);
                }
            }
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) HashSet(java.util.HashSet) Set(java.util.Set) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) ArrayList(java.util.ArrayList) PageResponse(org.uberfire.paging.PageResponse) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Map(java.util.Map) HashSet(java.util.HashSet) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest) Test(org.junit.Test)

Example 22 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class ImpactAnalysisJavaFileTest method testQueryOperationRequest.

private void testQueryOperationRequest(QueryOperationRequest queryOpRequest) {
    List<RefactoringPageRow> response = service.queryToList(queryOpRequest);
    assertNotNull("Null PageResonse", response);
    assertNotNull("Null PageRefactoringRow list", response);
    assertEquals("Objects referencing " + AnnotationValuesAnnotation.class.getName(), 1, response.size());
    for (RefactoringPageRow row : response) {
        org.uberfire.backend.vfs.Path rowPath = (org.uberfire.backend.vfs.Path) row.getValue();
        logger.debug(rowPath.toURI());
    }
    Object pageRowValue = response.get(0).getValue();
    assertTrue("Expected a " + org.uberfire.backend.vfs.Path.class.getName() + ", not a " + pageRowValue.getClass().getSimpleName(), org.uberfire.backend.vfs.Path.class.isAssignableFrom(pageRowValue.getClass()));
    String fileName = ((org.uberfire.backend.vfs.Path) pageRowValue).getFileName();
    assertTrue("File does not end with '.java'", fileName.endsWith(".java"));
    assertEquals("File name", this.getClass().getSimpleName(), fileName.subSequence(0, fileName.indexOf(".java")));
}
Also used : Path(org.uberfire.java.nio.file.Path) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 23 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class RefactoringQueryServiceImpl method queryToPageResponse.

/* (non-Javadoc)
     * @see org.kie.workbench.common.services.refactoring.service.RefactoringQueryService#queryToPageResponse(org.kie.workbench.common.services.refactoring.service.impact.QueryOperationRequest)
     */
@Override
public PageResponse<RefactoringPageRow> queryToPageResponse(QueryOperationRequest queryOpRequest) {
    final RefactoringPageRequest request = convertToRefactoringPageRequest(queryOpRequest);
    final PageResponse<RefactoringPageRow> response = query(request);
    return response;
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 24 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class RefactoringQueryServiceImpl method queryToList.

@Override
public List<RefactoringPageRow> queryToList(final QueryOperationRequest queryOpRequest) {
    final RefactoringPageRequest request = convertToRefactoringPageRequest(queryOpRequest);
    final List<RefactoringPageRow> response = query(request.getQueryName(), request.getQueryTerms());
    return response;
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 25 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class DefaultResponseBuilder method buildResponse.

@Override
public List<RefactoringPageRow> buildResponse(final List<KObject> kObjects) {
    final List<RefactoringPageRow> result = new ArrayList<RefactoringPageRow>(kObjects.size());
    for (final KObject kObject : kObjects) {
        final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey())));
        final RefactoringPathPageRow row = new RefactoringPathPageRow();
        row.setValue(path);
        result.add(row);
    }
    return result;
}
Also used : Path(org.uberfire.backend.vfs.Path) KObject(org.uberfire.ext.metadata.model.KObject) ArrayList(java.util.ArrayList) RefactoringPathPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPathPageRow) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Aggregations

RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)26 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)11 Path (org.uberfire.backend.vfs.Path)10 PageResponse (org.uberfire.paging.PageResponse)9 HashSet (java.util.HashSet)8 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)8 Path (org.uberfire.java.nio.file.Path)5 Map (java.util.Map)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)4 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)4 LibraryValueModuleRootPathIndexTerm (org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm)4 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)4 Set (java.util.Set)3 Branch (org.guvnor.structure.repositories.Branch)3 List (java.util.List)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 AssetInfo (org.kie.workbench.common.screens.library.api.AssetInfo)2