@Test(expected = IllegalArgumentException.class) public void testCreateDirectoryStructure_fails() throws Exception { final String path = "directoryPath"; File mFileMock = createMock(File.class); PersistenceManager tested = new PersistenceManager(); expectNew(File.class, path).andReturn(mFileMock); expect(mFileMock.exists()).andReturn(true); replay(mFileMock, File.class); tested.createDirectoryStructure(path); verify(mFileMock, File.class); }
public boolean createDirectoryStructure(String directoryPath) { File directory = new File(directoryPath); if (directory.exists()) { throw new IllegalArgumentException("\"" + directoryPath + "\" already exists."); } return directory.mkdirs(); }
PersistenceManager { public boolean createDirectoryStructure(String directoryPath) { File directory = new File(directoryPath); if (directory.exists()) { throw new IllegalArgumentException("\"" + directoryPath + "\" already exists."); } return directory.mkdirs(); } }
PersistenceManager { public boolean createDirectoryStructure(String directoryPath) { File directory = new File(directoryPath); if (directory.exists()) { throw new IllegalArgumentException("\"" + directoryPath + "\" already exists."); } return directory.mkdirs(); }  }
PersistenceManager { public boolean createDirectoryStructure(String directoryPath) { File directory = new File(directoryPath); if (directory.exists()) { throw new IllegalArgumentException("\"" + directoryPath + "\" already exists."); } return directory.mkdirs(); }  boolean createDirectoryStructure(String directoryPath); }
PersistenceManager { public boolean createDirectoryStructure(String directoryPath) { File directory = new File(directoryPath); if (directory.exists()) { throw new IllegalArgumentException("\"" + directoryPath + "\" already exists."); } return directory.mkdirs(); }  boolean createDirectoryStructure(String directoryPath);  }