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 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;
}
use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.
the class ProcessesDataServiceTest method setup.
@Before
public void setup() {
List<RefactoringPageRow> results = new ArrayList<RefactoringPageRow>();
RefactoringMapPageRow refactoringMapPageRow = new RefactoringMapPageRow();
Map<String, Path> map = new HashMap<String, Path>();
map.put(ID1, path1);
map.put(ID2, path2);
refactoringMapPageRow.setValue(map);
results.add(refactoringMapPageRow);
when(queryService.query(anyString(), anyObject())).thenReturn(results);
tested = new ProcessesDataService(queryService, processesUpdatedEvent);
}
use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.
the class BpmnFileIndexerTest method testBpmnIndexing.
@Test
public void testBpmnIndexing() throws Exception {
List<Path> pathList = new ArrayList<>();
ioService().startBatch(ioService().getFileSystem(basePath.toUri()));
for (int i = 0; i < BPMN_FILES.length; ++i) {
String bpmnFile = BPMN_FILES[i];
if (bpmnFile.endsWith("bpmn")) {
Path path = basePath.resolve(bpmnFile);
pathList.add(path);
String bpmnStr = loadText(bpmnFile);
ioService().write(path, bpmnStr);
}
}
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 = queryBPMN2Resources();
if (response != null && response.getPageRowList() != null && response.getPageRowList().size() >= paths.length) {
break;
}
}
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
assertNotNull(response);
assertEquals(paths.length, response.getPageRowList().size());
}
{
QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("*", PartType.RULEFLOW_GROUP, ValueIndexTerm.TermSearchType.WILDCARD).inAllModules().onAllBranches();
try {
final List<RefactoringPageRow> response = service.queryToList(request);
assertNotNull(response);
assertEquals(1, response.size());
assertResponseContains(response, paths[4]);
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
}
{
QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("MySignal", PartType.SIGNAL).inAllModules().onAllBranches();
try {
final List<RefactoringPageRow> response = service.queryToList(request);
assertNotNull(response);
assertEquals(1, response.size());
assertResponseContains(response, paths[5]);
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
}
{
QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("BrokenSignal", PartType.SIGNAL).inAllModules().onAllBranches();
try {
final List<RefactoringPageRow> response = service.queryToList(request);
assertNotNull(response);
assertEquals(1, response.size());
assertResponseContains(response, paths[6]);
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
}
{
QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("name", PartType.GLOBAL).inAllModules().onAllBranches();
try {
final List<RefactoringPageRow> response = service.queryToList(request);
assertNotNull(response);
assertEquals(2, response.size());
assertResponseContains(response, paths[5]);
assertResponseContains(response, paths[6]);
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
}
{
final Set<ValueIndexTerm> queryTerms = new HashSet<ValueIndexTerm>() {
{
add(new ValueResourceIndexTerm("*", ResourceType.BPMN2, ValueIndexTerm.TermSearchType.WILDCARD));
}
};
try {
List<RefactoringPageRow> response = service.query(FindBpmnProcessIdsQuery.NAME, queryTerms);
assertNotNull(response);
assertEquals(paths.length, response.size());
for (String expectedId : PROCESS_IDS) {
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(PROCESS_IDS.contains(rKey));
foundId = true;
}
}
if (!foundId) {
fail("Process with PARENT_ID <" + expectedId + " not found in results for " + FindBpmnProcessIdsQuery.NAME);
}
}
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
}
}
Aggregations