### Question:
DU extends AbstractSpaceUsageSource { @Override public long getUsedSpace() { return time(duShell::getUsed, LOG); } DU(File path);  DU(File path, String excludePattern); @Override long getUsedSpace(); @SuppressWarnings("squid:S106") // command-line program, output to stdout static void main(String[] args);  }### Answer:
@Test public void testGetUsed() throws Exception { final long writtenSize = 32 * KB; File file = new File(DIR, "data"); createFile(file, (int) writtenSize); SpaceUsageSource du = new DU(file); long duSize = du.getUsedSpace(); assertFileSize(writtenSize, duSize); }
@Test public void testExcludePattern() throws IOException { createFile(new File(DIR, "include.txt"), (int) (4 * KB)); createFile(new File(DIR, "exclude.tmp"), (int) (100 * KB)); SpaceUsageSource du = new DU(DIR, "*.tmp"); long usedSpace = du.getUsedSpace(); assertFileSize(4*KB, usedSpace); }