Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
Add destroy favorite feature
Browse files Browse the repository at this point in the history
  • Loading branch information
vergnesOL committed Mar 16, 2012
1 parent 905213e commit e73c7c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public interface FavoriteOperations {

Favorite createFavorite(long statusId);

Favorite deleteFavorite(long statusId);

Favorite getFavorite(long id);

CursoredList<Favorite> getFavorites();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,14 @@ public Favorite createFavorite(long statusId) {
request, Favorite.class);
}

@Override
public Favorite deleteFavorite(long statusId) {
requireAuthorization();
MultiValueMap<String, String> request = new LinkedMultiValueMap<String, String>(
1);
request.add("id", String.valueOf(statusId));
return restTemplate.postForObject(buildUri("favorites/destroy.json"),
request, Favorite.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,17 @@ public void testCreateFavorite() {
verifyFavorite(favoriteTemplate.createFavorite(1));
}

@Test
public void testDeleteFavorite() {
mockServer
.expect(requestTo("https://api.weibo.com/2/favorites/destroy.json"))
.andExpect(method(POST))
.andExpect(body("id=1"))
.andExpect(header("Authorization", "OAuth2 accessToken"))
.andRespond(
withResponse(jsonResource("favorite"), responseHeaders));
verifyFavorite(favoriteTemplate.deleteFavorite(1));

}

}

0 comments on commit e73c7c0

Please sign in to comment.