use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest 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.RefactoringPageRequest in project kie-wb-common by kiegroup.
the class FindResourcePartReferencesQueryInvalidIndexTermsTest method testFindResourcePartReferencesQueryInvalidIndexTerms.
@Test
public void testFindResourcePartReferencesQueryInvalidIndexTerms() throws IOException, InterruptedException {
{
final RefactoringPageRequest request = new RefactoringPageRequest(FindResourcePartReferencesQuery.NAME, new HashSet<ValueIndexTerm>(), 0, -1);
try {
service.query(request);
fail();
} catch (IllegalArgumentException e) {
assertTrue("Unexpected message: " + e.getMessage(), e.getMessage().startsWith("At least 1 term must be submitted"));
// and Swallow. Expected
}
}
{
final RefactoringPageRequest request = new RefactoringPageRequest(FindResourcePartReferencesQuery.NAME, new HashSet<ValueIndexTerm>() {
{
add(new ValueReferenceIndexTerm("myRule", ResourceType.RULE));
}
}, 0, -1);
try {
service.query(request);
fail();
} catch (IllegalArgumentException e) {
assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().startsWith("Index term 'ref:rule' can not be used with"));
}
}
{
final RefactoringPageRequest request = new RefactoringPageRequest(FindResourcePartReferencesQuery.NAME, new HashSet<ValueIndexTerm>() {
{
add(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ResourceType.JAVA));
add(new ValueReferenceIndexTerm("myRule", ResourceType.RULE));
}
}, 0, -1);
try {
service.query(request);
fail();
} catch (IllegalArgumentException e) {
assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().contains(" can not be used with the " + FindResourcePartReferencesQuery.NAME));
}
}
}
use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest in project kie-wb-common by kiegroup.
the class FindResourcePartReferencesQueryValidIndexTermsTest method testFindResourcePartReferencesQueryValidIndexTerms.
@Test
public void testFindResourcePartReferencesQueryValidIndexTerms() throws IOException, InterruptedException {
// Add test files
Path[] path = { basePath.resolve("drl1.drl"), basePath.resolve("drl2.drl"), basePath.resolve("drl3.drl") };
String[] content = { loadText("../findresourceparts/drl1.drl"), loadText("../findresourceparts/drl2.drl"), loadText("../findresourceparts/drl3.drl") };
for (int i = 0; i < path.length; ++i) {
ioService().write(path[i], content[i]);
}
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
{
final RefactoringPageRequest request = new RefactoringPageRequest(FindResourcePartReferencesQuery.NAME, new HashSet<ValueIndexTerm>() {
{
add(new ValuePartReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", "age", PartType.FIELD));
}
}, 0, 10);
try {
final PageResponse<RefactoringPageRow> response = service.query(request);
assertNotNull(response);
assertEquals(2, response.getPageRowList().size());
assertResponseContains(response.getPageRowList(), path[0]);
assertResponseContains(response.getPageRowList(), path[1]);
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
}
{
final RefactoringPageRequest request = new RefactoringPageRequest(FindResourcePartReferencesQuery.NAME, new HashSet<ValueIndexTerm>() {
{
add(new ValueSharedPartIndexTerm("myRuleFlowGroup", PartType.RULEFLOW_GROUP));
}
}, 0, 10);
try {
final PageResponse<RefactoringPageRow> response = service.query(request);
assertNotNull(response);
assertEquals(2, response.getPageRowList().size());
assertResponseContains(response.getPageRowList(), path[0]);
assertResponseContains(response.getPageRowList(), path[2]);
} catch (IllegalArgumentException e) {
fail("Exception thrown: " + e.getMessage());
}
}
}
use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest in project kie-wb-common by kiegroup.
the class FindResourcePartsQueryInvalidIndexTermsTest method testFindResourcePartsQueryInvalidIndexTerms.
@Test
public void testFindResourcePartsQueryInvalidIndexTerms() throws IOException, InterruptedException {
{
final RefactoringPageRequest request = new RefactoringPageRequest("FindResourcePartsQuery", new HashSet<ValueIndexTerm>(), 0, -1);
try {
service.query(request);
fail();
} catch (IllegalArgumentException e) {
assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().startsWith("Expected '" + ValuePartIndexTerm.class.getSimpleName() + "' term was not found"));
// and Swallow. Expected
}
}
ValueIndexTerm ruleRefTerm = new ValueReferenceIndexTerm("myRule", ResourceType.RULE);
{
final RefactoringPageRequest request = new RefactoringPageRequest("FindResourcePartsQuery", new HashSet<ValueIndexTerm>() {
{
add(ruleRefTerm);
}
}, 0, -1);
try {
service.query(request);
fail();
} catch (IllegalArgumentException e) {
assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().startsWith("Index term '" + ruleRefTerm.getTerm() + "' can not be used with"));
// and Swallow. Expected
}
}
{
final RefactoringPageRequest request = new RefactoringPageRequest("FindResourcePartsQuery", new HashSet<ValueIndexTerm>() {
{
add(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ResourceType.JAVA));
add(ruleRefTerm);
}
}, 0, -1);
try {
service.query(request);
fail();
} catch (IllegalArgumentException e) {
assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().contains(" can not be used with the " + FindResourcePartsQuery.NAME));
// and Swallow. Expected
}
}
}
use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest in project kie-wb-common by kiegroup.
the class FindResourceReferencesQueryInvalidIndexTermsTest method testQueryInvalidIndexTerms.
@Test
public void testQueryInvalidIndexTerms() throws IOException, InterruptedException {
{
final RefactoringPageRequest request = new RefactoringPageRequest("FindResourceReferencesQuery", new HashSet<ValueIndexTerm>(), 0, -1);
try {
service.query(request);
fail();
} catch (IllegalArgumentException e) {
e.printStackTrace();
assertTrue("Unexpected message: " + e.getMessage(), e.getMessage().startsWith("Expected 'ref:*' term was not found"));
// and Swallow. Expected
}
}
}
Aggregations