### Question:
RetrieveQuestionsUtil { public Set<String> getRandomQuestions(Integer num) throws IOException { String filename = "pgQuestions.txt"; Random random = new Random(); ClassLoader classLoader = getClass().getClassLoader(); int numberOfLines = numberOfLinesInFile(filename); BufferedReader reader = new BufferedReader( new InputStreamReader( Objects.requireNonNull(classLoader.getResourceAsStream(filename)))); Set<String> randomQuestions = new HashSet<>(); Set<Integer> randomNumbersSet = new HashSet<>(); while(randomNumbersSet.size() < num) { randomNumbersSet.add(random.nextInt(numberOfLines)); } List<Integer> randomNumbersList = new ArrayList<>(randomNumbersSet); sort(randomNumbersList); int lineNumber = 0; while (randomNumbersList.size() > 0) { String line = reader.readLine(); if (randomNumbersList.get(0).equals(lineNumber)) { randomQuestions.add(line); LOGGER.debug(String.format("Adding question: %s", line)); randomNumbersList.remove(0); } lineNumber += 1; } return randomQuestions; }  Set<String> getRandomQuestions(Integer num);  }### Answer:
@Test public void givenAPositiveNumber_whenCallingGetRandomQuestions_thenReturnThatManyUniqueQuestions() throws IOException { Set<String> questions = retrieveQuestionsUtil.getRandomQuestions(5); assertEquals(5, questions.size()); }
@Test public void givenANegativeNumberOrZero_whenCallingGetRandomQuestions_thenReturnAnEmptySet() throws IOException { assertEquals(new HashSet<>(), retrieveQuestionsUtil.getRandomQuestions(-20)); assertEquals(new HashSet<>(), retrieveQuestionsUtil.getRandomQuestions(0)); }