Search in sources :

Example 6 with SingleTermQueryBuilder

use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.

the class IndexEnumEntriesTest method testIndexEnumEntries.

@Test
public void testIndexEnumEntries() throws IOException, InterruptedException {
    // Add test files
    final Path path1 = basePath.resolve("enum1.enumeration");
    final String dsl1 = loadText("enum1.enumeration");
    ioService().write(path1, dsl1);
    final Path path2 = basePath.resolve("enum2.enumeration");
    final String dsl2 = loadText("enum2.enumeration");
    ioService().write(path2, dsl2);
    final Path path3 = basePath.resolve("enum3.enumeration");
    final String dsl3 = loadText("enum3.enumeration");
    ioService().write(path3, dsl3);
    // 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());
    // Enumerations using org.drools.workbench.screens.enums.backend.server.indexing.classes.Applicant
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.enums.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 2, path1, path2);
    }
    // Enumerations using org.drools.workbench.screens.enums.backend.server.indexing.classes.Mortgage
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.enums.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path2);
    }
    // Enumerations using org.drools.workbench.screens.enums.backend.server.indexing.classes.Mortgage#amount
    {
        final Query query = new SingleTermQueryBuilder(new ValuePartReferenceIndexTerm("org.drools.workbench.screens.enums.backend.server.indexing.classes.Mortgage", "amount", PartType.FIELD)).build();
        searchFor(index, query, 1, path2);
    }
    // Enumerations using java.lang.Integer
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("java.lang.Integer", ResourceType.JAVA)).build();
        searchFor(index, query, 2, path1, path2);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValuePartReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePartReferenceIndexTerm) 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 7 with SingleTermQueryBuilder

use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.

the class IndexGlobalsInvalidDrlTest method testIndexGlobalsInvalidDrl.

@Test
@SuppressWarnings("unchecked")
public void testIndexGlobalsInvalidDrl() 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 file
    final Path path = basePath.resolve("bz1269366.gdrl");
    final String drl = loadText("bz1269366.gdrl");
    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 Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("java.util.ArrayList", ResourceType.JAVA)).build();
        searchFor(index, query, 0);
        verify(mockAppender).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {

            @Override
            public boolean matches(final Object argument) {
                return ((ILoggingEvent) 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) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 8 with SingleTermQueryBuilder

use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.

the class IndexGlobalsTest method testIndexGlobals.

@Test
public void testIndexGlobals() throws IOException, InterruptedException {
    // Add test files
    final Path path1 = basePath.resolve("global1.gdrl");
    final String drl1 = loadText("global1.gdrl");
    ioService().write(path1, drl1);
    final Path path2 = basePath.resolve("global2.gdrl");
    final String drl2 = loadText("global2.gdrl");
    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("java.util.ArrayList", ResourceType.JAVA)).build();
        searchFor(index, query, 2, path1, 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 9 with SingleTermQueryBuilder

use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.

the class IndexDslEntriesTest method testIndexDslEntries.

@Test
public void testIndexDslEntries() throws IOException, InterruptedException {
    // Add test files
    final Path path1 = basePath.resolve("dsl1.dsl");
    final String dsl1 = loadText("dsl1.dsl");
    ioService().write(path1, dsl1);
    final Path path2 = basePath.resolve("dsl2.dsl");
    final String dsl2 = loadText("dsl2.dsl");
    ioService().write(path2, dsl2);
    // 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 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, 2, path1, path2);
    }
    {
        final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.dsltext.backend.server.indexing.classes.Mortgage", ResourceType.JAVA)).build();
        searchFor(index, query, 1, path2);
    }
}
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 10 with SingleTermQueryBuilder

use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder in project drools-wb by kiegroup.

the class IndexDslInvalidDrlTest method testIndexDslInvalidDrl.

@Test
public void testIndexDslInvalidDrl() 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.dsl");
    final String dsl = loadText("bz1269366.dsl");
    ioService().write(path, dsl);
    // 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.dsltext.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
        searchFor(index, query, 0);
        verify(mockAppender).doAppend(argThat(new ArgumentMatcher<ILoggingEvent>() {

            @Override
            public boolean matches(final Object argument) {
                return ((ILoggingEvent) 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) 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