public void shouldThrowErrorIfFilesToSelectIsEmpty() {
   try {
     driver.selectFiles(fileChooser, new File[0]);
     failWhenExpectingException();
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage()).isEqualTo("The array of files to select should not be empty");
   }
 }
 public void shouldThrowErrorIfFilesToSelectIsNull() {
   try {
     driver.selectFiles(fileChooser, null);
     failWhenExpectingException();
   } catch (NullPointerException e) {
     assertThat(e.getMessage()).isEqualTo("The files to select should not be null");
   }
 }
 public void shouldThrowErrorWhenSettingCurrentDirectoryInNotShowingJFileChooser() {
   hideWindow();
   try {
     driver.setCurrentDirectory(fileChooser, userHomeDirectory());
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToNotShowingComponent(e);
   }
 }
 public void shouldThrowErrorWhenSelectingFilesInNotShowingJFileChooser() {
   hideWindow();
   try {
     driver.selectFiles(fileChooser, array(new File("Fake")));
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToNotShowingComponent(e);
   }
 }
 public void shouldThrowErrorIfAnyFileToSelectIsNull() {
   try {
     driver.selectFiles(fileChooser, array(new File("Fake"), null));
     failWhenExpectingException();
   } catch (NullPointerException e) {
     assertThat(e.getMessage())
         .isEqualTo("The array of files to select should not contain null elements");
   }
 }
 public void shouldThrowErrorWhenSettingCurrentDirectoryInDisabledJFileChooser() {
   disableFileChooser();
   try {
     driver.setCurrentDirectory(fileChooser, userHomeDirectory());
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToDisabledComponent(e);
   }
 }
 public void shouldSelectFile() {
   File temporaryFile = newTemporaryFile();
   try {
     driver.selectFile(fileChooser, temporaryFile);
     File selectedFile = selectedFileIn(fileChooser);
     assertThat(selectedFile).isSameAs(temporaryFile);
   } finally {
     temporaryFile.delete();
   }
 }
 public void shouldThrowErrorWhenSelectingFilesAndJFileChooserCannotHandleMultipleSelection() {
   disableMultipleSelection();
   try {
     driver.selectFiles(fileChooser, array(new File("Fake1"), new File("Fake2")));
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertThat(e.getMessage())
         .contains("Expecting file chooser")
         .contains("to handle multiple selection");
   }
 }
 public void shouldThrowErrorIfJFileChooserCanOnlySelectFilesAndFileToSelectIsFolder() {
   File temporaryFolder = newTemporaryFolder();
   setFileChooserToSelectFilesOny();
   try {
     driver.selectFile(fileChooser, temporaryFolder);
     failWhenExpectingException();
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage()).contains("the file chooser cannot open directories");
   } finally {
     temporaryFolder.delete();
   }
 }
 public void
     shouldNotThrowErrorIfJFileChooserCannotHandleMultipleSelectionAndArrayOfFilesToSelectHasOneElementOnly() {
   disableMultipleSelection();
   File temporaryFile = newTemporaryFile();
   try {
     driver.selectFiles(fileChooser, array(temporaryFile));
     File[] selectedFiles = selectedFilesIn(fileChooser);
     assertThat(selectedFiles).containsOnly(temporaryFile);
   } finally {
     temporaryFile.delete();
   }
 }
 public void shouldThrowErrorWhenSelectingFileInDisabledJFileChooser() {
   File temporaryFile = newTemporaryFile();
   disableFileChooser();
   try {
     driver.selectFile(fileChooser, temporaryFile);
     failWhenExpectingException();
   } catch (IllegalStateException e) {
     assertActionFailureDueToDisabledComponent(e);
   } finally {
     temporaryFile.delete();
   }
 }
 public void shouldSelectFiles() {
   enableMultipleSelection();
   setFileChooserToSelectFilesAndDirectories();
   File temporaryFolder = newTemporaryFolder();
   File temporaryFile = newTemporaryFile();
   try {
     driver.selectFiles(fileChooser, array(temporaryFolder, temporaryFile));
     File[] selectedFiles = selectedFilesIn(fileChooser);
     assertThat(selectedFiles).containsOnly(temporaryFolder, temporaryFile);
   } finally {
     temporaryFolder.delete();
     temporaryFile.delete();
   }
 }
 public void shouldThrowErrorIfJFileChooserCanOnlySelectFoldersAndOneOfFilesToSelectIsFile() {
   enableMultipleSelection();
   File temporaryFolder = newTemporaryFolder();
   File temporaryFile = newTemporaryFile();
   setFileChooserToSelectDirectoriesOnly();
   try {
     driver.selectFiles(fileChooser, array(temporaryFolder, temporaryFile));
     failWhenExpectingException();
   } catch (IllegalArgumentException e) {
     assertThat(e.getMessage()).contains("the file chooser can only open directories");
   } finally {
     temporaryFile.delete();
     temporaryFile.delete();
   }
 }
 public void shouldFindCancelButton() {
   JButton cancelButton = driver.cancelButton(fileChooser);
   assertThat(cancelButton).isNotNull();
   assertThat(textOf(cancelButton)).isEqualTo(cancelButtonText());
 }
 public void shouldSetCurrentDirectory() {
   File userHome = userHomeDirectory();
   driver.setCurrentDirectory(fileChooser, userHome);
   assertThat(currentDirectoryAbsolutePath(fileChooser)).isEqualTo(userHome.getAbsolutePath());
 }
 public void shouldFindFileNameTextBox() {
   JTextField fileNameTextBox = driver.fileNameTextBox(fileChooser);
   assertThat(fileNameTextBox).isNotNull();
 }
 public void shouldFindApproveButton() {
   JButton approveButton = driver.approveButton(fileChooser);
   assertThat(approveButton).isNotNull();
   assertThat(textOf(approveButton)).isEqualTo(approveButtonText(fileChooser));
 }