DumpTermStatisticsFn extends AppFunction { @Override public void run(String[] args, PrintStream output) throws Exception { if (args.length <= 1 || args.length > 2) { output.println(getHelpString()); return; } execute(args[1], 0, 0, output); }  @Override String getName(); @Override String getHelpString(); @Override void run(String[] args, PrintStream output); @Override void run(Parameters p, PrintStream output);  }
@Test public void test() throws Exception { ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(byteArrayStream); App.run(new String[]{"dump-term-stats", childPath_1.getAbsolutePath(),}, printStream); String output = byteArrayStream.toString(); Set<String> items = new HashSet<String>(Arrays.asList(output.split("\n"))); assertTrue(items.size() == 3); String expected = "michael\t2\t2\njulia\t1\t1\nclaire\t1\t1\n"; Set<String> expectedSet = new HashSet<String>(Arrays.asList(expected.split("\n"))); assertTrue(items.containsAll(expectedSet)); byteArrayStream = new ByteArrayOutputStream(); printStream = new PrintStream(byteArrayStream); App.run(new String[]{"dump-term-stats", childPathStemmed_1.getAbsolutePath(),}, printStream); output = byteArrayStream.toString(); assertEquals(expected, output); byteArrayStream = new ByteArrayOutputStream(); printStream = new PrintStream(byteArrayStream); App.run(new String[]{"dump-term-stats", childPath_1.getAbsolutePath() + "," + childPath_2.getAbsolutePath(),}, printStream); output = byteArrayStream.toString(); items = new HashSet<String>(Arrays.asList(output.split("\n"))); assertTrue(items.size() == 4); expected = "michael\t4\t3\nmax\t1\t1\njulia\t1\t1\nclaire\t1\t1\n"; expectedSet = new HashSet<String>(Arrays.asList(expected.split("\n"))); assertTrue(items.containsAll(expectedSet)); }
@Test public void testExtendedVersion() throws Exception { ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(byteArrayStream); App.run(new String[]{"dump-term-stats-ext", "--indexParts=" + childPath_1.getAbsolutePath() + "," + childPath_2.getAbsolutePath(),}, printStream); String output = byteArrayStream.toString(); Set<String> items = new HashSet<String>(Arrays.asList(output.split("\n"))); assertTrue(items.size() == 4); String expected = "michael\t4\t3\nmax\t1\t1\njulia\t1\t1\nclaire\t1\t1\n"; Set<String> expectedSet = new HashSet<String>(Arrays.asList(expected.split("\n"))); assertTrue(items.containsAll(expectedSet)); byteArrayStream = new ByteArrayOutputStream(); printStream = new PrintStream(byteArrayStream); App.run(new String[]{"dump-term-stats-ext", "--minTF=3", "--indexParts=" + childPath_1.getAbsolutePath() + "," + childPath_2.getAbsolutePath(),}, printStream); output = byteArrayStream.toString(); items = new HashSet<String>(Arrays.asList(output.split("\n"))); assertTrue(items.size() == 1); expected = "michael\t4\t3\n"; expectedSet = new HashSet<String>(Arrays.asList(expected.split("\n"))); assertTrue(items.containsAll(expectedSet)); byteArrayStream = new ByteArrayOutputStream(); printStream = new PrintStream(byteArrayStream); App.run(new String[]{"dump-term-stats-ext", "--minDF=3", "--indexParts=" + childPath_1.getAbsolutePath() + "," + childPath_2.getAbsolutePath(),}, printStream); output = byteArrayStream.toString(); items = new HashSet<String>(Arrays.asList(output.split("\n"))); assertTrue(items.size() == 1); expected = "michael\t4\t3\n"; expectedSet = new HashSet<String>(Arrays.asList(expected.split("\n"))); assertTrue(items.containsAll(expectedSet)); byteArrayStream = new ByteArrayOutputStream(); printStream = new PrintStream(byteArrayStream); App.run(new String[]{"dump-term-stats-ext", "--minTF=1", "--minDF=1", "--indexParts=" + childPath_1.getAbsolutePath() + "," + childPath_2.getAbsolutePath(),}, printStream); output = byteArrayStream.toString(); items = new HashSet<String>(Arrays.asList(output.split("\n"))); assertTrue(items.size() == 4); expected = "michael\t4\t3\nmax\t1\t1\njulia\t1\t1\nclaire\t1\t1\n"; expectedSet = new HashSet<String>(Arrays.asList(expected.split("\n"))); assertTrue(items.containsAll(expectedSet)); }