/**
   * Needed for hyperlink form switches...
   *
   * @param request
   * @throws DatabaseException
   */
  private void doXrefselect(Tuple request) throws DatabaseException {
    // also set the parent menu
    if (getParent() != null && getParent() instanceof MenuController) {
      // set the filter to select the xref-ed entity
      pager.resetFilters();
      getModel().setUserRules(new ArrayList<QueryRule>());
      QueryRule rule =
          new QueryRule(
              request.getString("attribute"),
              QueryRule.Operator.valueOf(request.getString("operator")),
              request.getString("value"));
      pager.addFilter(rule);

      // tell "my" menu to select me
      Tuple parentRequest = new SimpleTuple();
      String aChildName = getModel().getName();
      ScreenController<?> aParent = getParent();
      while (aParent != null) {
        if (aParent instanceof MenuModel) {
          parentRequest.set("select", aChildName);
          MenuController c = (MenuController) aParent;
          c.doSelect(parentRequest);
        }
        aChildName = aParent.getName();
        aParent = aParent.getParent();
      }
    }
  }
  @Before
  public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    instance = new MenuController();
    instance.iDAO = iDAO;
    instance.programCache = programCache;

    when(iDAO.getConnection()).thenReturn(iDAOconn);

    connections = new HashMap<String, ConnectionWrapper>();
    connections.put("test", new ConnectionWrapper());
    when(iDAO.readAllConnectionWrappers(iDAOconn)).thenReturn(connections);
  }
  @Test
  public void showMenu() throws Exception {
    String expected = "menu";

    String result = instance.showMenu();

    verify(iDAO).setUpInternalDB(iDAOconn);
    verify(iDAO).readAllConnectionWrappers(iDAOconn);
    verify(programCache).setAllConnections(connectionsCaptor.capture());

    assertEquals(expected, result);
    assertEquals(connections, connectionsCaptor.getValue());
  }
Example #4
0
 public void render() {
   new BoardView(board).render();
   System.out.println("--------------------------");
   System.out.println("1. Move from deck to draw");
   System.out.println("2. Move from draw to suit");
   System.out.println("3. Move from draw to rank");
   System.out.println("4. Move from rank to suit");
   System.out.println("5. Move from rank to rank");
   System.out.println("6. Move from suit to rank");
   int menuOption = 0;
   do {
     System.out.print("Option? [1-6]: ");
     @SuppressWarnings("resource")
     Scanner in = new Scanner(System.in);
     menuOption = in.nextInt();
   } while ((menuOption > 6) && (menuOption < 1));
   menuController.control(menuOption);
 }
 /** Removes input listener */
 public void removeListener() {
   super.removeListener();
   getInput().removeListener(this);
 }