use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexTestScenarioTest method testIndexTestScenario.
@Test
public void testIndexTestScenario() throws IOException, InterruptedException {
// Add test files
final Path path1 = basePath.resolve("scenario1.scenario");
final Scenario model1 = TestScenarioFactory.makeTestScenarioWithVerifyFact("org.drools.workbench.screens.testscenario.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage"));
}
}, "scenario1");
final String xml1 = ScenarioXMLPersistence.getInstance().marshal(model1);
ioService().write(path1, xml1);
final Path path2 = basePath.resolve("scenario2.scenario");
final Scenario model2 = TestScenarioFactory.makeTestScenarioWithoutVerifyFact("org.drools.workbench.screens.testscenario.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage"));
}
}, "scenario2");
final String xml2 = ScenarioXMLPersistence.getInstance().marshal(model2);
ioService().write(path2, xml2);
final Path path3 = basePath.resolve("scenario3.scenario");
final Scenario model3 = TestScenarioFactory.makeTestScenarioWithVerifyRuleFired("org.drools.workbench.screens.testscenario.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage"));
}
}, "scenario3");
final String xml3 = ScenarioXMLPersistence.getInstance().marshal(model3);
ioService().write(path3, xml3);
final Path path4 = basePath.resolve("scenario4.scenario");
final Scenario model4 = TestScenarioFactory.makeTestScenarioWithGlobalVerifyGlobal("org.drools.workbench.screens.testscenario.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("java.util.Date"));
}
}, "scenario1");
final String xml4 = ScenarioXMLPersistence.getInstance().marshal(model4);
ioService().write(path4, xml4);
// 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());
// Test Scenarios using org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Applicant
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 2, path1, path2);
}
// Test Scenarios using org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
searchFor(index, query, 1, path1);
}
// Test Scenarios using org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage#amount
{
final Query query = new SingleTermQueryBuilder(new ValuePartReferenceIndexTerm("org.drools.workbench.screens.testscenario.backend.server.indexing.classes.Mortgage", "amount", PartType.FIELD)).build();
searchFor(index, query, 1, path1);
}
// Test Scenarios using java.lang.Integer
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("java.lang.Integer", ResourceType.JAVA)).build();
searchFor(index, query, 3, path1, path2);
}
// Test Scenarios expecting rule "test" to fire
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("test", ResourceType.RULE)).build();
searchFor(index, query, 1, path3);
}
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("java.util.Date", ResourceType.JAVA)).build();
searchFor(index, query, 1, path4);
}
}
use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexGuidedDecisionTableAttributesTest method testIndexGuidedDecisionTableAttributes.
@Test
public void testIndexGuidedDecisionTableAttributes() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("dtable1.gdst");
final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithAttributeCol("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
}
}, "dtable1");
final String xml = GuidedDTXMLPersistence.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());
// Decision Table defining a RuleFlow-Group named myRuleFlowGroup. This should match dtable1.gdst
// 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);
}
}
use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.
the class IndexGuidedDecisionTableBRLFragmentActionsTest method testIndexGuidedDecisionTableBRLFragmentActions.
@Test
public void testIndexGuidedDecisionTableBRLFragmentActions() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("dtable1.gdst");
final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithBRLFragmentActionCol("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage"));
}
}, "dtable1");
final String xml = GuidedDTXMLPersistence.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.dtable.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 1, path);
}
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtable.backend.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 IndexGuidedDecisionTableBRLFragmentConditionsPredicateTest method checkSingleFieldConstraintPredicate.
@Test
public void checkSingleFieldConstraintPredicate() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("dtable1.gdst");
final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithBRLFragmentConditionColWithPredicate("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage"));
}
}, "dtable1");
final String xml = GuidedDTXMLPersistence.getInstance().marshal(model);
ioService().write(path, xml);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(7500);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant", 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 IndexDecisionTableXLSAttributeNameAndValueCompositionTest method testIndexDecisionTableXLSAttributeNameAndValueComposition.
@Test
public void testIndexDecisionTableXLSAttributeNameAndValueComposition() throws IOException, InterruptedException {
// Add test files
final Path path1 = loadXLSFile(basePath, "dtable3.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());
// Decision Table defining a RuleFlow-Group named myRuleFlowGroup. This should match dtable3.xls
// 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, path1);
}
// Decision Table defining a RuleFlow-Group named myAgendaGroup. This should *NOT* match dtable3.xls
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("myAgendaGroup", PartType.RULEFLOW_GROUP)).build();
searchFor(index, query, 0);
}
}
Aggregations