use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexRuleAttributeNameAndValueCompositionTest method testIndexDrlRuleAttributeNameAndValues.
@Test
public void testIndexDrlRuleAttributeNameAndValues() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("drl1.rdrl");
final String drl = loadText("drl1.rdrl");
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());
// DRL defining a RuleFlow-Group named myRuleFlowGroup. This should match drl5.drl
// This checks whether there is a Rule Attribute "ruleflow-group" and its Value is "myRuleflowGroup"
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("myRuleFlowGroup", PartType.RULEFLOW_GROUP)).build();
searchFor(index, query, 1, path);
}
// DRL defining a RuleFlow-Group named myAgendaGroup. This should *NOT* match drl5.drl
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("myAgendaGroup", PartType.RULEFLOW_GROUP)).build();
searchFor(index, query, 0);
}
}
use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexRuleMultipleTypesTest method testIndexDrlRuleMultipleTypes.
@Test
public void testIndexDrlRuleMultipleTypes() throws IOException, InterruptedException {
// Add test files
final Path path1 = basePath.resolve("drl3.rdrl");
final String drl1 = loadText("drl3.rdrl");
ioService().write(path1, drl1);
final Path path2 = basePath.resolve("drl4.rdrl");
final String drl2 = loadText("drl4.rdrl");
ioService().write(path2, drl2);
// 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 Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.rule.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 2, path1, path2);
}
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.rule.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
searchFor(index, query, 1, path2);
}
}
use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexRuleTypeTest method testIndexRuleTypes.
@Test
public void testIndexRuleTypes() throws IOException, InterruptedException {
// Add test files
final Path path1 = basePath.resolve("drl1.rdrl");
final String drl1 = loadText("drl1.rdrl");
ioService().write(path1, drl1);
final Path path2 = basePath.resolve("drl2.rdrl");
final String drl2 = loadText("drl2.rdrl");
ioService().write(path2, drl2);
// 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 Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.rule.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 2);
}
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("*.Applicant", ResourceType.JAVA, TermSearchType.WILDCARD)).build();
searchFor(index, query, 2);
}
}
use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexGuidedRuleTemplateActionsTest method testIndexGuidedRuleTemplateActions.
@Test
public void testIndexGuidedRuleTemplateActions() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("template1.template");
final TemplateModel model = GuidedRuleTemplateFactory.makeModelWithActions("org.drools.workbench.screens.guided.template.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.template.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.template.server.indexing.classes.Mortgage"));
}
}, "template1");
final String xml = RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(model);
ioService().write(path, xml);
// 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 Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.template.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 1, path);
}
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.template.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
searchFor(index, query, 1, path);
}
}
use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexGuidedRuleTemplateConditionsTest method testIndexGuidedRuleTemplateConditions.
@Test
public void testIndexGuidedRuleTemplateConditions() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("template1.template");
final TemplateModel model = GuidedRuleTemplateFactory.makeModelWithConditions("org.drools.workbench.screens.guided.template.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.template.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.template.server.indexing.classes.Mortgage"));
}
}, "template1");
final String xml = RuleTemplateModelXMLPersistenceImpl.getInstance().marshal(model);
ioService().write(path, xml);
// 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 Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.template.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 1, path);
}
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.template.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
searchFor(index, query, 1, path);
}
}
Aggregations