Package com.sun.jersey.samples.jmaki.beans

Examples of com.sun.jersey.samples.jmaki.beans.WebResourceList$Item


    Document doc = _docBuilder.newDocument();
    Element elem = doc.createElement("item-notes");
    Text textValue = doc.createTextNode("SalesID# 3445");
    elem.appendChild(textValue);
   
    Item item = pBuilder.createShoppingItem(itemName, itemDesc, quantity,
      unitPrice, null, currency, elem);
   
    assertEquals(itemName, item.getItemName());
    assertEquals(itemDesc, item.getItemDescription());
    assertEquals(quantity, item.getQuantity());
    assertEquals(4999.99F, item.getUnitPrice().getValue().floatValue());
    assertEquals(currency, item.getUnitPrice().getCurrency());
    assertEquals(elem, item.getMerchantPrivateItemData().getAny());
  }
View Full Code Here


    String[] itemDescs = new String[] {"mp3 player", "podcast subscription"};
    int[] quantities = new int[] {2, 1};
    float[] prices = new float[] {249.99F, 3.99F};
    List<Item> itemList = new ArrayList<Item>();
    for (int i = 0; i < itemNames.length; i++) {
      Item cartItem = pBuilder.createShoppingItem(itemNames[i], itemDescs[i],
        quantities[i], prices[i], null, null, null);
      itemList.add(cartItem);
    }
   
    return itemList;
View Full Code Here

  public Item createShoppingItem(String itemName, String itemDesc,
      int quantity, float unitPrice, String currency,
      String taxTableSelector, Element privateItemData)
      throws ProtocolException {
    Money money = createMoney(unitPrice, currency);
    Item item = _objectFact.createItem();
    item.setItemName(itemName);
    item.setItemDescription(itemDesc);
    item.setQuantity(quantity);
    item.setUnitPrice(money);

    if (taxTableSelector != null) {
      item.setTaxTableSelector(taxTableSelector);
    }
   
    if (privateItemData != null) {
      AnyType anyType = _objectFact.createAnyType();
      anyType.setAny(privateItemData);
      item.setMerchantPrivateItemData(anyType);
    }
   
    return item;
  }
View Full Code Here

      String taxTableSelector, Element privateItemData)
      throws ProtocolException {
   
    try {
      Money money = createMoney(unitPrice, currency);
      Item item = _objectFact.createItem();
      item.setItemName(itemName);
      item.setItemDescription(itemDesc);
      item.setQuantity(quantity);
      item.setUnitPrice(money);
 
      if (taxTableSelector != null) {
        item.setTaxTableSelector(taxTableSelector);
      }
     
      if (privateItemData != null) {
        AnyType anyType = _objectFact.createAnyType();
        anyType.setAny(privateItemData);
        item.setMerchantPrivateItemData(anyType);
      }
     
      return item;
    } catch (JAXBException jaxbEx) {
      throw new ProtocolException(jaxbEx.getMessage());
View Full Code Here

    Document doc = _docBuilder.newDocument();
    Element elem = doc.createElement("item-notes");
    Text textValue = doc.createTextNode("SalesID# 3445");
    elem.appendChild(textValue);
   
    Item item = pBuilder.createShoppingItem(itemName, itemDesc, quantity,
      unitPrice, null, currency, elem);
   
    assertEquals(itemName, item.getItemName());
    assertEquals(itemDesc, item.getItemDescription());
    assertEquals(quantity, item.getQuantity());
    assertEquals(4999.99F, item.getUnitPrice().getValue().floatValue(), 0);
    assertEquals(currency, item.getUnitPrice().getCurrency());
    assertEquals(elem, item.getMerchantPrivateItemData().getAny());
  }
View Full Code Here

    String[] itemDescs = new String[] {"mp3 player", "podcast subscription"};
    int[] quantities = new int[] {2, 1};
    float[] prices = new float[] {249.99F, 3.99F};
    List itemList = new ArrayList();
    for (int i = 0; i < itemNames.length; i++) {
      Item cartItem = pBuilder.createShoppingItem(itemNames[i], itemDescs[i],
        quantities[i], prices[i], null, null, null);
      itemList.add(cartItem);
    }
   
    return itemList;
View Full Code Here

     */
    @Test
    public void doTestGetPrinters() {
        WebResource webResource = resource();
        // GET Printers - mime-type application/json
        WebResourceList resourceList = webResource.path("printers").accept(MediaType.APPLICATION_JSON).get(WebResourceList.class);
        int numberOfResourceTypes = resourceList.items.size();
        Assert.assertEquals("Method: doTestGetPrinters \nMessage: Number of resource types retrieved " +
                "with MIME-TYPE application/json do not match the expected number.", 3, numberOfResourceTypes);

        // GET Printers - mime-type application/xml
View Full Code Here

     */
    @Test
    public void doTestGetPrinterList() {
        WebResource webResource = resource();
        //GET on printer list - mime-type application/json
        WebResourceList resourceList = webResource.path("printers").path("list").accept(MediaType.APPLICATION_JSON).get(WebResourceList.class);
        int numberOfPrinters = resourceList.items.size();
        Assert.assertEquals("Method: doTestGetPrinterList \nMessage: Number of printers retrieved " +
                "with MIME-TYPE application/json do not match the expected number.", 5, numberOfPrinters);

        //GET on printer list - mime-type application/xml
View Full Code Here

    @GET
    @Produces({"application/json", "application/xml"})
    public WebResourceList getMyResources() {
        if (null == myResources) {
            myResources = new WebResourceList();
            myResources.items = new LinkedList<WebResourceList.Item>();
            myResources.items.add(new WebResourceList.Item(
                    "list of printers", uriInfo.getBaseUriBuilder().path(this.getClass()).path("list").build().toString()));
            myResources.items.add(new WebResourceList.Item(
                    "jMaki table model", uriInfo.getBaseUriBuilder().path(this.getClass()).path("jMakiTable").build().toString()));
View Full Code Here

    }
   
    @GET @Path("/list")
    @Produces({"application/json", "application/xml"})
    public WebResourceList getListOfPrinters() {
        WebResourceList result = new WebResourceList();
        result.items = new LinkedList<WebResourceList.Item>();
        for (Printer p : getPrinters().values()) {
            result.items.add(new WebResourceList.Item(
                    (new Formatter()).format("%s (%s)", p.id, p.model).toString(),
                    uriInfo.getBaseUriBuilder().path(this.getClass()).path("ids").path(p.id).build().toString()));
View Full Code Here

TOP

Related Classes of com.sun.jersey.samples.jmaki.beans.WebResourceList$Item

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.