Search in sources :

Example 31 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project drools-wb by kiegroup.

the class IndexRuleInvalidDrlTest method testIndexRuleInvalidDrl.

@Test
public void testIndexRuleInvalidDrl() throws IOException, InterruptedException {
    // Setup logging
    final Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    final Appender<ILoggingEvent> mockAppender = mock(Appender.class);
    when(mockAppender.getName()).thenReturn("MOCK");
    root.addAppender(mockAppender);
    // Add test files
    final Path path = basePath.resolve("bz1269366.drl");
    final String drl = loadText("bz1269366.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).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.drltext.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
        // should be 1, but parsing fails (see verify line below) so that 0 is returned..
        searchFor(index, query, 0);
        verify(mockAppender).doAppend(argThat(argument -> argument.getMessage().startsWith("Unable to parse DRL")));
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) 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) Logger(ch.qos.logback.classic.Logger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest) Test(org.junit.Test)

Example 32 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project drools-wb by kiegroup.

the class IndexDefaultPackageDslEntriesTest method testDefaultPackageIndexDslEntries.

@Test
public void testDefaultPackageIndexDslEntries() throws IOException, InterruptedException {
    // Add test files
    final Path path1 = basePath.resolve("dsl1.dsl");
    final String dsl1 = loadText("dsl1.dsl");
    ioService().write(path1, dsl1);
    // 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).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueResourceIndexTerm("*", ResourceType.RULE, TermSearchType.WILDCARD)).build();
        searchFor(index, query, 0);
    }
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.dsltext.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path1);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) 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 33 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm 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.tdrl");
    final String drl1 = loadText("drl3.tdrl");
    ioService().write(path1, drl1);
    final Path path2 = basePath.resolve("drl4.tdrl");
    final String drl2 = loadText("drl4.tdrl");
    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).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtree.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.dtree.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path2);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) 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 34 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm 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.tdrl");
    final String drl1 = loadText("drl1.tdrl");
    ioService().write(path1, drl1);
    final Path path2 = basePath.resolve("drl2.tdrl");
    final String drl2 = loadText("drl2.tdrl");
    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).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtree.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);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) 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 35 with ValueReferenceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm in project drools-wb by kiegroup.

the class IndexDecisionTableXLSMultipleTypesTest method testIndexDecisionTableXLSMultipleTypes.

@Test
public void testIndexDecisionTableXLSMultipleTypes() 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).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.dtablexls.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.dtablexls.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
        // Mortgage import statement in both .xls files
        searchFor(index, query, 2, path2);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) 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)

Aggregations

ValueReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)39 Test (org.junit.Test)35 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)35 Path (org.uberfire.java.nio.file.Path)32 Query (org.apache.lucene.search.Query)31 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)31 Import (org.kie.soup.project.datamodel.imports.Import)9 ValuePartReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartReferenceIndexTerm)7 Logger (ch.qos.logback.classic.Logger)5 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)5 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)5 HashSet (java.util.HashSet)4 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)4 ArrayList (java.util.ArrayList)2 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)2 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)2 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 TopScoreDocCollector (org.apache.lucene.search.TopScoreDocCollector)1 ScoreCardModel (org.drools.workbench.models.guided.scorecard.shared.ScoreCardModel)1 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)1