Package com.restfully.shop.domain

Examples of com.restfully.shop.domain.Product


      Map<String, Link> shoppingLinks = processLinkHeaders(response);

      System.out.println("** Populate Products");
      request = new ClientRequest(shoppingLinks.get("products").getHref());

      Product product = new Product();
      product.setName("iPhone");
      product.setCost(199.99);
      request.body("application/xml", product);
      response = request.post();
      response.releaseConnection();
      Assert.assertEquals(201, response.getStatus());

      product = new Product();
      product.setName("MacBook Pro");
      product.setCost(3299.99);
      request.body("application/xml", product);
      response = request.post();
      response.releaseConnection();
      Assert.assertEquals(201, response.getStatus());

      product = new Product();
      product.setName("iPod");
      product.setCost(49.99);
      request.body("application/xml", product);
      response = request.post();
      response.releaseConnection();
      Assert.assertEquals(201, response.getStatus());

View Full Code Here


      System.out.println();
      System.out.println("Search for iPhone in the Product database");
      request = new ClientRequest(shoppingLinks.get("products").getHref() + "?name=iPhone");
      Products products = request.getTarget(Products.class);
      Product product = null;
      if (products.getProducts().size() > 0)
      {
         System.out.println("- Found iPhone in the database.");
         product = products.getProducts().iterator().next();
      }
      else
      {
         throw new RuntimeException("Failed to find an iPhone in the database!");
      }

      System.out.println();
      System.out.println("** Create Order for iPhone");
      LineItem item = new LineItem();
      item.setProduct(product);
      item.setQuantity(1);
      Order order = new Order();
      order.setTotal(product.getCost());
      order.setCustomer(customer);
      order.setDate(new Date().toString());
      order.getLineItems().add(item);
      request = new ClientRequest(shoppingLinks.get("orders").getHref());
      request.body("application/xml", order);
View Full Code Here

      Map<String, Link> shoppingLinks = processLinkHeaders(response);

      System.out.println("** Populate Products");
      request = new ClientRequest(shoppingLinks.get("products").getHref());

      Product product = new Product();
      product.setName("iPhone");
      product.setCost(199.99);
      request.body("application/xml", product);
      response = request.post();
      Assert.assertEquals(201, response.getStatus());

      product = new Product();
      product.setName("MacBook Pro");
      product.setCost(3299.99);
      request.body("application/xml", product);
      response = request.post();
      Assert.assertEquals(201, response.getStatus());

      product = new Product();
      product.setName("iPod");
      product.setCost(49.99);
      request.body("application/xml", product);
      response = request.post();
      Assert.assertEquals(201, response.getStatus());

   }
View Full Code Here

      System.out.println();
      System.out.println("Search for iPhone in the Product database");
      request = new ClientRequest(shoppingLinks.get("products").getHref() + "?name=iPhone");
      Products products = request.getTarget(Products.class);
      Product product = null;
      if (products.getProducts().size() > 0)
      {
         System.out.println("- Found iPhone in the database.");
         product = products.getProducts().iterator().next();
      }
      else
      {
         throw new RuntimeException("Failed to find an iPhone in the database!");
      }

      System.out.println();
      System.out.println("** Create Order for iPhone");
      LineItem item = new LineItem();
      item.setProduct(product);
      item.setQuantity(1);
      Order order = new Order();
      order.setTotal(product.getCost());
      order.setCustomer(customer);
      order.setDate(new Date().toString());
      order.getLineItems().add(item);
      request = new ClientRequest(shoppingLinks.get("orders").getHref());
      request.body("application/xml", order);
View Full Code Here

        Map<String, Link> shoppingLinks = processLinkHeaders(response);

        System.out.println("** Populate Products");
        wr = c.resource(shoppingLinks.get("products").getHref());

        Product product = new Product();
        product.setName("iPhone");
        product.setCost(199.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("MacBook Pro");
        product.setCost(3299.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("iPod");
        product.setCost(49.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

    }
View Full Code Here

        System.out.println();
        System.out.println("Search for iPhone in the Product database");
        wr = c.resource(shoppingLinks.get("products").getHref());
        Products products = wr.queryParam("name", "iPhone").get(Products.class);
        Product product = null;
        if (products.getProducts().size() > 0) {
            System.out.println("- Found iPhone in the database.");
            product = products.getProducts().iterator().next();
        } else {
            throw new RuntimeException("Failed to find an iPhone in the database!");
        }

        System.out.println();
        System.out.println("** Create Order for iPhone");
        LineItem item = new LineItem();
        item.setProduct(product);
        item.setQuantity(1);
        Order order = new Order();
        order.setTotal(product.getCost());
        order.setCustomer(customer);
        order.setDate(new Date().toString());
        order.getLineItems().add(item);
        wr = c.resource(shoppingLinks.get("orders").getHref());
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, order);
View Full Code Here

   public static LineItem entity2domain(LineItemEntity entity)
   {
      LineItem item = new LineItem();
      item.setId(entity.getId());
      Product product = ProductResourceBean.entity2domain(entity.getProduct());
      item.setProduct(product);
      item.setQuantity(entity.getQuantity());
      return item;
   }
View Full Code Here

   public static LineItem entity2domain(LineItemEntity entity)
   {
      LineItem item = new LineItem();
      item.setId(entity.getId());
      Product product = ProductResourceBean.entity2domain(entity.getProduct());
      item.setProduct(product);
      item.setQuantity(entity.getQuantity());
      return item;
   }
View Full Code Here

        Map<String, Link> shoppingLinks = processLinkHeaders(response);

        System.out.println("** Populate Products");
        wr = c.resource(shoppingLinks.get("products").getHref());

        Product product = new Product();
        product.setName("iPhone");
        product.setCost(199.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("MacBook Pro");
        product.setCost(3299.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

        product = new Product();
        product.setName("iPod");
        product.setCost(49.99);
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, product);
        Assert.assertEquals(201, response.getStatus());

    }
View Full Code Here

        System.out.println();
        System.out.println("Search for iPhone in the Product database");
        wr = c.resource(shoppingLinks.get("products").getHref());
        Products products = wr.queryParam("name", "iPhone").get(Products.class);
        Product product = null;
        if (products.getProducts().size() > 0) {
            System.out.println("- Found iPhone in the database.");
            product = products.getProducts().iterator().next();
        } else {
            throw new RuntimeException("Failed to find an iPhone in the database!");
        }

        System.out.println();
        System.out.println("** Create Order for iPhone");
        LineItem item = new LineItem();
        item.setProduct(product);
        item.setQuantity(1);
        Order order = new Order();
        order.setTotal(product.getCost());
        order.setCustomer(customer);
        order.setDate(new Date().toString());
        order.getLineItems().add(item);
        wr = c.resource(shoppingLinks.get("orders").getHref());
        response = wr.type(MediaType.APPLICATION_XML).post(ClientResponse.class, order);
View Full Code Here

TOP

Related Classes of com.restfully.shop.domain.Product

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.