Permalink
Browse files

Add /BlogPost/featured and integration tests

  • Loading branch information...
1 parent 768d0e4 commit 3baaf7160ba203e7ffde615f3c2ec2ebbe9f681b @dasevilla dasevilla committed Jan 19, 2012
@@ -38,11 +38,11 @@ public Counter counter(ReadableDateTime createdAfter) {
public Creator<BlogPost> creator(BlogPost blogPost) {
return new BlogPostCreator(connection, config, endpointForPOST(), blogPost);
}
-
+
public final Deleter<BlogPost> deleter(Key<BlogPost> id) {
return new DefaultDeleter<BlogPost>(connection, config, endpointForDELETE(), id);
}
-
+
public Lister listerForRecent(BlogPostField firstField, BlogPostField... otherFields) {
return listerForRecent(new Fields<BlogPostField>(BlogPostField.class, firstField, otherFields));
}
@@ -52,15 +52,24 @@ public Lister listerForRecent(Fields<BlogPostField> fields) {
null, null, null);
}
+ public Lister listerForFeatured(BlogPostField firstField, BlogPostField... otherFields) {
+ return listerForFeatured(new Fields<BlogPostField>(BlogPostField.class, firstField, otherFields));
+ }
+
+ public Lister listerForFeatured(Fields<BlogPostField> fields) {
+ return new Lister(connection, config, endpointForFeatured(), fields,
+ null, null, null);
+ }
+
public Updater<BlogPost> updater(BlogPost blogPost) {
return new BlogPostUpdater(connection, config, endpointForPUT(), blogPost);
}
-
+
/*
///////////////////////////////////////////////////////////////////////
// Request builder classes (Creator, Updater, Finder, UserLister, ActivityCounter)
///////////////////////////////////////////////////////////////////////
- */
+ */
/**
* Intermediate accessor used for building and executing "count" requests.
@@ -79,7 +88,7 @@ protected Counter(Counter base, String author, Boolean isPrivate, Boolean isAppr
this(base.connection, base.config, base.endpoint, base.createdAfter,
author, isPrivate, isApproved);
}
-
+
public Counter author(String author) {
return new Counter(this, author, isPrivate, isApproved);
}
@@ -91,7 +100,7 @@ public Counter approved() {
public Counter unapproved() {
return new Counter(this, author, isPrivate, Boolean.FALSE);
}
-
+
public Counter onlyPrivate() {
return new Counter(this, author, Boolean.TRUE, isApproved);
}
@@ -104,7 +113,7 @@ public Counter onlyPublic() {
public static class BlogPostCreator extends DefaultCreator<BlogPost>
{
protected BlogPost blogPost;
-
+
public BlogPostCreator(NingConnection connection, NingClientConfig config, String endpoint,
BlogPost blogPost)
{
@@ -130,7 +139,7 @@ public BlogPostCreator draft() {
blogPost.setPublishStatus(PublishStatus.draft);
blogPost.setPublishTime(null);
return this;
- }
+ }
/**
* Method for indicating that the BlogPost being created will be published
@@ -141,7 +150,7 @@ public BlogPostCreator published() {
blogPost.setPublishStatus(PublishStatus.publish);
blogPost.setPublishTime(null);
return this;
- }
+ }
/**
* Method for indicating that the BlogPost being created will be published
@@ -152,8 +161,8 @@ public BlogPostCreator published(ReadableDateTime publishTime) {
blogPost.setPublishStatus(PublishStatus.queued);
blogPost.setPublishTime(publishTime);
return this;
- }
-
+ }
+
@Override
protected NingHttpPost addCreateParameters(NingHttpPost create)
{
@@ -175,7 +184,7 @@ protected NingHttpPost addCreateParameters(NingHttpPost create)
return create;
}
}
-
+
/**
* Accessor used for fetching sequences of items
*/
@@ -196,12 +205,12 @@ public Lister approved() {
return new Lister(connection, config, endpoint, fields,
author, isPrivate, Boolean.TRUE);
}
-
+
public Lister unapproved() {
return new Lister(connection, config, endpoint, fields,
author, isPrivate, Boolean.FALSE);
}
-
+
public Lister onlyPrivate() {
return new Lister(connection, config, endpoint, fields,
author, Boolean.TRUE, isApproved);
@@ -217,7 +226,7 @@ public Lister onlyPublic() {
return new PagedListImpl<BlogPost,BlogPostField>(connection, config, endpoint,
BlogPost.class, fields, author, isPrivate, isApproved);
}
- }
+ }
public static class BlogPostUpdater extends DefaultUpdater<BlogPost>
{
@@ -248,7 +257,7 @@ public BlogPostUpdater draft() {
blogPost.setPublishStatus(PublishStatus.draft);
blogPost.setPublishTime(null);
return this;
- }
+ }
/**
* Method for indicating that the BlogPost being created will be published
@@ -259,7 +268,7 @@ public BlogPostUpdater published() {
blogPost.setPublishStatus(PublishStatus.publish);
blogPost.setPublishTime(null);
return this;
- }
+ }
/**
* Method for indicating that the BlogPost being created will be published
@@ -270,14 +279,14 @@ public BlogPostUpdater published(ReadableDateTime publishTime) {
blogPost.setPublishStatus(PublishStatus.queued);
blogPost.setPublishTime(publishTime);
return this;
- }
+ }
public BlogPostUpdater approved(Boolean approvedOrNot) {
this.blogPost = blogPost.clone();
blogPost.setApproved(approvedOrNot);
return this;
}
-
+
@Override
protected NingHttpPut addUpdateParameters(NingHttpPut put)
{
@@ -286,7 +295,7 @@ protected NingHttpPut addUpdateParameters(NingHttpPut put)
throw new IllegalArgumentException("Missing mandatory field 'id'");
}
put = put.addFormParameter("id", id.toString());
-
+
if (blogPost.getDescription() != null) {
put = put.addFormParameter("description", blogPost.getDescription());
}
@@ -27,6 +27,7 @@
// And then the rest
updatedDate(ReadableDateTime.class),
+ featuredDate(ReadableDateTime.class),
url(URI.class),
visibility(Visibility.class),
commentCount(Integer.class),
Oops, something went wrong.

0 comments on commit 3baaf71

Please sign in to comment.