@org.junit.Test()
 public void testRemoveItem() throws Exception {
   order.addItem(item);
   int totalCount = order.total();
   order.removeItem(item);
   assertEquals(totalCount - order.total(), 1);
 }
  @Test
  @Ignore
  public void anOrderCanBeShipped() throws Exception {
    Order order = new Order("x", "y", "z");
    assertEquals(false, order.isShipped());

    order.ship();

    assertEquals("order should be shipped", true, order.isShipped());
  }
  @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
  @Ignore
  public void shippedOrdersAreNotShown() throws Exception {
    Order shipped = new Order("X");
    Order notShipped = new Order("Y");
    orders.addAll(asList(shipped, notShipped));
    shipped.ship();

    when(request.getMethod()).thenReturn("GET");
    when(request.getRequestURI()).thenReturn("/orders");

    ordersController.service();

    verify(ordersView).show(asList(notShipped));
  }
  @Test
  @Ignore
  public void theControllerWillShipAnOrder() throws Exception {
    Order order = new Order("5555", "_", "_");
    orders.add(order);

    when(request.getMethod()).thenReturn("POST");
    when(request.getRequestURI()).thenReturn("/orders/shipped");
    when(request.getParameter("order_code")).thenReturn("5555");

    ordersController.service();

    assertEquals("controller should set shipped", true, order.isShipped());
    verify(ordersView).refresh();
  }
 public void orderTest() {
   Customer customer = customerDAO.getCustomerById(3);
   List<Commodity> commodityList = commoDAO.getCommoditiesByIdString("2;3;4");
   List<OrderCommodityRel> relationLsit = CommodityListTools.commoToRel(commodityList);
   Order order = new Order(customer, relationLsit, 100);
   Map<Integer, Integer> map = new HashMap<Integer, Integer>();
   map.put(2, 2);
   map.put(3, 4);
   map.put(4, 4);
   order.setBuyNum(map);
   Date date = new Date();
   order.setOrderTime(new Timestamp(date.getTime()));
   orderDAO.createOrder(order);
   System.out.println(order.getOrderId());
 }
  @Test
  public void testOrderSpending() {

    Supplier s1 = new Supplier("Walsh Meats", "Dublin", 3);
    Supplier s2 = new Supplier("Fruit N Veg", "Meath", 2);
    Supplier s3 = new Supplier("DailyBasics", "Kildare", 4);

    suppliers.add(s1);
    suppliers.add(s2);
    suppliers.add(s3);

    // Name, id, cost price, sell price, quantity, supplier
    Product p1 = new Product("Steak", 111, 2, 5, 10, suppliers.get(0));
    Product p2 = new Product("Chicken breast", 222, 1, 3, 10, suppliers.get(0));
    Product p3 = new Product("Apples", 333, 0.5, 2, 25, suppliers.get(1));
    Product p4 = new Product("Brocolli", 444, 0.7, 2.5, 20, suppliers.get(1));
    Product p5 = new Product("Bread", 555, 0.8, 2, 50, suppliers.get(2));
    Product p6 = new Product("Milk", 666, 0.8, 1.5, 50, suppliers.get(2));

    products.add(p1);
    products.add(p2);
    products.add(p3);
    products.add(p4);
    products.add(p5);
    products.add(p6);

    // Product, supplier, quantity, day, month, year
    Order o1 = new Order(products.get(0), 2, 1, 2, 2015); // 4
    Order o2 = new Order(products.get(1), 1, 3, 4, 2015); // 1
    Order o3 = new Order(products.get(2), 3, 27, 5, 2015); // 1.5
    Order o4 = new Order(products.get(3), 2, 28, 5, 2015); // 1.4
    Order o5 = new Order(products.get(4), 1, 8, 6, 2015); // 0.8
    Order o6 = new Order(products.get(5), 4, 8, 8, 2015); // 3.2
    // total = 11.9

    orders.add(o1);
    orders.add(o2);
    orders.add(o3);
    orders.add(o4);
    orders.add(o5);
    orders.add(o6);

    Order order = new Order();
    assertEquals(11.9, order.viewOrderCost(new Date(), orders), DELTA);
  }
  public void paymentTest() {
    Payment payment = new Payment();
    // 取出订单
    Order order = orderDAO.getOrderById(8);
    // 取出订单顾客
    Customer customer = order.getCustomer();
    // 取出操作员
    Worker worker = workerDAO.getWorkerById(7);
    // 取出银行卡
    Bankcard bankcard = customer.getBankcardList().get(0);

    payment.setPayCustomer(customer);
    System.out.println("OrderId:" + order.getOrderId());
    payment.setPayOrder(order);
    System.out.println(bankcard);
    payment.setPayCard(bankcard);
    payment.setPayPrice(order.getOrderPrice());
    payment.setPayType(1);
    payment.setWorker(worker);

    paymentDAO.createPayment(payment);
  }
Beispiel #9
0
 @Test
 public void testGetStudent() {
   assertEquals(s, o.getStudent());
 }
 @org.junit.Test
 public void testAddItem() throws Exception {
   order.addItem(Order.Item.createItem());
   assertEquals(order.total(), 1);
 }