@Test public void testBookmark() throws Exception { final User user = UserServiceFactory.getUserService().getCurrentUser(); bookmarkController.insertBookmark(postEntity.getWebsafeId(), user); List<Bookmark> bookmarks = ofy().load().type(Bookmark.class).ancestor(Key.<Account>create(user.getUserId())).list(); assertEquals(1, bookmarks.size()); }
public void insertBookmark(String postId, User user) { final Key<Account> authKey = Key.create(user.getUserId()); final Key<PostEntity> postKey = Key.create(postId); Bookmark saved = createBookmark(postKey, authKey); final Key<PostShard> postShardKey = postShardService.getRandomShardKey(postKey); PostShard shard = ofy().load().key(postShardKey).now(); shard.getBookmarkKeys().add(saved.getKey()); ofy().save().entities(saved, shard); }
BookmarkController extends Controller { public void insertBookmark(String postId, User user) { final Key<Account> authKey = Key.create(user.getUserId()); final Key<PostEntity> postKey = Key.create(postId); Bookmark saved = createBookmark(postKey, authKey); final Key<PostShard> postShardKey = postShardService.getRandomShardKey(postKey); PostShard shard = ofy().load().key(postShardKey).now(); shard.getBookmarkKeys().add(saved.getKey()); ofy().save().entities(saved, shard); } }
BookmarkController extends Controller { public void insertBookmark(String postId, User user) { final Key<Account> authKey = Key.create(user.getUserId()); final Key<PostEntity> postKey = Key.create(postId); Bookmark saved = createBookmark(postKey, authKey); final Key<PostShard> postShardKey = postShardService.getRandomShardKey(postKey); PostShard shard = ofy().load().key(postShardKey).now(); shard.getBookmarkKeys().add(saved.getKey()); ofy().save().entities(saved, shard); }  }
BookmarkController extends Controller { public void insertBookmark(String postId, User user) { final Key<Account> authKey = Key.create(user.getUserId()); final Key<PostEntity> postKey = Key.create(postId); Bookmark saved = createBookmark(postKey, authKey); final Key<PostShard> postShardKey = postShardService.getRandomShardKey(postKey); PostShard shard = ofy().load().key(postShardKey).now(); shard.getBookmarkKeys().add(saved.getKey()); ofy().save().entities(saved, shard); }  void insertBookmark(String postId, User user); void deleteBookmark(String postId, User user); CollectionResponse<PostEntity> listBookmarks(Optional<Integer> limit,
      Optional<String> cursor, User user); }
BookmarkController extends Controller { public void insertBookmark(String postId, User user) { final Key<Account> authKey = Key.create(user.getUserId()); final Key<PostEntity> postKey = Key.create(postId); Bookmark saved = createBookmark(postKey, authKey); final Key<PostShard> postShardKey = postShardService.getRandomShardKey(postKey); PostShard shard = ofy().load().key(postShardKey).now(); shard.getBookmarkKeys().add(saved.getKey()); ofy().save().entities(saved, shard); }  void insertBookmark(String postId, User user); void deleteBookmark(String postId, User user); CollectionResponse<PostEntity> listBookmarks(Optional<Integer> limit,
      Optional<String> cursor, User user);  }