diff --git a/Flickr4Java/BUILDING.md b/Flickr4Java/BUILDING.md index 562324e7..9a6c422a 100644 --- a/Flickr4Java/BUILDING.md +++ b/Flickr4Java/BUILDING.md @@ -19,22 +19,38 @@ The following tasks are available: ## Testing -Most of the tests are integration tests, and require hitting the actual Flickr -API service with DELETE permissions. The safest and easiest way to do this is to -set up a test user account, the following photos etc.: - -1. At least one photo in one album -2. At least one collection with title and description, containing at least one album - (the ID of the collection can be retrieved manually via the - [API explorer](https://www.flickr.com/services/api/explore/flickr.collections.getTree) - and be added as `collectionid` in `src/test/resources/setup.properties`) -3. *[List is incomplete]* - To test: 1. Copy `src/test/resources/setup.properties.example` to `src/test/resources/setup.properties` 2. Run `gradle compiletestjava -q` — compile all sources -3. Run `gradle setuptests -q` — this will prompt for authorisation and update the above `setup.properties` file -4. Run `gradle test` +3. Run `gradle setuptests -q` — this will prompt for authorisation + and update the `setup.properties` file with the test user's details +4. Run `gradle test` — can be run as `gradle -Dtest.single=NameOfTest test` to + run only one test (because the full suite can take quite a while) (The `-q` above just hides some of the more verbose output; it can be left out.) + +Most of the tests are integration tests and require hitting the actual Flickr +API service with DELETE permissions. The safest and easiest way to do this is to +set up a test user account with the following: + +1. At least one photo with a location set, in at least one album, with exactly 3 tags. + Add this photo's ID as `photoid` and `geo.write.photoid` in `setup.properties`. +2. At least one collection with title and description, containing at least one album + (the ID of the collection should be retrieved manually via the + [API explorer](https://www.flickr.com/services/api/explore/flickr.collections.getTree) + and be added as `collectionid` in `setup.properties`). +3. At least one comment on another user's photo. +4. Following at least one other user. +5. At least one favorite. +6. Allows 'anyone' "to see your stuff on a map". +7. A member of at least one group, whose ID is saved as `testgroupid`. +8. A gallery, containing at least one photo. +9. An "[own Flickr address](https://www.flickr.com/profile_url.gne)" set to `username` (see below). +10. *[List is incomplete]* + +The last few keys in the `setup.properties` need to be as follows: + +* Set the following keys in `setup.properties` to match your test user: + `nsid`, `username`, `displayname`, and `email`. +* Point `imagefile` to a test image that will be uploaded (and then deleted). diff --git a/Flickr4Java/src/test/java/com/flickr4java/flickr/test/FavoritesInterfaceTest.java b/Flickr4Java/src/test/java/com/flickr4java/flickr/test/FavoritesInterfaceTest.java index acc05682..dfaffef7 100644 --- a/Flickr4Java/src/test/java/com/flickr4java/flickr/test/FavoritesInterfaceTest.java +++ b/Flickr4Java/src/test/java/com/flickr4java/flickr/test/FavoritesInterfaceTest.java @@ -45,7 +45,7 @@ public void testGetPublicList() throws FlickrException { FavoritesInterface iface = flickr.getFavoritesInterface(); Collection favorites = iface.getPublicList(testProperties.getNsid(), 0, 0, null); assertNotNull(favorites); - assertTrue(favorites.size() > 1); + assertTrue(favorites.size() > 0); } @Test diff --git a/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PeopleInterfaceTest.java b/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PeopleInterfaceTest.java index b22af4c4..17f213af 100644 --- a/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PeopleInterfaceTest.java +++ b/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PeopleInterfaceTest.java @@ -33,13 +33,13 @@ public void testFindByEmail() throws FlickrException { User person = iface.findByEmail(testProperties.getEmail()); assertNotNull(person); assertEquals(person.getId(), testProperties.getNsid()); - assertEquals(person.getUsername(), testProperties.getDisplayname()); + assertEquals(person.getUsername(), testProperties.getUsername()); } @Test public void testFindByUsername() throws FlickrException { PeopleInterface iface = flickr.getPeopleInterface(); - User person = iface.findByUsername(testProperties.getDisplayname()); + User person = iface.findByUsername(testProperties.getUsername()); assertNotNull(person); assertEquals(testProperties.getNsid(), person.getId()); assertEquals(testProperties.getUsername(), person.getUsername()); @@ -56,7 +56,7 @@ public void testGetInfo() throws FlickrException { User person = iface.getInfo(testProperties.getNsid()); assertNotNull(person); assertEquals(testProperties.getNsid(), person.getId()); - assertEquals(testProperties.getDisplayname(), person.getUsername()); + assertEquals(testProperties.getDisplayname(), person.getRealName()); assertTrue(person.getMobileurl().startsWith("https://m.flickr.com/photostream.gne")); assertEquals(person.getPhotosurl(), String.format("https://www.flickr.com/photos/%s/", testProperties.getUsername())); assertEquals(person.getProfileurl(), String.format("https://www.flickr.com/people/%s/", testProperties.getUsername())); @@ -93,7 +93,7 @@ public void testGetPhotos() throws FlickrException { PeopleInterface iface = flickr.getPeopleInterface(); PhotoList photos = iface.getPhotos(testProperties.getNsid(), null, null, null, null, null, null, null, null, 15, 1); assertNotNull(photos); - assertTrue(photos.size() > 1); + assertTrue(photos.size() > 0); } @Test @@ -101,7 +101,7 @@ public void testGetPhotosOf() throws FlickrException { PeopleInterface iface = flickr.getPeopleInterface(); PhotoList photos = iface.getPhotosOf(testProperties.getNsid(), null, null, 10, 1); assertNotNull(photos); - assertTrue(photos.size() > 1); + assertTrue(photos.size() > 0); } @Test diff --git a/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PhotosInterfaceTest.java b/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PhotosInterfaceTest.java index 0eef55b1..868c13f7 100644 --- a/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PhotosInterfaceTest.java +++ b/Flickr4Java/src/test/java/com/flickr4java/flickr/test/PhotosInterfaceTest.java @@ -66,13 +66,23 @@ public void teardown() { public void testAddAndRemoveTags() throws FlickrException { PhotosInterface iface = flickr.getPhotosInterface(); String photoId = testProperties.getPhotoId(); + Photo photo = iface.getInfo(photoId, null); + + // Find number of existing tags + int preCount = photo.getTags().size(); + int postCount = preCount + 1; + + // Add a tag String[] tagsToAdd = { "test" }; iface.addTags(photoId, tagsToAdd); - Photo photo = iface.getInfo(photoId, null); + + // Check that it was added + photo = iface.getInfo(photoId, null); Collection tags = photo.getTags(); assertNotNull(tags); - assertEquals(4, tags.size()); + assertEquals(postCount, tags.size()); + // Get the added tag's ID String tagId = null; for (Tag tag : tags) { if (tag.getValue().equals("test")) { @@ -81,11 +91,12 @@ public void testAddAndRemoveTags() throws FlickrException { } } + // Remove and check that it was removed iface.removeTag(tagId); photo = iface.getInfo(photoId, null); tags = photo.getTags(); assertNotNull(tags); - assertEquals(3, tags.size()); + assertEquals(preCount, tags.size()); } @Test @@ -110,7 +121,7 @@ public void testGetInfo() throws FlickrException { User owner = photo.getOwner(); assertEquals(testProperties.getNsid(), owner.getId()); - assertEquals(testProperties.getDisplayname(), owner.getUsername()); + assertEquals(testProperties.getUsername(), owner.getUsername()); List tags = (List) photo.getTags(); assertEquals("green", (tags.get(0)).getValue()); @@ -325,7 +336,7 @@ public void testGetThumbnailImage() throws FlickrException, IOException { Photo photo = iface.getInfo(photoId, null); BufferedImage image = iface.getImage(photo, Size.THUMB); assertNotNull(image); - assertEquals(67, image.getWidth()); + assertTrue(67==image.getWidth() || 68==image.getWidth()); assertEquals(100, image.getHeight()); ImageIO.write(image, "jpg", thumbnailFile); }