@Test
  public void testSplitter() throws InterruptedException {
    MockEndpoint coldDrinks = context.getEndpoint("mock:coldDrinks", MockEndpoint.class);
    MockEndpoint hotDrinks = context.getEndpoint("mock:hotDrinks", MockEndpoint.class);

    Order order = new Order(1);
    order.addItem(DrinkType.ESPRESSO, 2, true);
    order.addItem(DrinkType.CAPPUCCINO, 2, false);

    coldDrinks.expectedBodiesReceived(new OrderItem(order, DrinkType.ESPRESSO, 2, true));
    hotDrinks.expectedBodiesReceived(new OrderItem(order, DrinkType.CAPPUCCINO, 2, false));

    template.sendBody("direct:cafe", order);

    assertMockEndpointsSatisfied();
  }
 @org.junit.Test()
 public void testRemoveItem() throws Exception {
   order.addItem(item);
   int totalCount = order.total();
   order.removeItem(item);
   assertEquals(totalCount - order.total(), 1);
 }
  @org.junit.Test
  public void testRemoveItems() throws Exception {
    List<Order.Item> items = Lists.newArrayList();
    items.add(item);
    items.add(Order.Item.createItem());

    order.addItem(item).addItem(Order.Item.createItem());
    order.removeItems(items);

    assertTrue(order.total() > 0);
  }
  @Test
  public void testCafeRoute() throws Exception {
    driverRouter.setTestModel(false);
    List<Drink> drinks = new ArrayList<Drink>();
    Order order = new Order(2);
    order.addItem(DrinkType.ESPRESSO, 2, true);
    order.addItem(DrinkType.CAPPUCCINO, 4, false);
    order.addItem(DrinkType.LATTE, 4, false);
    order.addItem(DrinkType.MOCHA, 2, false);

    drinks.add(new Drink(2, DrinkType.ESPRESSO, true, 2));
    drinks.add(new Drink(2, DrinkType.CAPPUCCINO, false, 4));
    drinks.add(new Drink(2, DrinkType.LATTE, false, 4));
    drinks.add(new Drink(2, DrinkType.MOCHA, false, 2));

    waiter.setVerfiyDrinks(drinks);

    template.sendBody("direct:cafe", order);

    // wait enough time to let the aggregate complete
    Thread.sleep(10000);

    waiter.verifyDrinks();
  }
Ejemplo n.º 5
0
  public void confirmItem() {
    this.subtotal += item.getTotal();
    String subtotalStr = formatter.format(this.subtotal);
    text_bookID.setText("");
    text_quantity.setText("");
    text_subtotal.setText(subtotalStr);

    confirmAlert();

    order.addItem(item);
    this.totalQuantity += item.getQuantity();
    changeItemNumber();
    btn_confirm.setDisable(true);
    btn_view.setDisable(false);
    text_totalItems.setDisable(true);
    item = null;
  }
Ejemplo n.º 6
0
    public void actionPerformed(final ActionEvent anEvent) {
      int selected = view.getOrderTable().getSelectedRow();
      if (selected > -1) {
        int selectedItem = customerMenu.getItemIds().get(selected);
        String comment = view.getCommentText();
        try {
          Order thisOrder = orders.get(currentOrder);
          thisOrder.addItem(selectedItem, comment);
          if (thisOrder.getStatus() == 0) {
            thisOrder.setStatus(1);
            updateStatusLabel();
          }
          MenuItem itemRef = customerMenu.getItemByID(selectedItem);
          view.clearCommentText();

          view.addOrderRow(new Object[] {itemRef.getName(), comment});
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
 @org.junit.Test
 public void testAddItem() throws Exception {
   order.addItem(Order.Item.createItem());
   assertEquals(order.total(), 1);
 }