### Question:
DiskChecker { @VisibleForTesting float checkDiskFull(File dir) throws DiskOutOfSpaceException, DiskWarnThresholdException { if (null == dir) { return 0f; } if (dir.exists()) { long usableSpace = dir.getUsableSpace(); long totalSpace = dir.getTotalSpace(); float free = (float) usableSpace / (float) totalSpace; float used = 1f - free; if (used > diskUsageThreshold) { LOG.error("Space left on device {} : {}, Used space fraction: {} > threshold {}.", dir, usableSpace, used, diskUsageThreshold); throw new DiskOutOfSpaceException("Space left on device " + usableSpace + " Used space fraction:" + used + " > threshold " + diskUsageThreshold, used); } if (used > diskUsageWarnThreshold) { LOG.warn("Space left on device {} : {}, Used space fraction: {} > WarnThreshold {}.", dir, usableSpace, used, diskUsageWarnThreshold); throw new DiskWarnThresholdException("Space left on device:" + usableSpace + " Used space fraction:" + used + " > WarnThreshold:" + diskUsageWarnThreshold, used); } return used; } else { return checkDiskFull(dir.getParentFile()); } } DiskChecker(float threshold, float warnThreshold); long getTotalFreeSpace(List<File> dirs); long getTotalDiskSpace(List<File> dirs); float getTotalDiskUsage(List<File> dirs); float checkDir(File dir); float getDiskUsageThreshold(); float getDiskUsageWarnThreshold();  }### Answer:
@Test(expected = DiskOutOfSpaceException.class) public void testCheckDiskFull() throws IOException { File file = createTempDir("DiskCheck", "test"); long usableSpace = file.getUsableSpace(); long totalSpace = file.getTotalSpace(); float threshold = minMaxThreshold((1f - ((float) usableSpace / (float) totalSpace)) - (1.0f - THRESHOLD)); diskChecker.setDiskSpaceThreshold(threshold, threshold); diskChecker.checkDiskFull(file); }