Package rocks.xmpp.extensions.data.model

Examples of rocks.xmpp.extensions.data.model.DataForm$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

      FilePersistenceTooBigForSerializationException {

    IFilePersistence filePersistence = createFilePersistence(true);
    IDataAccessSession session = filePersistence.createDataAccessSession();
    session.open();
    Item item = new Item(0, "value");
    session.setObject("key", item);
    session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
    filePersistence.close();

    filePersistence = createFilePersistence(false);
    session = filePersistence.createDataAccessSession();
    session.open();
    item = (Item) session.getObject("key");
    assertEquals("bad state", 0, item.getIdentifier());
    assertEquals("bad state", "value", item.getValue());
    session.closeAndWait(EnumFilePersistenceCloseAction.SAVE);
    filePersistence.close();
  }
View Full Code Here

                "  </uri>\n" +
                "   </media>" +
                "  </field>\n" +
                "</x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getType(), DataForm.Type.FORM);
        Media media = dataForm.getFields().get(0).getMedia();
        Assert.assertNotNull(media);
        Assert.assertEquals(media.getHeight(), 0);
        Assert.assertEquals(media.getWidth(), 0);
    }
View Full Code Here

                "      <uri type='image/jpeg'>cid:sha1+f24030b8d91d233bac14777be5ab531ca3b9f102@bob.xmpp.org</uri>\n" +
                "    </media>\n" +
                "  </field>\n" +
                "</x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getType(), DataForm.Type.FORM);
        Media media = dataForm.getFields().get(0).getMedia();
        Assert.assertNotNull(media);
        Assert.assertEquals(media.getHeight(), 80);
        Assert.assertEquals(media.getWidth(), 290);
        Assert.assertEquals(media.getLocations().size(), 2);
        Assert.assertEquals(media.getLocations().get(0).getType(), "image/jpeg");
View Full Code Here

                "  </field>\n" +
                "  <field var='activity.xeps' type='text-multi' label='XEPs Authored or Co-Authored'>\n" +
                "  </field>\n" +
                "</x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 3);
        Assert.assertEquals(dataForm.getPages().get(0).getText().size(), 2);
        Assert.assertEquals(dataForm.getPages().get(0).getText().get(0), "This is page one of three.");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().size(), 5);
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(0).getVar(), "name.first");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(1).getVar(), "name.last");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(2).getVar(), "email");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(3).getVar(), "jid");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(4).getVar(), "background");
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.data.model.DataForm$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.