@Test public void whenInitConsoleMenuThenResultMenuWithDashes() { StringBuilder menuInLine = new StringBuilder(); menuInLine.append(String.format("File%s--New%s----Project... [opr]%s", sep, sep, sep)); menuInLine.append(String.format("%-17s%s%s", "--Open", "[open]", sep)); menuInLine.append(String.format("Help%s--About [ab]%s", sep, sep)); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { System.setOut(new PrintStream(out)); this.menu.init(); assertThat(out.toString(), is(menuInLine.toString())); } catch (IOException ioe) { ioe.printStackTrace(); } }
public void init() { File file = new File(); New fileNew = new New(); Help help = new Help(); file.addMenuItem(fileNew); file.addMenuItem(new FileOpen()); fileNew.addMenuItem(new Project()); help.addMenuItem(new HelpAbout()); menu.add(file); menu.add(help); printMenu(this.menu); }
ConsoleMenu implements Add, Get { public void init() { File file = new File(); New fileNew = new New(); Help help = new Help(); file.addMenuItem(fileNew); file.addMenuItem(new FileOpen()); fileNew.addMenuItem(new Project()); help.addMenuItem(new HelpAbout()); menu.add(file); menu.add(help); printMenu(this.menu); } }
ConsoleMenu implements Add, Get { public void init() { File file = new File(); New fileNew = new New(); Help help = new Help(); file.addMenuItem(fileNew); file.addMenuItem(new FileOpen()); fileNew.addMenuItem(new Project()); help.addMenuItem(new HelpAbout()); menu.add(file); menu.add(help); printMenu(this.menu); }  }
ConsoleMenu implements Add, Get { public void init() { File file = new File(); New fileNew = new New(); Help help = new Help(); file.addMenuItem(fileNew); file.addMenuItem(new FileOpen()); fileNew.addMenuItem(new Project()); help.addMenuItem(new HelpAbout()); menu.add(file); menu.add(help); printMenu(this.menu); }  void init(); void printMenu(List<MenuItems> menu); @Override void addMenuItem(MenuItems item); @Override List<MenuItems> getMenuItems(); }
ConsoleMenu implements Add, Get { public void init() { File file = new File(); New fileNew = new New(); Help help = new Help(); file.addMenuItem(fileNew); file.addMenuItem(new FileOpen()); fileNew.addMenuItem(new Project()); help.addMenuItem(new HelpAbout()); menu.add(file); menu.add(help); printMenu(this.menu); }  void init(); void printMenu(List<MenuItems> menu); @Override void addMenuItem(MenuItems item); @Override List<MenuItems> getMenuItems();  }