Ejemplo n.º 1
0
  /**
   * Can we handle a full stream.publish example?
   *
   * <p>See http://wiki.developers.facebook.com/index.php/Attachment_(Streams).
   */
  @Test
  public void streamPublish() throws JSONException {
    ActionLink category = new ActionLink();
    category.href = "http://bit.ly/KYbaN";
    category.text = "humor";

    Properties properties = new Properties();
    properties.category = category;
    properties.ratings = "5 stars";

    Medium medium = new Medium();
    medium.href = "http://bit.ly/187gO1";
    medium.src =
        "http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg";
    medium.type = "image";

    List<Medium> media = new ArrayList<Medium>();
    media.add(medium);

    Attachment attachment = new Attachment();
    attachment.name = "i'm bursting with joy";
    attachment.href = "http://bit.ly/187gO1";
    attachment.caption = "{*actor*} rated the lolcat 5 stars";
    attachment.description = "a funny looking cat";
    attachment.properties = properties;
    attachment.media = media;

    String json = createJsonMapper().toJson(attachment);
    String expectedJson =
        "{\"description\":\"a funny looking cat\",\"name\":\"i'm bursting with joy\",\"caption\":\"{*actor*} rated the lolcat 5 stars\",\"properties\":{\"category\":{\"text\":\"humor\",\"href\":\"http://bit.ly/KYbaN\"},\"ratings\":\"5 stars\"},\"media\":[{\"src\":\"http://icanhascheezburger.files.wordpress.com/2009/03/funny-pictures-your-cat-is-bursting-with-joy1.jpg\",\"type\":\"image\",\"href\":\"http://bit.ly/187gO1\"}],\"href\":\"http://bit.ly/187gO1\"}";
    JSONAssert.assertEquals(expectedJson, json, JSONCompareMode.NON_EXTENSIBLE);
  }
Ejemplo n.º 2
0
 @Test
 public void testWithActionLinks() {
   ActionLink actionLink = ActionLink.withAction(Action.READ);
   recordLink.addActionLink("read", actionLink);
   assertEquals(recordLink.getActionLink("read"), actionLink);
   assertEquals(recordLink.getActionLinks().get("read"), actionLink);
   assertNull(recordLink.getActionLink("notAnAction"));
 }
Ejemplo n.º 3
0
  public void createRow(List<Widget> widgets) {
    if (isAutoNumber) {
      row.add(getTd(new InlineLabel(rowNum + "")));
    }

    for (Widget widget : widgets) {
      row.add(getTd(widget));
    }

    if (isShowRemove) {
      ActionLink anchor = new ActionLink();
      anchor.setTitle("Remove Line");
      anchor.getElement().setInnerHTML("<i class=\"icon-trash\"></i>");
      anchor.addClickHandler(
          new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
              RowWidget.this.removeFromParent();
            }
          });
      row.add(getTd(anchor));
    }
  }