Exemplo n.º 1
0
 /** @throws FacebookException if the GraphObject doesn't have an ID. */
 String getIdOfGraphObject(T graphObject) {
   if (graphObject.asMap().containsKey(ID)) {
     Object obj = graphObject.getProperty(ID);
     if (obj instanceof String) {
       return (String) obj;
     }
   }
   throw new FacebookException("Received an object without an ID.");
 }
Exemplo n.º 2
0
  protected String getSectionKeyOfGraphObject(T graphObject) {
    String result = null;

    if (groupByField != null) {
      result = (String) graphObject.getProperty(groupByField);
      if (result != null && result.length() > 0) {
        result = result.substring(0, 1).toUpperCase();
      }
    }

    return (result != null) ? result : "";
  }
  /**
   * Create a mock CmisObject using Mockito that will contain the provided properties
   *
   * @param properties Array of arrays in the form of {{propertyId, displayName, propertyValue}}
   * @param clazz Class object in the CmisObject hierarchy that has to be created
   * @return The mocked CmisObject
   */
  protected <T extends CmisObject> T createMockedCmisObject(Object[][] properties, Class<T> clazz) {
    T object = mock(clazz);
    List<Property<?>> documentProperties = new ArrayList<Property<?>>();
    for (Object[] mockProp : properties) {
      Property prop = createMockedProperty(mockProp[0], mockProp[1], mockProp[2]);
      documentProperties.add(prop);
      when(object.getProperty(mockProp[0].toString())).thenReturn(prop);

      if (PropertyIds.NAME.equals(mockProp[0])) {
        when(object.getName()).thenReturn(mockProp[2].toString());
      }
    }
    when(object.getProperties()).thenReturn(documentProperties);

    return object;
  }
Exemplo n.º 4
0
  protected URI getPictureUriOfGraphObject(T graphObject) {
    String uri = null;
    Object o = graphObject.getProperty(PICTURE);
    if (o instanceof String) {
      uri = (String) o;
    } else if (o instanceof JSONObject) {
      ItemPicture itemPicture = GraphObject.Factory.create((JSONObject) o).cast(ItemPicture.class);
      ItemPictureData data = itemPicture.getData();
      if (data != null) {
        uri = data.getUrl();
      }
    }

    if (uri != null) {
      try {
        return new URI(uri);
      } catch (URISyntaxException e) {
      }
    }
    return null;
  }
Exemplo n.º 5
0
 protected CharSequence getTitleOfGraphObject(T graphObject) {
   return (String) graphObject.getProperty(NAME);
 }