### Question:
MenuItemHelper { public static MenuItem createFromExistingWithId(MenuItem selected, int newId) { return visitWithResult(selected, new AbstractMenuItemVisitor<MenuItem>() { @Override public void visit(AnalogMenuItem item) { setResult(AnalogMenuItemBuilder.anAnalogMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(BooleanMenuItem item) { setResult(BooleanMenuItemBuilder.aBooleanMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(EnumMenuItem item) { setResult(EnumMenuItemBuilder.anEnumMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(SubMenuItem item) { setResult(SubMenuItemBuilder.aSubMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(EditableTextMenuItem item) { setResult(EditableTextMenuItemBuilder.aTextMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(EditableLargeNumberMenuItem item) { setResult(EditableLargeNumberMenuItemBuilder.aLargeNumberItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(FloatMenuItem item) { setResult(FloatMenuItemBuilder.aFloatMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(ActionMenuItem item) { setResult(ActionMenuItemBuilder.anActionMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } @Override public void visit(RuntimeListMenuItem item) { setResult(RuntimeListMenuItemBuilder.aRuntimeListMenuItemBuilder() .withExisting(item) .withId(newId) .menuItem() ); } }).orElse(null); }  static Optional<T> visitWithResult(MenuItem item, AbstractMenuItemVisitor<T> visitor); static SubMenuItem asSubMenu(MenuItem item); static boolean isRuntimeStructureNeeded(MenuItem item); static MenuItem createFromExistingWithId(MenuItem selected, int newId); static int eepromSizeForItem(MenuItem item);  }### Answer:
@Test public void testCreateFromExisting() { MenuItem newAnalog = MenuItemHelper.createFromExistingWithId(analogItem, 11); MenuItem newEnum = MenuItemHelper.createFromExistingWithId(enumItem, 94); MenuItem newSub = MenuItemHelper.createFromExistingWithId(subItem, 97); MenuItem newBool = MenuItemHelper.createFromExistingWithId(boolMenuItem, 99); MenuItem newFloat = MenuItemHelper.createFromExistingWithId(floatItem, 3333); MenuItem newText = MenuItemHelper.createFromExistingWithId(textItem, 1111); MenuItem newAction = MenuItemHelper.createFromExistingWithId(actionItem, 9999); MenuItem newList = MenuItemHelper.createFromExistingWithId(listItem, 20093); assertTrue(newList instanceof RuntimeListMenuItem); assertEquals(20093, newList.getId()); assertTrue(newAnalog instanceof AnalogMenuItem); assertEquals(11, newAnalog.getId()); assertTrue(newEnum instanceof EnumMenuItem); assertEquals(94, newEnum.getId()); assertTrue(newSub instanceof SubMenuItem); assertEquals(97, newSub.getId()); assertTrue(newBool instanceof BooleanMenuItem); assertEquals(99, newBool.getId()); assertTrue(newFloat instanceof FloatMenuItem); assertEquals(3333, newFloat.getId()); assertTrue((newAction instanceof ActionMenuItem)); assertEquals(9999, newAction.getId()); assertTrue(newText instanceof EditableTextMenuItem); assertEquals(1111, newText.getId()); }