Search in sources :

Example 1 with SingleTermQueryBuilder

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValuePartReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartReferenceIndexTerm) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 2 with SingleTermQueryBuilder

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 3 with SingleTermQueryBuilder

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 4 with SingleTermQueryBuilder

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Import(org.kie.soup.project.datamodel.imports.Import) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 5 with SingleTermQueryBuilder

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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) Query(org.apache.lucene.search.Query) SingleTermQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

Query (org.apache.lucene.search.Query)38 Test (org.junit.Test)38 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)38 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)38 Path (org.uberfire.java.nio.file.Path)37 ValueReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)23 Import (org.kie.soup.project.datamodel.imports.Import)11 ValueSharedPartIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm)10 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)7 Logger (ch.qos.logback.classic.Logger)6 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)6 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)3 ValuePartReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartReferenceIndexTerm)3 ScoreCardModel (org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel)1 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)1 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)1