use of org.cryptomator.ui.launcher.AppLaunchEvent in project cryptomator by cryptomator.
the class FileOpenRequestHandlerTest method testOpenArgsWithFullQueue.
@Test
@DisplayName("./cryptomator.exe foo (with full event queue)")
public void testOpenArgsWithFullQueue() {
queue.add(new AppLaunchEvent(AppLaunchEvent.EventType.OPEN_FILE, Collections.emptyList()));
Assumptions.assumeTrue(queue.remainingCapacity() == 0);
inTest.handleLaunchArgs(List.of("foo"));
}
use of org.cryptomator.ui.launcher.AppLaunchEvent in project cryptomator by cryptomator.
the class FileOpenRequestHandlerTest method testOpenArgsWithCorrectPaths.
@Test
@DisplayName("./cryptomator.exe foo bar")
public void testOpenArgsWithCorrectPaths() {
inTest.handleLaunchArgs(List.of("foo", "bar"));
AppLaunchEvent evt = queue.poll();
Assertions.assertNotNull(evt);
Collection<Path> paths = evt.getPathsToOpen();
MatcherAssert.assertThat(paths, CoreMatchers.hasItems(Paths.get("foo"), Paths.get("bar")));
}
use of org.cryptomator.ui.launcher.AppLaunchEvent in project cryptomator by cryptomator.
the class FileOpenRequestHandlerTest method testOpenArgsWithIncorrectPaths.
@Test
@DisplayName("./cryptomator.exe foo (with 'foo' being an invalid path)")
public void testOpenArgsWithIncorrectPaths() {
FileSystem fs = Mockito.mock(FileSystem.class);
Mockito.when(fs.getPath("foo")).thenThrow(new InvalidPathException("foo", "foo is not a path"));
inTest.handleLaunchArgs(fs, List.of("foo"));
AppLaunchEvent evt = queue.poll();
Assertions.assertNull(evt);
}
use of org.cryptomator.ui.launcher.AppLaunchEvent in project cryptomator by cryptomator.
the class FileOpenRequestHandler method handleLaunchArgs.
// visible for testing
void handleLaunchArgs(FileSystem fs, List<String> args) {
Collection<Path> pathsToOpen = args.stream().map(str -> {
try {
return fs.getPath(str);
} catch (InvalidPathException e) {
LOG.trace("Argument not a valid path: {}", str);
return null;
}
}).filter(Objects::nonNull).toList();
if (!pathsToOpen.isEmpty()) {
AppLaunchEvent launchEvent = new AppLaunchEvent(AppLaunchEvent.EventType.OPEN_FILE, pathsToOpen);
tryToEnqueueFileOpenRequest(launchEvent);
}
}
use of org.cryptomator.ui.launcher.AppLaunchEvent in project cryptomator by cryptomator.
the class FileOpenRequestHandler method openFiles.
private void openFiles(OpenFilesEvent evt) {
Collection<Path> pathsToOpen = evt.getFiles().stream().map(File::toPath).toList();
AppLaunchEvent launchEvent = new AppLaunchEvent(AppLaunchEvent.EventType.OPEN_FILE, pathsToOpen);
tryToEnqueueFileOpenRequest(launchEvent);
}
Aggregations