/** * Gets the total (sum) rating by all users on the specified node in the specified scheme. * @param node ScriptNode * @param ratingSchemeName String * @return float */ public float getTotalRating(ScriptNode node, String ratingSchemeName) { return ratingService.getTotalRating(node.getNodeRef(), ratingSchemeName); }
/** * Gets the total (sum) rating by all users on the specified node in the specified scheme. * @param node ScriptNode * @param ratingSchemeName String * @return float */ public float getTotalRating(ScriptNode node, String ratingSchemeName) { return ratingService.getTotalRating(node.getNodeRef(), ratingSchemeName); }
public Void execute() throws Throwable { RATING_SERVICE.applyRating(testDoc_Admin, 1.0f, FIVE_STAR_SCHEME_NAME); // A new score in the same rating scheme by the same user should replace the previous score. RATING_SERVICE.applyRating(testDoc_Admin, 2.0f, FIVE_STAR_SCHEME_NAME); float meanRating = RATING_SERVICE.getAverageRating(testDoc_Admin, FIVE_STAR_SCHEME_NAME); assertEquals("Document had wrong mean rating.", 2, (int)meanRating); float totalRating = RATING_SERVICE.getTotalRating(testDoc_Admin, FIVE_STAR_SCHEME_NAME); assertEquals("Document had wrong total rating.", 2, (int)totalRating); int ratingsCount = RATING_SERVICE.getRatingsCount(testDoc_Admin, FIVE_STAR_SCHEME_NAME); assertEquals("Document had wrong ratings count.", 1, ratingsCount); // There should only be one rating child node under the rated node. assertEquals("Wrong number of child nodes", 1 , NODE_SERVICE.getChildAssocs(testDoc_Admin).size()); return null; } });
assertEquals("Document had wrong mean rating.", 3, (int)meanRating); float totalRating = RATING_SERVICE.getTotalRating(testDoc_Admin, FIVE_STAR_SCHEME_NAME); assertEquals("Document had wrong total rating.", 6, (int)totalRating); assertEquals("Document had wrong mean rating.", 4, (int)meanRating); totalRating = RATING_SERVICE.getTotalRating(testDoc_Admin, FIVE_STAR_SCHEME_NAME); assertEquals("Document had wrong total rating.", 4, (int)totalRating);