Ejemplo n.º 1
0
 @Test
 public void testRead() {
   try {
     setUpProducts();
     ProductXml productXml = new ProductXml();
     productXml.setProductId("9780789724410");
     ProductMsgXml productMsg = new ProductMsgXml(productXml);
     ProductDaoSql productDaoSql = new ProductDaoSql(productMsg);
     productMsg = (ProductMsgXml) productDaoSql.read();
     System.out.println(productMsg.getSuccess());
     ArrayList<ProductXml> lOfProducts = productMsg.getLOfProducts();
     productXml = lOfProducts.get(0);
     System.out.println(productXml.toString());
     assertEquals(
         "getProduct failed Incorrect author returned ", "Mark Wutka", productXml.getAuthor());
     assertTrue("getProduct failed crDate is null", null != productXml.getCrDate());
     assertEquals(
         "getProduct failed Incorrect image large URL returned ",
         "http://ecx.images-amazon.com/images/I/51TW6S55A4L._SL75_.jpg",
         productXml.getImageLargeURL());
     assertEquals(
         "getProduct failed Incorrect image URL returned ",
         "http://ecx.images-amazon.com/images/I/51TW6S55A4L._SL75_.jpg",
         productXml.getImageURL());
     assertEquals(
         "getProduct failed Incorrect manufacturer returned ",
         "QUE",
         productXml.getManufacturer());
     assertEquals(
         "getProduct failed Incorrect product group returned ",
         "Book",
         productXml.getProductgroup());
     assertEquals(
         "getProduct failed Incorrect product id returned ",
         "9780789724410",
         productXml.getProductId());
     assertEquals(
         "getProduct failed Incorrect product type returned ",
         "EAN",
         productXml.getProductidtype());
     assertEquals(
         "getProduct failed Incorrect source returned ", "Amazon", productXml.getSource());
     assertEquals(
         "actualProduct failed Incorrect source id returned ",
         "789724413",
         productXml.getSourceid());
     assertEquals(
         "getProduct failed Incorrect title returned ",
         "Using Java Server Pages and Servlets Special Edition (Special Edition Using)",
         productXml.getTitle());
     assertTrue("getProduct failed updDate is null", null != productXml.getUpdDate());
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
  @Test
  public void testUpdateProductIndex() {
    try {
      setUpProducts();
      Product product = pdt.setUpProduct6();
      ProductXml productXml =
          new ProductXml.ProductBuilder()
              .author("")
              .imageURL("")
              .imageLargeURL("")
              .manufacturer("")
              .productIndex("1")
              .productgroup("")
              .productId(product.getProductId())
              .productidtype("")
              .source("")
              .sourceid("")
              .title("")
              .build();
      System.out.println(productXml.toString());
      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 ", "1", 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 product type returned ",
          "EAN",
          productXml.getProductidtype());
      assertEquals(
          "getProduct failed Incorrect source returned ", "Amazon", productXml.getSource());
      assertEquals(
          "actualProduct failed Incorrect source id returned ",
          "789724999",
          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();
    }
  }