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;
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleImplResolveModuleValidTest method testResolveModuleWithRootPath.
@Test
public void testResolveModuleWithRootPath() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
// Test a root resolves to the Module's root
final Module result = moduleService.resolveModule(rootPath);
assertEquals(rootPath.toURI(), result.getRootPath().toURI());
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleImplResolveModuleValidTest method testResolveModuleWithResourcesFile.
@Test
public void testResolveModuleWithResourcesFile() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/resources/rule1.drl");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
// Test a child folder resolves to the Module's root
final Module result = moduleService.resolveModule(testPath);
assertEquals(rootPath.toURI(), result.getRootPath().toURI());
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleImplResolveModuleValidTest method testResolveModuleWithGlobalFile.
@Test
public void testResolveModuleWithGlobalFile() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/global/themes.json");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
// Test a child folder resolves to the Module's root
final Module result = moduleService.resolveModule(testPath);
assertEquals(rootPath.toURI(), result.getRootPath().toURI());
}
use of org.kie.workbench.common.services.shared.project.KieModuleService in project kie-wb-common by kiegroup.
the class ModuleServiceImplResolvePackageInvalidNoKModuleTest method testResolvePackageDefaultResources.
@Test
public void testResolvePackageDefaultResources() throws Exception {
final Bean moduleServiceBean = (Bean) beanManager.getBeans(KieModuleService.class).iterator().next();
final CreationalContext cc = beanManager.createCreationalContext(moduleServiceBean);
final KieModuleService moduleService = (KieModuleService) beanManager.getReference(moduleServiceBean, KieModuleService.class, cc);
final URL rootUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureInvalidNoKModule/src/main/resources");
final org.uberfire.java.nio.file.Path nioRootPath = fs.getPath(rootUrl.toURI());
final Path rootPath = paths.convert(nioRootPath);
final URL testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureInvalidNoKModule/src/main/resources");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
// Test a non-Project Path resolves to null
final Package result = moduleService.resolvePackage(testPath);
assertNull(result);
}
Aggregations