use of java.nio.file.PathMatcher in project che by eclipse.
the class BaseTest method initProjectApi.
@BeforeMethod
protected void initProjectApi() throws Exception {
mavenServerManager = new MavenServerManager(mavenServerPath);
workspaceHolder = new TestWorkspaceHolder();
if (root == null)
root = new File(wsPath);
if (root.exists()) {
IoUtil.deleteRecursive(root);
}
root.mkdir();
File indexDir = new File(INDEX_PATH);
if (indexDir.exists()) {
IoUtil.deleteRecursive(indexDir);
}
indexDir.mkdir();
Set<PathMatcher> filters = new HashSet<>();
filters.add(path -> true);
FSLuceneSearcherProvider sProvider = new FSLuceneSearcherProvider(indexDir, filters);
vfsProvider = new LocalVirtualFileSystemProvider(root, sProvider);
projectTypeRegistry = new ProjectTypeRegistry(new HashSet<>());
projectTypeRegistry.registerProjectType(new TestProjectType());
projectTypeRegistry.registerProjectType(new JavaProjectType(new JavaValueProviderFactory()));
projectTypeRegistry.registerProjectType(new MavenProjectType(new MavenValueProviderFactory()));
projectHandlerRegistry = new ProjectHandlerRegistry(new HashSet<>());
projectRegistry = new ProjectRegistry(workspaceHolder, vfsProvider, projectTypeRegistry, projectHandlerRegistry, eventService);
projectRegistry.initProjects();
importerRegistry = new ProjectImporterRegistry(new HashSet<>());
fileWatcherNotificationHandler = new DefaultFileWatcherNotificationHandler(vfsProvider);
fileTreeWatcher = new FileTreeWatcher(root, new HashSet<>(), fileWatcherNotificationHandler);
pm = new ProjectManager(vfsProvider, projectTypeRegistry, projectRegistry, projectHandlerRegistry, importerRegistry, fileWatcherNotificationHandler, fileTreeWatcher, new TestWorkspaceHolder(new ArrayList<>()), mock(FileWatcherManager.class));
plugin = new ResourcesPlugin("target/index", wsPath, () -> projectRegistry, () -> pm);
plugin.start();
javaPlugin.start();
}
use of java.nio.file.PathMatcher in project che by eclipse.
the class FileWatcherUtilsTest method shouldBeExcluded.
@Test
public void shouldBeExcluded() throws Exception {
PathMatcher matcher = Mockito.mock(PathMatcher.class);
Path path = Mockito.mock(Path.class);
when(matcher.matches(path)).thenReturn(true);
boolean condition = isExcluded(singleton(matcher), path);
assertTrue(condition);
}
use of java.nio.file.PathMatcher in project che by eclipse.
the class FileWatcherUtilsTest method shouldNotBeExcluded.
@Test
public void shouldNotBeExcluded() throws Exception {
PathMatcher matcher = Mockito.mock(PathMatcher.class);
Path path = Mockito.mock(Path.class);
when(matcher.matches(path)).thenReturn(false);
boolean condition = isExcluded(singleton(matcher), path);
assertFalse(condition);
}
use of java.nio.file.PathMatcher in project buck by facebook.
the class FakeProjectFilesystem method getMtimeSortedMatchingDirectoryContents.
@Override
public ImmutableSortedSet<Path> getMtimeSortedMatchingDirectoryContents(final Path pathRelativeToProjectRoot, String globPattern) throws IOException {
Preconditions.checkState(isDirectory(pathRelativeToProjectRoot));
final PathMatcher pathMatcher = FileSystems.getDefault().getPathMatcher("glob:" + globPattern);
return fileContents.keySet().stream().filter(i -> i.getParent().equals(pathRelativeToProjectRoot) && pathMatcher.matches(i.getFileName())).sorted((f0, f1) -> {
try {
return getLastModifiedTimeFetcher().getLastModifiedTime(f1).compareTo(getLastModifiedTimeFetcher().getLastModifiedTime(f0));
} catch (IOException e) {
throw new RuntimeException(e);
}
}).collect(MoreCollectors.toImmutableSortedSet());
}
use of java.nio.file.PathMatcher in project jimfs by google.
the class AbstractPathMatcherTest method assertSyntaxError.
protected void assertSyntaxError(String pattern) {
try {
matcher(pattern);
fail();
} catch (PatternSyntaxException expected) {
}
try {
PathMatcher real = realMatcher(pattern);
if (real != null) {
fail();
}
} catch (PatternSyntaxException expected) {
}
}
Aggregations