@@ -66,13 +66,23 @@ public void teardown() {
6666 public void testAddAndRemoveTags () throws FlickrException {
6767 PhotosInterface iface = flickr .getPhotosInterface ();
6868 String photoId = testProperties .getPhotoId ();
69+ Photo photo = iface .getInfo (photoId , null );
70+
71+ // Find number of existing tags
72+ int preCount = photo .getTags ().size ();
73+ int postCount = preCount + 1 ;
74+
75+ // Add a tag
6976 String [] tagsToAdd = { "test" };
7077 iface .addTags (photoId , tagsToAdd );
71- Photo photo = iface .getInfo (photoId , null );
78+
79+ // Check that it was added
80+ photo = iface .getInfo (photoId , null );
7281 Collection <Tag > tags = photo .getTags ();
7382 assertNotNull (tags );
74- assertEquals (4 , tags .size ());
83+ assertEquals (postCount , tags .size ());
7584
85+ // Get the added tag's ID
7686 String tagId = null ;
7787 for (Tag tag : tags ) {
7888 if (tag .getValue ().equals ("test" )) {
@@ -81,11 +91,12 @@ public void testAddAndRemoveTags() throws FlickrException {
8191 }
8292 }
8393
94+ // Remove and check that it was removed
8495 iface .removeTag (tagId );
8596 photo = iface .getInfo (photoId , null );
8697 tags = photo .getTags ();
8798 assertNotNull (tags );
88- assertEquals (3 , tags .size ());
99+ assertEquals (preCount , tags .size ());
89100 }
90101
91102 @ Test
@@ -110,7 +121,7 @@ public void testGetInfo() throws FlickrException {
110121
111122 User owner = photo .getOwner ();
112123 assertEquals (testProperties .getNsid (), owner .getId ());
113- assertEquals (testProperties .getDisplayname (), owner .getUsername ());
124+ assertEquals (testProperties .getUsername (), owner .getUsername ());
114125
115126 List <Tag > tags = (List <Tag >) photo .getTags ();
116127 assertEquals ("green" , (tags .get (0 )).getValue ());
@@ -325,7 +336,7 @@ public void testGetThumbnailImage() throws FlickrException, IOException {
325336 Photo photo = iface .getInfo (photoId , null );
326337 BufferedImage image = iface .getImage (photo , Size .THUMB );
327338 assertNotNull (image );
328- assertEquals (67 , image .getWidth ());
339+ assertTrue (67 == image . getWidth () || 68 == image .getWidth ());
329340 assertEquals (100 , image .getHeight ());
330341 ImageIO .write (image , "jpg" , thumbnailFile );
331342 }
0 commit comments