Search in sources :

Example 6 with QueryOperationRequest

use of org.kie.workbench.common.services.refactoring.service.impact.QueryOperationRequest in project kie-wb-common by kiegroup.

the class QueryOperationRequestTest method workingCodeTest.

// Tests ----------------------------------------------------------------------------------------------------------------------
@Test
public void workingCodeTest() throws Exception {
    // Add test files
    final Path path1 = basePath.resolve("drl1.drl");
    final String drl1 = loadText("drl1.drl");
    ioService().write(path1, drl1);
    final Path path2 = basePath.resolve("drl2.drl");
    final String drl2 = loadText("drl2.drl");
    ioService().write(path2, drl2);
    final Path path3 = basePath.resolve("drl3.drl");
    final String drl3 = loadText("drl3.drl");
    ioService().write(path3, drl3);
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(5000);
    {
        QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("myRuleFlowGroup", PartType.RULEFLOW_GROUP).inAllModules().onAllBranches();
        try {
            final List<RefactoringPageRow> response = service.queryToList(request);
            assertNotNull(response);
            assertEquals(2, response.size());
            assertResponseContains(response, path1);
            assertResponseContains(response, path3);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
    {
        QueryOperationRequest request = QueryOperationRequest.referencesSharedPart("*", PartType.RULEFLOW_GROUP, TermSearchType.WILDCARD).inAllModules().onAllBranches();
        try {
            final List<RefactoringPageRow> response = service.queryToList(request);
            assertNotNull(response);
            assertEquals(3, response.size());
            assertResponseContains(response, path1);
            assertResponseContains(response, path2);
            assertResponseContains(response, path3);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) QueryOperationRequest(org.kie.workbench.common.services.refactoring.service.impact.QueryOperationRequest) List(java.util.List) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest) Test(org.junit.Test)

Aggregations

QueryOperationRequest (org.kie.workbench.common.services.refactoring.service.impact.QueryOperationRequest)6 Test (org.junit.Test)5 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)5 List (java.util.List)3 Path (org.uberfire.java.nio.file.Path)3 RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Inject (javax.inject.Inject)1 Service (org.jboss.errai.bus.server.annotations.Service)1 AnnotationValuesAnnotation (org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation)1 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)1 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)1 AssetsUsageService (org.kie.workbench.common.services.refactoring.service.AssetsUsageService)1 PartType (org.kie.workbench.common.services.refactoring.service.PartType)1 RefactoringQueryService (org.kie.workbench.common.services.refactoring.service.RefactoringQueryService)1