use of org.kie.workbench.common.services.refactoring.model.index.terms.SharedPartIndexTerm in project drools-wb by kiegroup.
the class IndexRuleAttributeNameAndValueTest method testIndexDrlRuleAttributeNameAndValue.
@Test
public void testIndexDrlRuleAttributeNameAndValue() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.drl");
final String drl = loadText("drl1.drl");
ioService().write(path, drl);
// 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());
{
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
queryBuilder.add(new TermQuery(new Term((new SharedPartIndexTerm(PartType.RULEFLOW_GROUP)).getTerm())), BooleanClause.Occur.MUST);
queryBuilder.add(new TermQuery(new Term("nonexistent")), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 0);
}
// This note replaces an earlier note, if it doesn't make sense, delete or ignore it.
// Both pieces of info (that it's a ruleflow group, and that the ruleflow group is called "myruleflowgroup")
// are present in the same field ("shared:ruleflowgroup" => "myruleflowgroup"), so this only returns
// documents that match that field (as opposed to the structure we had before).
{
final BooleanQuery.Builder queryBuilder = new BooleanQuery.Builder();
ValueIndexTerm termVals = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
queryBuilder.add(new TermQuery(new Term(termVals.getTerm(), termVals.getValue())), BooleanClause.Occur.MUST);
searchFor(index, queryBuilder.build(), 1);
}
}
Aggregations