Search in sources :

Example 41 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class BaseLibraryIndexingTest method getModuleService.

protected KieModuleService getModuleService() {
    final Package mockPackage = mock(Package.class);
    when(mockPackage.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
    final KieModuleService mockModuleService = mock(KieModuleService.class);
    when(mockModuleService.resolvePackage(any(org.uberfire.backend.vfs.Path.class))).thenReturn(mockPackage);
    return mockModuleService;
}
Also used : Path(org.uberfire.java.nio.file.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Package(org.guvnor.common.services.project.model.Package)

Example 42 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class FindAllLibraryAssetsQueryTest method getModuleService.

@Override
protected KieModuleService getModuleService() {
    final KieModuleService moduleService = super.getModuleService();
    when(moduleService.resolveModule(any(org.uberfire.backend.vfs.Path.class))).thenAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            org.uberfire.backend.vfs.Path resource = (org.uberfire.backend.vfs.Path) invocationOnMock.getArguments()[0];
            if (resource.toURI().contains(TEST_MODULE_ROOT)) {
                return getKieModuleMock(TEST_MODULE_ROOT, TEST_MODULE_NAME);
            } else if (resource.toURI().contains(SOME_OTHER_MODULE_ROOT)) {
                return getKieModuleMock(SOME_OTHER_MODULE_ROOT, SOME_OTHER_MODULE_NAME);
            } else {
                return null;
            }
        }
    });
    return moduleService;
}
Also used : KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) KObject(org.uberfire.ext.metadata.model.KObject)

Example 43 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class FindAllLibraryAssetsSortedQueryTest method getModuleService.

@Override
protected KieModuleService getModuleService() {
    final KieModuleService mock = super.getModuleService();
    when(mock.resolveModule(any(Path.class))).thenAnswer((Answer) invocationOnMock -> {
        Path resource = (Path) invocationOnMock.getArguments()[0];
        if (resource.toURI().contains(TEST_PROJECT_ROOT1)) {
            return getKieModuleMock(TEST_PROJECT_ROOT1, TEST_PROJECT_NAME1);
        } else if (resource.toURI().contains(TEST_PROJECT_ROOT2)) {
            return getKieModuleMock(TEST_PROJECT_ROOT2, TEST_PROJECT_NAME2);
        } else {
            return null;
        }
    });
    return mock;
}
Also used : Path(org.uberfire.backend.vfs.Path) ResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.ResponseBuilder) Set(java.util.Set) IOException(java.io.IOException) Test(org.junit.Test) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) TermSearchType(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm.TermSearchType) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Matchers.any(org.mockito.Matchers.any) Answer(org.mockito.stubbing.Answer) Mockito(org.mockito.Mockito) RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) NamedQuery(org.kie.workbench.common.services.refactoring.backend.server.query.NamedQuery) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) DefaultResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder) Assert(org.junit.Assert) Path(org.uberfire.backend.vfs.Path) PageResponse(org.uberfire.paging.PageResponse) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService)

Example 44 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class IndexingTest method getModuleService.

protected KieModuleService getModuleService() {
    final KieModule mockModule = getKieModuleMock(TEST_MODULE_ROOT, TEST_MODULE_NAME);
    final Package mockPackage = mock(Package.class);
    when(mockPackage.getPackageName()).thenReturn(TEST_PACKAGE_NAME);
    final KieModuleService mockWorkspaceProjectService = mock(KieModuleService.class);
    when(mockWorkspaceProjectService.resolveModule(any(org.uberfire.backend.vfs.Path.class))).thenReturn(mockModule);
    when(mockWorkspaceProjectService.resolvePackage(any(org.uberfire.backend.vfs.Path.class))).thenReturn(mockPackage);
    return mockWorkspaceProjectService;
}
Also used : Path(org.uberfire.java.nio.file.Path) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Package(org.guvnor.common.services.project.model.Package) KieModule(org.kie.workbench.common.services.shared.project.KieModule)

Example 45 with KieModuleService

use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.

the class FindRulesByModuleQueryValidIndexTermsTest method getModuleService.

@Override
protected KieModuleService getModuleService() {
    final KieModuleService mock = super.getModuleService();
    when(mock.resolveModule(any(org.uberfire.backend.vfs.Path.class))).thenAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            org.uberfire.backend.vfs.Path resource = (org.uberfire.backend.vfs.Path) invocationOnMock.getArguments()[0];
            if (resource.toURI().contains(TEST_MODULE_ROOT)) {
                return getKieModuleMock(TEST_MODULE_ROOT, TEST_MODULE_NAME);
            } else if (resource.toURI().contains(SOME_OTHER_PROJECT_ROOT)) {
                return getKieModuleMock(SOME_OTHER_PROJECT_ROOT, SOME_OTHER_PROJECT_NAME);
            } else {
                return null;
            }
        }
    });
    return mock;
}
Also used : KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Aggregations

KieModuleService (org.kie.workbench.common.services.shared.project.KieModuleService)75 CreationalContext (javax.enterprise.context.spi.CreationalContext)66 Bean (javax.enterprise.inject.spi.Bean)66 Test (org.junit.Test)66 Path (org.uberfire.backend.vfs.Path)59 URL (java.net.URL)58 Package (org.guvnor.common.services.project.model.Package)49 Module (org.guvnor.common.services.project.model.Module)16 Before (org.junit.Before)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 KieModule (org.kie.workbench.common.services.shared.project.KieModule)3 Answer (org.mockito.stubbing.Answer)3 Path (org.uberfire.java.nio.file.Path)3 Set (java.util.Set)2 POM (org.guvnor.common.services.project.model.POM)2 FolderItem (org.kie.workbench.common.screens.explorer.model.FolderItem)2 FolderListing (org.kie.workbench.common.screens.explorer.model.FolderListing)2 ActiveOptions (org.kie.workbench.common.screens.explorer.service.ActiveOptions)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1