Help implements BaseCommand { private String mainHelp() { final TTable tTable = new TTable(new TTable.ColumnDefine[]{ new TTable.ColumnDefine(TTable.Align.RIGHT), new TTable.ColumnDefine(80, false, TTable.Align.LEFT) }); final List<Class<?>> classes = CommandHelper.getAllCommandClass(); Collections.sort(classes, new Comparator<Class<?>>() { @Override public int compare(Class<?> o1, Class<?> o2) { final Integer o1s = o1.getAnnotation(Cmd.class).sort(); final Integer o2s = o2.getAnnotation(Cmd.class).sort(); return o1s.compareTo(o2s); } }); for (Class<?> clazz : classes) { if (clazz.isAnnotationPresent(Cmd.class)) { final Cmd cmd = clazz.getAnnotation(Cmd.class); tTable.addRow(cmd.name(), cmd.summary()); } } return tTable.padding(1).rendering(); }  @Override String execute(CommandContext commandContext, String[] args);  }
@Test public void testMainHelp() throws Exception { Help help = new Help(); String output = help.execute(Mockito.mock(CommandContext.class), null); assertThat(output, containsString("greeting")); assertThat(output, containsString("help")); assertThat(output, containsString("ls")); assertThat(output, containsString("online")); assertThat(output, containsString("offline")); assertThat(output, containsString("quit")); }