use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project kie-wb-common by kiegroup.
the class SearchEmptyQueryBuilder method addRuleNameWildCardTerm.
public SearchEmptyQueryBuilder addRuleNameWildCardTerm() {
ValueIndexTerm valTerm = new ValueResourceIndexTerm("*", ResourceType.RULE, TermSearchType.WILDCARD);
queryBuilder.add(new WildcardQuery(new Term(valTerm.getTerm(), valTerm.getValue())), MUST);
return this;
}
use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm 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.index.terms.valueterms.ValueIndexTerm in project drools-wb by kiegroup.
the class IndexDecisionTableXLSAttributeNameAndValueTest method testIndexDecisionTableXLSAttributeNameAndValue.
@Test
public void testIndexDecisionTableXLSAttributeNameAndValue() throws IOException, InterruptedException {
// Add test files
final Path path1 = loadXLSFile(basePath, "dtable1.xls");
final Path path2 = loadXLSFile(basePath, "dtable2.xls");
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
// This simply checks whether there is a Rule Attribute "ruleflow-group" with a Rule Attribute Value "myRuleflowGroup"
{
final BooleanQuery.Builder query = new BooleanQuery.Builder();
ValueIndexTerm valTerm = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
query.add(new TermQuery(new Term(valTerm.getTerm(), valTerm.getValue())), BooleanClause.Occur.MUST);
searchFor(index, query.build(), 1, path1);
}
}
Aggregations