@Override public Void doWork() throws Exception { ratingService.applyRating(targetNode, rating, ratingSchemeName); return null; }
@Override public NodeRef execute() throws Throwable { RATING_SERVICE.applyRating(testDoc_UserOne, 11.0F, spinalTapScheme); return null; } });
@Override public Void execute() throws Throwable { RATING_SERVICE.applyRating(nodeRef, illegalRating, schemeName); return null; } });
/** * Applies the given rating to the specified node using the specified ratingScheme. * It is the responsibility of the caller to ensure that the rating scheme exists * and that the rating is within the limits defined for that scheme. * <p/>Furthermore, only one rating scheme per user per target node is supported. Any attempt * by one user to apply a second rating in a different scheme will result in a {@link RatingServiceException}. * * @param node ScriptNode * @param rating float * @param ratingSchemeName String * @throws RatingServiceException * @see ScriptRatingService#getMin(String) * @see ScriptRatingService#getMax(String) */ public void applyRating(ScriptNode node, float rating, String ratingSchemeName) { ratingService.applyRating(node.getNodeRef(), rating, ratingSchemeName); }
/** * Applies the given rating to the specified node using the specified ratingScheme. * It is the responsibility of the caller to ensure that the rating scheme exists * and that the rating is within the limits defined for that scheme. * <p/>Furthermore, only one rating scheme per user per target node is supported. Any attempt * by one user to apply a second rating in a different scheme will result in a {@link RatingServiceException}. * * @param node ScriptNode * @param rating float * @param ratingSchemeName String * @throws RatingServiceException * @see ScriptRatingService#getMin(String) * @see ScriptRatingService#getMax(String) */ public void applyRating(ScriptNode node, float rating, String ratingSchemeName) { ratingService.applyRating(node.getNodeRef(), rating, ratingSchemeName); }
public Void execute() throws Throwable { // In the likes rating scheme, users can rate their own content. RATING_SERVICE.applyRating(testDoc_UserOne, 1, LIKES_SCHEME_NAME); // But fiveStar rating scheme disallows rating your own content. boolean expectedExceptionThrown = false; try { RATING_SERVICE.applyRating(testDoc_UserOne, 4, FIVE_STAR_SCHEME_NAME); } catch (RatingServiceException expected) { expectedExceptionThrown = true; } assertTrue(expectedExceptionThrown); return null; } });
public Void execute() throws Throwable { RATING_SERVICE.applyRating(testDoc_UserTwo, 2.0f, FIVE_STAR_SCHEME_NAME); // A new score in a different rating scheme by the same user should not fail. RATING_SERVICE.applyRating(testDoc_UserTwo, 1.0f, LIKES_SCHEME_NAME); // There should be two rating child nodes under the rated node. assertEquals("Wrong number of child nodes", 2 , NODE_SERVICE.getChildAssocs(testDoc_UserTwo).size()); List<Rating> ratings = RATING_SERVICE.getRatingsByCurrentUser(testDoc_UserTwo); assertEquals(2, ratings.size()); assertEquals(FIVE_STAR_SCHEME_NAME, ratings.get(0).getScheme().getName()); assertEquals(LIKES_SCHEME_NAME, ratings.get(1).getScheme().getName()); return null; } });
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; } });
@Override public NodeRef execute() throws Throwable { // Create a new folder to copy the rated node to. NodeRef testFolder = testNodes.createNode(COMPANY_HOME, "copyTarget", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName()); // Ensure the test document is not rated initially. assertNull(RATING_SERVICE.getRatingByCurrentUser(testDoc_Admin, LIKES_SCHEME_NAME)); // Apply a rating to the test document. RATING_SERVICE.applyRating(testDoc_Admin, 1, LIKES_SCHEME_NAME); return testFolder; } });
ratingService.applyRating(nodeRef1, getFiveStarRating(), "fiveStarRatingScheme"); ratingService.applyRating(nodeRef2, getFiveStarRating(), "fiveStarRatingScheme"); ratingService.applyRating(nodeRef3, getFiveStarRating(), "fiveStarRatingScheme"); ratingService.applyRating(nodeRef4, getFiveStarRating(), "fiveStarRatingScheme"); ratingService.applyRating(nodeRef5, getFiveStarRating(), "fiveStarRatingScheme"); ratingService.applyRating(nodeRef6, 1.0f, "likesRatingScheme"); ratingService.applyRating(nodeRef7, 1.0f, "likesRatingScheme"); ratingService.applyRating(nodeRef8, 1.0f, "likesRatingScheme"); ratingService.applyRating(nodeRef9, 1.0f, "likesRatingScheme"); ratingService.applyRating(nodeRef10, 1.0f, "likesRatingScheme");
RATING_SERVICE.applyRating(testDoc_UserTwo, 2.0f, FIVE_STAR_SCHEME_NAME); RATING_SERVICE.applyRating(testDoc_UserTwo, 1.0f, LIKES_SCHEME_NAME);
RATING_SERVICE.applyRating(testDoc_Admin, 4.0f, FIVE_STAR_SCHEME_NAME); assertModifierIs(testDoc_Admin, AuthenticationUtil.getAdminUserName()); RATING_SERVICE.applyRating(testDoc_Admin, 2.0f, FIVE_STAR_SCHEME_NAME); assertModifierIs(testDoc_Admin, AuthenticationUtil.getAdminUserName());
RATING_SERVICE.applyRating(testDoc_Admin, fiveStarScore, FIVE_STAR_SCHEME_NAME); assertModifierIs(testDoc_Admin, AuthenticationUtil.getAdminUserName()); RATING_SERVICE.applyRating(testDoc_Admin, updatedFiveStarScore, FIVE_STAR_SCHEME_NAME); assertModifierIs(testDoc_Admin, AuthenticationUtil.getAdminUserName());