Package br.com.caelum.restbucks.model

Examples of br.com.caelum.restbucks.model.Order


      Resources resources = new MappingConfig().getServer();

        // Place the order
        System.out.println(String.format("About to start happy path test. Placing order at [%s] via POST", uri.toString()));
        Order order = createOrder();
        order = resources.entryAt(uri).post(order);
       
        System.out.println(String.format("Order placed at [%s]", order.getSelfUri()));
       
        // Pay for the order
        Payment payment = new Payment("12345677878", "guilherme silveira", 12, 2999, order.getCost());
        System.out.println(String.format("About to create a payment resource at [%s] via PUT", resource(order).getRelation("payment").getHref()));
        payment =  order.pay(payment);
        System.out.println("Payment made, receipt created at: " + payment.getCreatedAt());

        // Check on the order status
        System.out.println(String.format("About to check order status at [%s] via GET", order.getSelfUri()));
        order = (Order) resource(order).getRelation("self").accessAndRetrieve();
        System.out.println(String.format("Final order placed, current status [%s]", order.getStatus()));
       
        // Allow the barista some time to make the order
        System.out.println("Pausing the client, press a key to continue");
        System.in.read();
       
        // Take the order if possible
        System.out.println(String.format("Trying to take the ready order from [%s] via DELETE. Note: the internal state machine must progress the order to ready before this should work, otherwise expect a 405 response.", order.getSelfUri()));
        order = (Order) resource(order).getRelation("self").accessAndRetrieve();
        Response finalResponse = resource(order).getRelation("retrieve").method(HttpMethod.DELETE).access();
        System.out.println(String.format("Tried to take final order, HTTP status [%d]", finalResponse.getCode()));
        if(finalResponse.getCode() == 200) {
            System.out.println(String.format("Order status [%s], enjoy your drink", finalResponse.getCode()));
View Full Code Here


  "  <atom:link href=\"http://localhost:3000/orders/360/payment\" xmlns:atom=\"http://www.w3.org/2005/Atom\" rel=\"pay\"/>"+
  "  <atom:link href=\"http://localhost:3000/orders/360\" xmlns:atom=\"http://www.w3.org/2005/Atom\" rel=\"update\"/>"+
  "</order>";
   
      Resources resources = new MappingConfig().getServer();
      Order order = (Order) resources.getDeserializer().fromXml(content);
      assertTrue(order!=null); // dumb test for config
  }
View Full Code Here

  "<items></items>"+
  "<status>unpaid</status>"+
  "</order>";
   
      Resources resources = new MappingConfig().getServer();
      Order order = new Order("unpaid", new ArrayList<Item>(), Location.takeAway);
      StringWriter w  = new StringWriter();
      resources.getSerializerFor(w, order).serialize();
      assertEquals(expected, w.getBuffer().toString());
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.restbucks.model.Order

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.