@Test public void testCreateDirectoryStructure_usingCreateMockAndExpectNew() throws Exception { final String path = "directoryPath"; File fileMock = createMockAndExpectNew(File.class, path); PersistenceManager tested = new PersistenceManager(); expect(fileMock.exists()).andReturn(false); expect(fileMock.mkdirs()).andReturn(true); replay(fileMock, File.class); assertTrue(tested.createDirectoryStructure(path)); verify(fileMock, 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);  }