Permalink
Browse files

#15 Adding test for getLovedTracks when response is empty to reproduc…

…e issue #15
  • Loading branch information...
1 parent 3725b61 commit 2c1e416ab23e145331db2ace5cdf29593b85c743 @michaellavelle committed Jan 13, 2012
@@ -279,6 +279,30 @@ public void getLovedTracksSingleTrackResponse() {
assertTrackData(tracks.get(0));
}
+
+ /**
+ * Tests for the case where the loved tracks response contains only a single
+ * track. In this case the Json format of the response is different to the
+ * response for multiple tracks
+ */
+ @Test
+ public void getLovedTracksEmptyResponse() {
+
+ mockServer
+ .expect(requestTo("http://ws.audioscrobbler.com/2.0/?format=json&api_key=someApiKey&method=user.getlovedtracks&user=mattslip"))
+ .andExpect(method(GET))
+ .andExpect(header("User-Agent", "someUserAgent"))
+ .andRespond(
+ withResponse(
+ jsonResource("testdata/loved-tracks-empty"),
+ responseHeaders));
+
+ List<Track> tracks = lastFm.userOperations().getLovedTracks("mattslip");
+ assertNotNull(tracks);
+ assertEquals(0,tracks.size());
+
+ }
+
@Test
public void getLovedTracks_withoutAuthorization() {
@@ -0,0 +1,3 @@
+{"lovedtracks":{"#text":"\n","user":"mattslip","page":"0","perPage":"50","totalPages":"0","total":"0"}}
+
+

0 comments on commit 2c1e416

Please sign in to comment.