MetricFactory { public void showOn(PrintStream out) { int paramIdWidth = 12; for (Entry<String, Map<Class<?>, Function<?,?>>> entry : buildersByFunction.entrySet()) { out.println(entry.getKey()); for (Function<?,?> function : entry.getValue().values()) { out.println("\t" + function.toString()); for (Parameter<?> p : function.parameters().keySet()) { out.print("\t\t"); StringUtil.printLeftJustified('\'' + p.id() + '\'', out, paramIdWidth);; out.println("\t" + p.description()); } } } } private  MetricFactory(); void register(String functionId, Map<Class<?>, Function<?,?>> builders); Set<String> registeredFunctions(); Function<?,?> functionFor(String functionId, Class<?> javaType); Set<String> availableFunctionsFor(Class<?> javaType); void showOn(PrintStream out); static final MetricFactory Instance; }
@Test public void showOnTest() { File outFile = new File("showOnTest.txt"); try { PrintStream out = new PrintStream(outFile); mf.showOn(out); out.close(); String contents = new String(Files.readAllBytes(Paths.get("showOnTest.txt"))); assertTrue(contents.contains(Summer.Id)); assertTrue(contents.contains(Averager.Id)); assertTrue(contents.contains(MinMax.Id)); assertTrue(contents.contains(Histogram.Id)); } catch (Exception ex) { fail(ex.getMessage()); } finally { outFile.deleteOnExit(); } }