Search in sources :

Example 6 with ValueResourceIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm 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.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, 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 7 with ValueResourceIndexTerm

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

the class IndexRuleTest method testIndexDrlRules.

@Test
public void testIndexDrlRules() throws IOException, InterruptedException {
    // Add test files
    Path path = basePath.resolve("drl1.drl");
    String drl = loadText("drl1.drl");
    ioService().write(path, drl);
    path = basePath.resolve("drl2.drl");
    drl = loadText("drl2.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.getFileSystem()).getClusterId());
    {
        final Query query = new SingleTermQueryBuilder(new ValueResourceIndexTerm("myRule", ResourceType.RULE)).build();
        searchFor(index, query, 1);
    }
    {
        final Query query = new SingleTermQueryBuilder(new ValueResourceIndexTerm("org.drools.workbench.screens.drltext.backend.server.indexing.classes.myRule", ResourceType.RULE)).build();
        searchFor(index, query, 1);
    }
}
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) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

Query (org.apache.lucene.search.Query)7 Test (org.junit.Test)7 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)7 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)7 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)7 Path (org.uberfire.java.nio.file.Path)7 Logger (ch.qos.logback.classic.Logger)2 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)2 ValueReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)2