本文整理了Java中org.guvnor.common.services.project.model.Package.getPackageName()
方法的一些代码示例,展示了Package.getPackageName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Package.getPackageName()
方法的具体详情如下:
包路径:org.guvnor.common.services.project.model.Package
类名称:Package
方法名:getPackageName
暂无
代码示例来源:origin: org.kie.workbench.widgets/kie-wb-common-ui
private List<Package> getSortedPackages(final boolean includeDefaultPackage,
final Set<Package> pkgs) {
final List<Package> sortedPackages = new ArrayList<>(pkgs);
Collections.sort(sortedPackages,
(p1, p2) -> p1.getCaption().compareTo(p2.getCaption()));
// Remove default package, if not required (after sorting it is guaranteed to be at index 0)
if (!includeDefaultPackage
&& !sortedPackages.isEmpty()
&& "".equals(sortedPackages.get(0).getPackageName())) {
sortedPackages.remove(0);
}
return sortedPackages;
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
private String getFullyQualifiedClassName(final Path path) {
final Package pkg = moduleService.resolvePackage(Paths.convert(path));
final String packageName = pkg.getPackageName();
if (packageName == null) {
return null;
}
final String className = path.getFileName().toString().replace(".java",
"");
return (packageName.equals("") ? className : packageName + "." + className);
}
代码示例来源:origin: org.kie.workbench.widgets/kie-wb-common-ui
@Override
public String getPackageName() {
if (packageListBox.getSelectedPackage() != null) {
return packageListBox.getSelectedPackage().getPackageName();
}
return null;
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-refactoring-backend
/**
* Delegate resolution of package name to method to assist testing
* @param path The {@link Path} of the file being indexed
* @return The package name, as a {@link String}
*/
protected String getPackageName(final Path path) {
return moduleService.resolvePackage(Paths.convert(path)).getPackageName();
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-data-modeller-backend
@Override
protected Package getPackage(final Path path) {
final org.guvnor.common.services.project.model.Package mockPackage = mock(Package.class);
when(mockPackage.getPackageName()).thenReturn(BaseIndexingTest.TEST_PACKAGE_NAME);
return mockPackage;
}
}
代码示例来源:origin: org.drools/drools-wb-test-scenario-editor-backend
protected String getPackageName(final Path path) {
return moduleService.resolvePackage(Paths.convert(path)).getPackageName();
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Override
public boolean accept(Path path) {
if (!accept(path.getFileName())) {
return false;
}
Package currentPackage = moduleService.resolvePackage(path);
return currentPackage != null && !"".equals(currentPackage.getPackageName());
}
代码示例来源:origin: kiegroup/drools-wb
protected String getPackageName(final Path path) {
return moduleService.resolvePackage(Paths.convert(path)).getPackageName();
}
代码示例来源:origin: org.kie.workbench.widgets/kie-wb-common-ui
private void addPackagesToSelect(final List<Package> sortedPackages,
final Package activePackage) {
final Map<String, String> packageNames = new HashMap<>();
for (Package pkg : sortedPackages) {
packageNames.put(pkg.getCaption(),
pkg.getPackageName());
packages.put(pkg.getCaption(),
pkg);
}
selectedPackage = getSelectedPackage(activePackage,
packageNames);
view.setUp(selectedPackage,
packageNames);
}
代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-library-backend
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;
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-refactoring-backend
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;
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolvePackageWithResourcesFileInSubPackage() 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 testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/resources/org/kie/test/rule1.drl");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
//Test a Resources file resolves to the containing package
final Package result = moduleService.resolvePackage(testPath);
assertEquals("org.kie.test",
result.getPackageName());
}
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolvePackageDefaultJava() 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 testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
//Test /src/main/java resolves as the default package
final Package result = moduleService.resolvePackage(testPath);
assertEquals("",
result.getPackageName());
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@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 testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/resources");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
//Test /src/main/resources resolves as the default package
final Package result = moduleService.resolvePackage(testPath);
assertEquals("",
result.getPackageName());
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolvePackageWithJavaFileInDefaultPackage() 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 testUrl = this.getClass().getResource("/ModuleBackendTestModuleStructureValid/src/main/java/Bean.java");
final org.uberfire.java.nio.file.Path nioTestPath = fs.getPath(testUrl.toURI());
final Path testPath = paths.convert(nioTestPath);
//Test a Java file resolves to the containing package
final Package result = moduleService.resolvePackage(testPath);
assertEquals("",
result.getPackageName());
}
代码示例来源:origin: org.kie.workbench.services/kie-wb-common-services-backend
@Test
public void testResolvePackageWithResourcesFileInDefaultPackage() 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 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 Resources file resolves to the containing package
final Package result = moduleService.resolvePackage(testPath);
assertEquals("",
result.getPackageName());
}
代码示例来源:origin: org.drools/drools-wb-test-scenario-editor-backend
@Test
public void loadBrokenScenario() throws
Exception {
final Package pgk = mock(Package.class);
when(pgk.getPackageName()).thenReturn("org.test");
when(moduleService.resolvePackage(path)).thenReturn(pgk);
final Scenario load = testEditorService.load(path);
assertNotNull(load);
assertEquals("org.test",
load.getPackageName());
assertNotNull(load.getImports());
}
代码示例来源:origin: kiegroup/drools-wb
@Test
public void loadBrokenScenario() throws
Exception {
final Package pgk = mock(Package.class);
when(pgk.getPackageName()).thenReturn("org.test");
when(moduleService.resolvePackage(path)).thenReturn(pgk);
final Scenario load = testEditorService.load(path);
assertNotNull(load);
assertEquals("org.test",
load.getPackageName());
assertNotNull(load.getImports());
}
代码示例来源:origin: kiegroup/drools-wb
@Override
public void create( final Package pkg,
final String baseFileName,
final NewResourcePresenter presenter ) {
busyIndicatorView.showBusyIndicator( CommonConstants.INSTANCE.Saving() );
service.call(
getSuccessCallback( presenter ),
new HasBusyIndicatorDefaultErrorCallback( busyIndicatorView ) ).create( pkg.getPackageTestResourcesPath(),
buildFileName( baseFileName,
resourceType ),
new Scenario( pkg.getPackageName(),
baseFileName ),
"" );
}
代码示例来源:origin: kiegroup/drools-wb
@Override
public void create(final Package pkg,
final String baseFileName,
final NewResourcePresenter presenter) {
final ScoreCardModel model = new ScoreCardModel();
model.setName(baseFileName);
model.setPackageName(pkg.getPackageName());
busyIndicatorView.showBusyIndicator(CommonConstants.INSTANCE.Saving());
scoreCardService.call(getSuccessCallback(presenter),
new HasBusyIndicatorDefaultErrorCallback(busyIndicatorView)).create(pkg.getPackageMainResourcesPath(),
buildFileName(baseFileName,
resourceType),
model,
"");
}
}
内容来源于网络,如有侵权,请联系作者删除!