TweetMediaUtils { public static boolean hasPhoto(Tweet tweet) { return getPhotoEntity(tweet) != null; } private  TweetMediaUtils(); static MediaEntity getPhotoEntity(Tweet tweet); static List<MediaEntity> getPhotoEntities(Tweet tweet); static boolean hasPhoto(Tweet tweet); static MediaEntity getVideoEntity(Tweet tweet); static boolean hasSupportedVideo(Tweet tweet); static VideoInfo.Variant getSupportedVariant(MediaEntity mediaEntity); static boolean isLooping(MediaEntity mediaEntity); static boolean showVideoControls(MediaEntity mediaEntity); static final String PHOTO_TYPE; static final String VIDEO_TYPE; static final String GIF_TYPE; }
@Test public void testHasPhoto_hasPhotoEntity() { final MediaEntity entity = TestFixtures.newMediaEntity(TEST_INDICES_START, TEST_INDICES_END, TEST_MEDIA_TYPE_PHOTO); final ArrayList<MediaEntity> media = new ArrayList<>(); media.add(entity); final TweetEntities entities = new TweetEntities(null, null, media, null, null); final Tweet tweet = new TweetBuilder().setEntities(entities).build(); assertTrue(TweetMediaUtils.hasPhoto(tweet)); }
@Test public void testHasPhoto_noPhotoEntity() { final MediaEntity entity = TestFixtures.newMediaEntity(TEST_INDICES_START, TEST_INDICES_END, TEST_MEDIA_TYPE_VIDEO); final ArrayList<MediaEntity> media = new ArrayList<>(); media.add(entity); final TweetEntities entities = new TweetEntities(null, null, media, null, null); final Tweet tweet = new TweetBuilder().setEntities(entities).build(); assertFalse(TweetMediaUtils.hasPhoto(tweet)); }
@Test public void testHasPhoto_uninitializedMediaEntities() { final TweetEntities entities = new TweetEntities(null, null, null, null, null); final Tweet tweet = new TweetBuilder().setEntities(entities).build(); assertFalse(TweetMediaUtils.hasPhoto(tweet)); }
@Test public void testHasPhoto_nullEntities() { final Tweet tweet = new TweetBuilder().setEntities(null).build(); assertFalse(TweetMediaUtils.hasPhoto(tweet)); }