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

Commit

Permalink
Fixed parsing problem with Blackberry and Android objects in returned…
Browse files Browse the repository at this point in the history
… Feed JSON.
  • Loading branch information
habuma committed Apr 10, 2012
1 parent 40c7b0e commit e4e4ff9
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 13 deletions.
10 changes: 10 additions & 0 deletions headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
HTTP/1.1 200 OK
Server: Apache/2.2.3 (CentOS)
X-Server: app08
Content-Type: text/html; charset=utf-8
Vary: Authorization
Vary: Cookie
Date: Fri, 06 Apr 2012 01:58:25 GMT
Content-Length: 435
Connection: keep-alive

Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,16 @@ public class Feed {

private final boolean broadcast;

private Feed(String id, String url, String feedUrl, Date lastChecked, FeedNotificationTemplate template, boolean broadcast) {
private final boolean airmail;

private Feed(String id, String url, String feedUrl, Date lastChecked, FeedNotificationTemplate template, boolean broadcast, boolean airmail) {
this.id = id;
this.url = url;
this.feedUrl = feedUrl;
this.lastChecked = lastChecked;
this.template = template;
this.broadcast = broadcast;
this.airmail = airmail;
}

public String getId() {
Expand All @@ -64,5 +67,8 @@ public boolean isBroadcast() {
return broadcast;
}

public boolean isAirmail() {
return airmail;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ public Feed createFeed(FeedConfig feedConfig) {
}

public Feed getFeed(String feedId) {
return restOperations.getForObject(FEED_URL + feedId, Feed.class);
return restOperations.getForObject(FEED_URL + feedId + "/", Feed.class);
}

public List<Feed> getFeeds() {
return restOperations.getForObject(FEED_URL, FeedList.class);
}

public void updateFeed(String feedId, FeedConfig feedConfig) {
restOperations.put(FEED_URL + feedId, feedConfig);
restOperations.put(FEED_URL + feedId + "/", feedConfig);
}

public void deleteFeed(String feedId) {
restOperations.delete(FEED_URL + feedId);
restOperations.delete(FEED_URL + feedId + "/");
}

private static final String FEED_URL = URBANAIRSHIP_API_URL + "feeds/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Map;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonSerialize;
Expand All @@ -25,8 +26,9 @@
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
abstract class AndroidMixin {

@JsonProperty("alert")
String alert;
@JsonCreator
AndroidMixin(
@JsonProperty("alert") String alert) {}

@JsonProperty("extra")
Map<String, String> extra;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@
*/
package org.springframework.mobile.urbanairship.impl.json;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonPropertyOrder;

@JsonPropertyOrder({"content-type", "body"})
abstract class BlackberryMixin {

@JsonCreator
BlackberryMixin(
@JsonProperty("body") String body) {}

@JsonProperty("content-type")
String contentType;

@JsonProperty("body")
String body;

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ abstract class FeedMixin {
@JsonProperty("feed_url") String feedUrl,
@JsonProperty("last_checked") @JsonDeserialize(using=DateDeserializer.class) Date lastChecked,
@JsonProperty("template") FeedNotificationTemplate template,
@JsonProperty("boolean") boolean broadcast) {}
@JsonProperty("boolean") boolean broadcast,
@JsonProperty("airmail") boolean airmail) {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void createFeed_minimal() {

@Test
public void getFeed() {
masterKeyMockServer.expect(requestTo("https://go.urbanairship.com/api/feeds/12345"))
masterKeyMockServer.expect(requestTo("https://go.urbanairship.com/api/feeds/12345/"))
.andExpect(method(GET))
.andRespond(withResponse(jsonResource("data/feed"), responseHeaders));
Feed feed = urbanAirship.feedOperations().getFeed("12345");
Expand Down Expand Up @@ -83,7 +83,7 @@ public void getFeeds() {

@Test
public void updateFeed() {
masterKeyMockServer.expect(requestTo("https://go.urbanairship.com/api/feeds/12345"))
masterKeyMockServer.expect(requestTo("https://go.urbanairship.com/api/feeds/12345/"))
.andExpect(method(PUT))
.andExpect(body(readCompactedJsonResource(jsonResource("data/feed-create"))))
.andRespond(withResponse("", responseHeaders));
Expand All @@ -94,7 +94,7 @@ public void updateFeed() {

@Test
public void deleteFeed() {
masterKeyMockServer.expect(requestTo("https://go.urbanairship.com/api/feeds/12345"))
masterKeyMockServer.expect(requestTo("https://go.urbanairship.com/api/feeds/12345/"))
.andExpect(method(DELETE))
.andRespond(withResponse("", responseHeaders, HttpStatus.NO_CONTENT, ""));
urbanAirship.feedOperations().deleteFeed("12345");
Expand Down

0 comments on commit e4e4ff9

Please sign in to comment.