예제 #1
0
  @Test
  public void testUpdateSourceID() {
    try {
      setUpProducts();
      Product product = pdt.setUpProduct6();
      ProductXml productXml =
          new ProductXml.ProductBuilder()
              .author("")
              .imageURL("")
              .imageLargeURL("")
              .manufacturer("")
              .productIndex("")
              .productgroup("")
              .productId(product.getProductId())
              .productidtype("")
              .source("")
              .sourceid("999999")
              .title("")
              .build();
      ProductMsgXml productMsg = new ProductMsgXml(productXml);

      ProductDaoSql productDaoSql = new ProductDaoSql(productMsg);
      productDaoSql.update();
      productXml = new ProductXml();
      productXml.setProductId("9780789799999");
      productMsg = new ProductMsgXml(productXml);
      productDaoSql = new ProductDaoSql(productMsg);
      productMsg = (ProductMsgXml) productDaoSql.read();
      System.out.println(productMsg.getSuccess());

      productXml = productMsg.getLOfProducts().get(0);

      assertEquals(
          "getProduct failed Incorrect author returned ", "Willy wonka", productXml.getAuthor());
      assertEquals(
          "getProduct failed Incorrect image URL returned ",
          "http://ecx.images-amazon.com/images/I/51TW6S55A4L._SL75_.jpg",
          productXml.getImageURL());
      assertEquals(
          "getProduct failed Incorrect image large URL returned ",
          "http://ecx.images-amazon.com/images/I/51TW6S55A4L._SL75_.jpg",
          productXml.getImageLargeURL());
      assertEquals(
          "getProduct failed Incorrect manufacturer returned ",
          "QUE",
          productXml.getManufacturer());
      assertEquals(
          "getProduct failed Incorrect product index returned ", "0", productXml.getProductIndex());
      assertEquals(
          "getProduct failed Incorrect product group returned ",
          "DVD",
          productXml.getProductgroup());
      assertEquals(
          "getProduct failed Incorrect product id returned ",
          "9780789799999",
          productXml.getProductId());
      assertEquals(
          "getProduct failed Incorrect id product type returned ",
          "EAN",
          productXml.getProductidtype());
      assertEquals(
          "getProduct failed Incorrect source returned ", "Amazon", productXml.getSource());
      assertEquals(
          "actualProduct failed Incorrect source id returned ", "999999", productXml.getSourceid());
      assertEquals(
          "getProduct failed Incorrect title returned ",
          "The Choocolate Factory",
          productXml.getTitle());
      assertTrue("getProduct failed crDate is null", null != productXml.getCrDate());
      assertTrue("getProduct failed updDate is null", null != productXml.getUpdDate());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
  @Test
  public void testDelete() {
    try {
      setUpProducts();
      Product product = pdt.setUpProduct1();

      ProductXml productXml =
          new ProductXml.ProductBuilder()
              .author(product.getAuthor())
              .imageURL(product.getImageURL())
              .imageLargeURL(product.getImageLargeURL())
              .manufacturer(product.getManufacturer())
              .productIndex(product.getProductIndex())
              .productgroup(product.getProductgroup())
              .productId(product.getProductId())
              .productidtype(product.getProductidtype())
              .source(product.getSource())
              .sourceid(product.getSourceid())
              .title(product.getTitle())
              .build();

      ProductMsgXml productMsg = new ProductMsgXml(productXml);
      ProductDaoSql productDaoSql = new ProductDaoSql(productMsg);
      productMsg = (ProductMsgXml) productDaoSql.delete();
      System.out.println(productMsg.getSuccess());
    } catch (Exception e) {
      e.printStackTrace();
    }
  }