GuidedDecisionTableGraphEditorServiceImpl extends KieService<GuidedDecisionTableEditorGraphContent> implements GuidedDecisionTableGraphEditorService { @Override public List<Path> listDecisionTablesInPackage(final Path path) { try { final Package pkg = moduleService.resolvePackage(path); if (pkg == null) { return Collections.emptyList(); } final Path pkgPath = pkg.getPackageMainResourcesPath(); final org.uberfire.java.nio.file.Path nioPkgPath = Paths.convert(pkgPath); final List<Path> paths = findDecisionTables(nioPkgPath); return paths; } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } GuidedDecisionTableGraphEditorServiceImpl(); @Inject  GuidedDecisionTableGraphEditorServiceImpl(final @Named("ioStrategy") IOService ioService,
                                                     final CopyService copyService,
                                                     final DeleteService deleteService,
                                                     final RenameService renameService,
                                                     final KieModuleService moduleService,
                                                     final VersionRecordService versionRecordService,
                                                     final GuidedDecisionTableEditorService dtableService,
                                                     final GuidedDecisionTableLinkManager dtableLinkManager,
                                                     final Event<ResourceOpenedEvent> resourceOpenedEvent,
                                                     final CommentedOptionFactory commentedOptionFactory,
                                                     final GuidedDTableResourceTypeDefinition resourceType,
                                                     final DotFileFilter dotFileFilter,
                                                     final SessionInfo sessionInfo); @Override Path create(final Path context,
                       final String fileName,
                       final GuidedDecisionTableEditorGraphModel model,
                       final String comment); @Override GuidedDecisionTableEditorGraphModel load(final Path path); @Override GuidedDecisionTableEditorGraphContent loadContent(final Path path); @Override Path save(final Path path,
                     final GuidedDecisionTableEditorGraphModel model,
                     final Metadata metadata,
                     final String comment); @Override void delete(final Path path,
                       final String comment); @Override Path rename(final Path path,
                       final String newName,
                       final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final Path targetDirectory,
                     final String comment); @Override List<Path> listDecisionTablesInPackage(final Path path);  }
@Test public void testListDecisionTablesInPackage() { final Path path = mock(Path.class); when(path.toURI()).thenReturn("file: resolvedPaths.add(makeNioPath("file: resolvedPaths.add(makeNioPath("file: resolvedPaths.add(makeNioPath("file: resolvedPaths.add(makeNioPath("file: final List<Path> paths = service.listDecisionTablesInPackage(path); assertNotNull(paths); assertEquals(3, paths.size()); final Set<String> fileNames = new HashSet<>(); fileNames.addAll(paths.stream().collect(Collectors.mapping(Path::getFileName, Collectors.toSet()))); assertTrue(fileNames.contains("dtable1.gdst")); assertTrue(fileNames.contains("dtable2.gdst")); assertTrue(fileNames.contains("dtable3.gdst")); }
@Test public void testListDecisionTablesInPackageExcludesDotFiles() { final Path path = mock(Path.class); when(path.toURI()).thenReturn("file: resolvedPaths.add(makeNioPath("file: resolvedPaths.add(makeNioPath("file: final List<Path> paths = service.listDecisionTablesInPackage(path); assertNotNull(paths); assertEquals(1, paths.size()); final Set<String> fileNames = new HashSet<>(); fileNames.addAll(paths.stream().collect(Collectors.mapping(Path::getFileName, Collectors.toSet()))); assertTrue(fileNames.contains("dtable1.gdst")); }