### Question:
SaveQueryResults { public boolean isDirectoryValid() { final File file = new File(this.outputQueryResultDirectory); return !file.exists() || file.isDirectory(); } SaveQueryResults();  SaveQueryResults(final boolean saveResults, final String outputDir); boolean isConfigurationValid(); boolean isDirectoryValid(); boolean isSaveResults(); void setSaveResults(final boolean saveResults); String getOutputQueryResultDirectory(); void setOutputQueryResultDirectory(final String outputQueryResultDirectory); static final String DEFAULT_OUTPUT_DIR_NAME; }### Answer:
@Test public void isDirectoryValid_nonExistingDirectory_valid() throws IOException { File nonExistingDirectory = tempFolder.newFolder("folderPath"); nonExistingDirectory.delete(); SaveQueryResults temp = new SaveQueryResults(true, nonExistingDirectory.getAbsolutePath()); assertTrue(temp.isDirectoryValid()); }
@Test public void isDirectoryValid_existingFile_nonValid() throws IOException { File existingFile = tempFolder.newFile("filePath"); existingFile.createNewFile(); SaveQueryResults temp = new SaveQueryResults(true, existingFile.getAbsolutePath()); assertFalse(temp.isDirectoryValid()); }