@Override public final <U extends GraphObject> GraphObjectList<U> castToListOf(Class<U> graphObjectClass) { if (GraphObject.class.isAssignableFrom(itemType)) { if (graphObjectClass.isAssignableFrom(itemType)) { @SuppressWarnings("unchecked") GraphObjectList<U> result = (GraphObjectList<U>)this; return result; } return createList(state, graphObjectClass); } else { throw new FacebookGraphObjectException("Can't cast GraphObjectCollection of non-GraphObject type " + itemType); } }
void updateObjectAttachmentUrls(String objectProperty, List<String> attachmentUrls, boolean isUserGenerated) { final OpenGraphObject object; try { object = action.getPropertyAs(objectProperty, OpenGraphObject.class); if (object == null) { throw new IllegalArgumentException("Action does not contain a property '" + objectProperty + "'"); } } catch (FacebookGraphObjectException exception) { throw new IllegalArgumentException("Property '" + objectProperty + "' is not a graph object"); } if (!object.getCreateObject()) { throw new IllegalArgumentException( "The Open Graph object in '" + objectProperty + "' is not marked for creation"); } GraphObjectList<GraphObject> attachments = object.getImage(); if (attachments == null) { attachments = GraphObject.Factory.createList(GraphObject.class); } for (String url : attachmentUrls) { GraphObject graphObject = GraphObject.Factory.create(); graphObject.setProperty(NativeProtocol.IMAGE_URL_KEY, url); if (isUserGenerated) { graphObject.setProperty(NativeProtocol.IMAGE_USER_GENERATED_KEY, true); } attachments.add(graphObject); } object.setImage(attachments); }
@SmallTest @MediumTest @LargeTest public void testCantWrapBadPropertyNameOverrides() { try { GraphObject.Factory.create(BadPropertyOverrideInterfaceGraphObject.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }
public final <U extends GraphObject> GraphObjectList<U> castToListOf(Class<U> paramClass) { if (GraphObject.class.isAssignableFrom(this.itemType)) { if (paramClass.isAssignableFrom(this.itemType)) return this; return GraphObject.Factory.createList(this.state, paramClass); } throw new FacebookGraphObjectException("Can't cast GraphObjectCollection of non-GraphObject type " + this.itemType); }
@SmallTest @MediumTest @LargeTest public void testCantWrapBadGetterName() { try { GraphObject.Factory.create(BadGetterNameGraphObject.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }
@SmallTest @MediumTest @LargeTest public void testCantWrapBadZeroParameterMethodName() { try { GraphObject.Factory.create(BadNoParameterMethodNameGraphObject.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }
@SmallTest @MediumTest @LargeTest public void testCantWrapBadSetterName() { try { GraphObject.Factory.create(BadSetterNameGraphObject.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }
@SmallTest @MediumTest @LargeTest public void testCantWrapBadGetterParams() { try { GraphObject.Factory.create(BadGetterParamsGraphObject.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }
@SmallTest @MediumTest @LargeTest public void testCantWrapBadBaseInterface() { try { GraphObject.Factory.create(BadBaseInterfaceGraphObject.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }
@SmallTest @MediumTest @LargeTest public void testCantWrapBadSingleParameterMethodName() { try { GraphObject.Factory.create(BadSingleParameterMethodNameGraphObject.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }
@SmallTest @MediumTest @LargeTest public void testCantWrapNonInterface() { try { GraphObject.Factory.create(GraphObjectClass.class); fail("Expected exception"); } catch (FacebookGraphObjectException exception) { } }