@Test public void shouldKnowIfAGivenDirectoryExists() throws Exception { File testFolder = new File("TestFolder"); testFolder.mkdir(); updater.parseCommandLine(new String[] {"TestFolder"}); assertTrue(updater.directoriesAreValid()); FileUtil.deleteFileSystemDirectory(testFolder); assertFalse(updater.directoriesAreValid()); }
@Test public void testMainUnhappyPath() throws Exception { String args[] = {"foo", "bar"}; UpdateFileList updaterMock = mock(UpdateFileList.class); UpdateFileList.testUpdater = updaterMock; when(updaterMock.directoriesAreValid()).thenReturn(false); UpdateFileList.main(args); verify(updaterMock).printMessage("Some directories are invalid."); verify(updaterMock).exit(); }
@Test public void testMainHappyPath() throws Exception { String args[] = {"foo", "bar"}; UpdateFileList updaterMock = mock(UpdateFileList.class); UpdateFileList.testUpdater = updaterMock; when(updaterMock.directoriesAreValid()).thenReturn(true); UpdateFileList.main(args); verify(updaterMock).parseCommandLine(args); verify(updaterMock).createUpdateList(); verify(updaterMock).createDoNotUpdateList(); }