use of org.wordpress.android.ui.stats.models.TopPostsAndPagesModel in project WordPress-Android by wordpress-mobile.
the class RemoteTests method testTopPost.
public void testTopPost() throws Exception {
StatsRestRequestAbstractListener listener = new StatsRestRequestAbstractListener() {
@Override
void parseResponse(JSONObject response) throws JSONException {
TopPostsAndPagesModel model = new TopPostsAndPagesModel(123456, response);
assertNotNull(model.getTopPostsAndPages());
assertEquals(model.getTopPostsAndPages().size(), 10);
StatsPostModel postModel = model.getTopPostsAndPages().get(0);
assertEquals(postModel.getItemID(), "39806");
assertEquals(postModel.getTotals(), 2420);
assertEquals(postModel.getTitle(), "Home");
assertEquals(postModel.getUrl(), "http://automattic.com/home/");
assertEquals(postModel.getDate(), StatsUtils.toMs("2011-08-30 21:47:38"));
assertEquals(postModel.getPostType(), "page");
postModel = model.getTopPostsAndPages().get(9);
assertEquals(postModel.getItemID(), "39254");
assertEquals(postModel.getTotals(), 56);
assertEquals(postModel.getTitle(), "Growth Explorer");
assertEquals(postModel.getUrl(), "http://automattic.com/work-with-us/growth-explorer/");
assertEquals(postModel.getDate(), StatsUtils.toMs("2011-08-25 19:37:27"));
assertEquals(postModel.getPostType(), "page");
}
};
mRestClient.makeRequest(Request.Method.POST, "https://public-api.wordpress.com/rest/v1.1/sites/123456/stats/top-posts", null, listener, errListener);
}
use of org.wordpress.android.ui.stats.models.TopPostsAndPagesModel in project WordPress-Android by wordpress-mobile.
the class RemoteTests method testTopPostEmptyURL.
public void testTopPostEmptyURL() throws Exception {
StatsRestRequestAbstractListener listener = new StatsRestRequestAbstractListener() {
@Override
void parseResponse(JSONObject response) throws JSONException {
TopPostsAndPagesModel model = new TopPostsAndPagesModel(1234567890, response);
assertNotNull(model.getTopPostsAndPages());
assertEquals(model.getTopPostsAndPages().size(), 10);
StatsPostModel postModel = model.getTopPostsAndPages().get(0);
assertEquals(postModel.getItemID(), "750");
assertEquals(postModel.getTotals(), 7);
assertEquals(postModel.getTitle(), "Asynchronous unit testing Core Data with Xcode 6");
// This post has no URL?!? Unpublished post that was prev published?
assertEquals(postModel.getUrl(), "");
assertEquals(postModel.getDate(), StatsUtils.toMs("2014-08-06 14:52:11"));
assertEquals(postModel.getPostType(), "post");
}
};
mRestClient.makeRequest(Request.Method.POST, "https://public-api.wordpress.com/rest/v1.1/sites/1234567890/stats/top-posts", null, listener, errListener);
}
Aggregations