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());
}
}
}
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")));
}
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;
}
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;
}
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;
}
Aggregations