use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.
the class FindAllLibraryAssetsSortedQueryTest method listAllInProjectSorted.
@Test
public void listAllInProjectSorted() throws IOException, InterruptedException {
setUp(TEST_PROJECT_ROOT1);
final RefactoringPageRequest request = new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, new HashSet<ValueIndexTerm>() {
{
add(new LibraryValueModuleRootPathIndexTerm(TEST_PROJECT_ROOT1, TermSearchType.WILDCARD));
}
}, 0, 10);
final PageResponse<RefactoringPageRow> response = service.query(request);
assertNotNull(response);
// Remove duplicates and sort file names alphabetically
Set<String> resultSet = new TreeSet<>();
for (RefactoringPageRow row : response.getPageRowList()) {
String fileName = ((Path) row.getValue()).getFileName();
System.out.println(fileName);
resultSet.add(fileName);
}
assertArrayEquals(FILE_NAMES, resultSet.toArray());
}
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 ID <" + expectedId + " not found in results for " + FindBpmnProcessIdsQuery.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 CalledElementFormProviderTest method setup.
@Before
public void setup() {
calledElementFormProvider.setQueryService(queryService);
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);
}
use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.
the class RuleFlowGroupFormProvider method getRuleFlowGroupNames.
@SuppressWarnings("unchecked")
private Map<Object, String> getRuleFlowGroupNames() {
List<RefactoringPageRow> results = queryService.query(FindRuleFlowNamesQuery.NAME, new HashSet<ValueIndexTerm>() {
{
add(new ValueSharedPartIndexTerm("*", PartType.RULEFLOW_GROUP, ValueIndexTerm.TermSearchType.WILDCARD));
}
});
Map<Object, String> ruleFlowGroupNames = new TreeMap<Object, String>();
for (RefactoringPageRow row : results) {
ruleFlowGroupNames.put(((Map<String, String>) row.getValue()).get("name"), ((Map<String, String>) row.getValue()).get("name"));
}
return ruleFlowGroupNames;
}
use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.
the class FindDataTypesService method getDataTypeNames.
public List<String> getDataTypeNames() {
// Query Java resources
List<RefactoringPageRow> results = queryService.query(FindDataTypesQuery.NAME, new HashSet<ValueIndexTerm>() {
{
add(new ValueResourceIndexTerm("*", ResourceType.JAVA, ValueIndexTerm.TermSearchType.WILDCARD));
}
});
final List<String> dataTypeNames = new ArrayList<String>();
for (RefactoringPageRow row : results) {
dataTypeNames.add((String) row.getValue());
}
Collections.sort(dataTypeNames);
return dataTypeNames;
}
Aggregations