UserProfileContext extends GraphicalContext<BorderPane> { static List<String> findAllUsersProfiles() { final File profilesDirectory = GazePlayDirectories.getProfilesDirectory(); log.info("profilesDirectory = {}", profilesDirectory); final File[] directoryContent = profilesDirectory.listFiles(); if (directoryContent == null) { return Collections.emptyList(); } final List<String> listOfUsers = Arrays.stream(directoryContent) .filter(f -> !f.isHidden()) .filter(File::isDirectory) .map(File::getName) .sorted() .collect(Collectors.toList()); log.info("FULL LIST OF GAZEPLAY USERS: " + listOfUsers); return listOfUsers; } UserProfileContext(final GazePlay gazePlay); @Override ObservableList<Node> getChildren();  }
@Test void shouldFindAllUsersProfiles() { new MockUp<GazePlayDirectories>() { @mockit.Mock public File getProfilesDirectory() { return new File(profileRoot); } }; List<String> result = UserProfileContext.findAllUsersProfiles(); assertTrue(result.contains(profileDirectory)); assertFalse(result.contains(hiddenDirectory)); assertFalse(result.contains(exampleFile)); }
@Test void shouldReturnEmptyListIfNoProfiles() { new MockUp<GazePlayDirectories>() { @mockit.Mock public File getProfilesDirectory() { return new File("bad/path"); } }; List<String> result = UserProfileContext.findAllUsersProfiles(); assertEquals(Collections.emptyList(), result); }