@Test public void whenPrintMenuWithTwoLinesThenResultMenuWithTwoLinesInConsole() { File file = new File(); Help help = new Help(); ArrayList<MenuItems> testList = new ArrayList<>(); testList.add(file); testList.add(help); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { System.setOut(new PrintStream(out)); this.menu.printMenu(testList); assertThat(out.toString(), is(String.format("File%sHelp%s", sep, sep))); } catch (IOException ioe) { ioe.printStackTrace(); } }
public void printMenu(List<MenuItems> menu) { for (MenuItems item : menu) { System.out.println(String.format("%s%s", printDashes(item.getLevel()), item.getInfo())); if (item.getMenuItems() != null) { printMenu(item.getMenuItems()); } } }
ConsoleMenu implements Add, Get { public void printMenu(List<MenuItems> menu) { for (MenuItems item : menu) { System.out.println(String.format("%s%s", printDashes(item.getLevel()), item.getInfo())); if (item.getMenuItems() != null) { printMenu(item.getMenuItems()); } } } }
ConsoleMenu implements Add, Get { public void printMenu(List<MenuItems> menu) { for (MenuItems item : menu) { System.out.println(String.format("%s%s", printDashes(item.getLevel()), item.getInfo())); if (item.getMenuItems() != null) { printMenu(item.getMenuItems()); } } }  }
ConsoleMenu implements Add, Get { public void printMenu(List<MenuItems> menu) { for (MenuItems item : menu) { System.out.println(String.format("%s%s", printDashes(item.getLevel()), item.getInfo())); if (item.getMenuItems() != null) { printMenu(item.getMenuItems()); } } }  void init(); void printMenu(List<MenuItems> menu); @Override void addMenuItem(MenuItems item); @Override List<MenuItems> getMenuItems(); }
ConsoleMenu implements Add, Get { public void printMenu(List<MenuItems> menu) { for (MenuItems item : menu) { System.out.println(String.format("%s%s", printDashes(item.getLevel()), item.getInfo())); if (item.getMenuItems() != null) { printMenu(item.getMenuItems()); } } }  void init(); void printMenu(List<MenuItems> menu); @Override void addMenuItem(MenuItems item); @Override List<MenuItems> getMenuItems();  }