### Question:
BrowsableDirectoryField extends BrowsableField { @Override void setTextFromFile(File inputFile) { if (inputFile != null) { if (inputFile.isDirectory()) { getTextField().setText(inputFile.getAbsolutePath()); } else { getTextField().setText(inputFile.getParent()); } getTextField().validate(); } } BrowsableDirectoryField();   }### Answer:
@Test public void setTextFromFile() throws IOException { File inputFile = folder.newFile(); BrowsableDirectoryField victim = new BrowsableDirectoryField(); victim.setTextFromFile(inputFile); assertEquals(inputFile.getParent(), victim.getTextField().getText()); }
@Test public void setTextFromNullFile() { BrowsableDirectoryField victim = new BrowsableDirectoryField(); victim.setTextFromFile(null); FxAssert.verifyThat(victim, v -> isBlank(v.getTextField().getText())); }
@Test public void setTextFromDirectory() throws IOException { File inputFolder = folder.newFolder(); BrowsableDirectoryField victim = new BrowsableDirectoryField(); victim.setTextFromFile(inputFolder); assertEquals(inputFolder.getAbsolutePath(), victim.getTextField().getText()); }