### Question:
DirBasedSteward implements Steward { @Override public Path createDaemonDir(Path jumiHome) { try { return UniqueDirectories.createUniqueDir(jumiHome.resolve(DAEMONS_DIR), System.currentTimeMillis()); } catch (IOException e) { throw new RuntimeException("Unable to create daemon directory", e); } } DirBasedSteward(DaemonJar daemonJar); @Override Path createDaemonDir(Path jumiHome); @Override Path getDaemonJar(Path jumiHome);  }### Answer:
@Test public void creates_a_daemon_directory() { Path daemonDir = steward.createDaemonDir(jumiHome); assertThat("should be under $JUMI_HOME/daemons", daemonDir.getParent(), is(jumiHome.resolve("daemons"))); assertThat("should be a directory", Files.isDirectory(daemonDir), is(true)); }
@Test public void concurrently_created_daemons_will_always_get_their_own_daemon_directories() { List<Path> daemonDirs = new ArrayList<>(); for (int i = 0; i < 100; i++) { daemonDirs.add(steward.createDaemonDir(jumiHome)); } Set<Path> uniqueDaemonDirs = new HashSet<>(daemonDirs); assertThat("unique daemon dirs", uniqueDaemonDirs.size(), is(daemonDirs.size())); }
@Test public void throws_exception_if_cannot_create_daemon_directory() throws IOException { Path parentDir = steward.createDaemonDir(jumiHome).getParent(); FileUtils.deleteDirectory(parentDir.toFile()); Files.createFile(parentDir); thrown.expect(RuntimeException.class); thrown.expectMessage("Unable to create daemon directory"); thrown.expectCause(instanceOf(FileAlreadyExistsException.class)); steward.createDaemonDir(jumiHome); }