Package org.springframework.batch.sample.domain.order

Examples of org.springframework.batch.sample.domain.order.LineItem


    order = new Order();
    order.setOrderId(Long.MAX_VALUE);
    order.setOrderDate(new Date(new Date().getTime() - 1000));
    order.setTotalLines(0);
    List<LineItem> items = new ArrayList<LineItem>();
    items.add(new LineItem());
    order.setLineItems(items);

    errors = new BeanPropertyBindingResult(order, "validOrder");

    orderValidator.validateOrder(order, errors);

    assertEquals(2, errors.getAllErrors().size());
    assertEquals("error.order.id", errors.getFieldError("orderId").getCode());
    assertEquals("error.order.lines.badcount", errors.getFieldError("totalLines").getCode());

    order = new Order();
    order.setOrderId(5L);
    order.setOrderDate(new Date(new Date().getTime() - 1000));
    order.setTotalLines(1);
    items = new ArrayList<LineItem>();
    items.add(new LineItem());
    order.setLineItems(items);

    errors = new BeanPropertyBindingResult(order, "validOrder");

    orderValidator.validateOrder(order, errors);
View Full Code Here


    assertEquals("error.lineitems.quantity", errors.getFieldErrors("lineItems").get(5).getCode());
    assertEquals("error.lineitems.totalprice", errors.getFieldErrors("lineItems").get(6).getCode());
  }

  private LineItem buildLineItem(long itemId, double price, int discountPercentage, int discountAmount, long shippingPrice, long handlingPrice, int qty, int totalPrice) {
    LineItem invalidId = new LineItem();
    invalidId.setItemId(itemId);
    invalidId.setPrice(new BigDecimal(price));
    invalidId.setDiscountPerc(new BigDecimal(discountPercentage));
    invalidId.setDiscountAmount(new BigDecimal(discountAmount));
    invalidId.setShippingPrice(new BigDecimal(shippingPrice));
    invalidId.setHandlingPrice(new BigDecimal(handlingPrice));
    invalidId.setQuantity(qty);
    invalidId.setTotalPrice(new BigDecimal(totalPrice));
    return invalidId;
  }
View Full Code Here

  public static final String PRICE_COLUMN = "PRICE";
  public static final String ITEM_ID_COLUMN = "ITEM_ID";

  @Override
  public LineItem mapFieldSet(FieldSet fieldSet) {
    LineItem item = new LineItem();

    item.setItemId(fieldSet.readLong(ITEM_ID_COLUMN));
    item.setPrice(fieldSet.readBigDecimal(PRICE_COLUMN));
    item.setDiscountPerc(fieldSet.readBigDecimal(DISCOUNT_PERC_COLUMN));
    item.setDiscountAmount(fieldSet.readBigDecimal(DISCOUNT_AMOUNT_COLUMN));
    item.setShippingPrice(fieldSet.readBigDecimal(SHIPPING_PRICE_COLUMN));
    item.setHandlingPrice(fieldSet.readBigDecimal(HANDLING_PRICE_COLUMN));
    item.setQuantity(fieldSet.readInt(QUANTITY_COLUMN));
    item.setTotalPrice(fieldSet.readBigDecimal(TOTAL_PRICE_COLUMN));

    return item;
  }
View Full Code Here

TOP

Related Classes of org.springframework.batch.sample.domain.order.LineItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.