Package com.testdomain

Examples of com.testdomain.LineItem


  }

  // UPDATE TESTS

  public void testInsertGeneratedKey() throws SQLException {
    LineItem item = new LineItem();

    item.setId(10);
    item.setItemCode("blah");
    item.setOrderId(333);
    item.setPrice(new BigDecimal("44.00"));
    item.setQuantity(1);

    Object key = sqlMap.insert("insertLineItem", item);

    assertEquals(new Integer(99), key);
    assertEquals(99, item.getId());

    Map param = new HashMap();
    param.put("orderId", new Integer(333));
    param.put("lineId", new Integer(10));
    LineItem testItem = (LineItem) sqlMap.queryForObject("getSpecificLineItem", param);
    assertNotNull(testItem);
    assertEquals(10, testItem.getId());
  }
View Full Code Here


    assertNotNull(testItem);
    assertEquals(10, testItem.getId());
  }

  public void testInsertGeneratedKeyFailure() throws SQLException {
    LineItem item = new LineItem();

    item.setId(0);
    item.setItemCode("blah");
    item.setOrderId(333);
    item.setPrice(new BigDecimal("44.00"));
    item.setQuantity(1);

    Object key = new Integer(-1);

    try {
      key = sqlMap.insert("insertLineItemOrDie", item);
    } catch (SQLException e) {
      // this is expected
    }

    assertEquals(key, new Integer(-1)); // this should not be changed from above
    assertEquals(0, item.getId()); // this should not be changed from above

  }
View Full Code Here

    assertEquals(0, item.getId()); // this should not be changed from above

  }

  public void testInsertPreKey() throws SQLException {
    LineItem item = new LineItem();

    item.setId(10);
    item.setItemCode("blah");
    item.setOrderId(333);
    item.setPrice(new BigDecimal("44.00"));
    item.setQuantity(1);

    Object key = sqlMap.insert("insertLineItemPreKey", item);

    assertEquals(new Integer(99), key);
    assertEquals(99, item.getId());

    Map param = new HashMap();
    param.put("orderId", new Integer(333));
    param.put("lineId", new Integer(99));
    LineItem testItem = (LineItem) sqlMap.queryForObject("getSpecificLineItem", param);
    assertNotNull(testItem);
    assertEquals(99, testItem.getId());

  }
View Full Code Here

    assertEquals(99, testItem.getId());

  }

  public void testInsertNoKey() throws SQLException {
    LineItem item = new LineItem();

    item.setId(100);
    item.setItemCode("blah");
    item.setOrderId(333);
    item.setPrice(new BigDecimal("44.00"));
    item.setQuantity(1);

    Object key = sqlMap.insert("insertLineItemNoKey", item);

    assertNull(null, key);
    assertEquals(100, item.getId());

    Map param = new HashMap();
    param.put("orderId", new Integer(333));
    param.put("lineId", new Integer(100));
    LineItem testItem = (LineItem) sqlMap.queryForObject("getSpecificLineItem", param);
    assertNotNull(testItem);
    assertEquals(100, testItem.getId());

  }
View Full Code Here

TOP

Related Classes of com.testdomain.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.