}
public void testCRUDRating() {
if (service == null) return;
// add comments
UserRatingsManager urm = service.getUserRatingsManager();
UserRatingsManager urm2 = serviceWithSubPath.getUserRatingsManager();
assertEquals(Float.valueOf(0), urm.calculateRatingAverage());
assertEquals(Float.valueOf(0), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(0), urm.countRatings());
assertEquals(Long.valueOf(0), urm2.countRatings());
UserRating r1 = urm.createRating(ident1, 2);
UserRating r2 = urm2.createRating(ident1, 2);
assertEquals(Float.valueOf(2), urm.calculateRatingAverage());
assertEquals(Float.valueOf(2), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(1), urm.countRatings());
assertEquals(Long.valueOf(1), urm2.countRatings());
//
UserRating r3 = urm.createRating(ident2, 4);
UserRating r4 = urm2.createRating(ident2, 4);
assertEquals(Float.valueOf(3), urm.calculateRatingAverage());
assertEquals(Float.valueOf(3), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(2), urm.countRatings());
assertEquals(Long.valueOf(2), urm2.countRatings());
//
UserRating r5 = urm.createRating(ident3, 1);
UserRating r6 = urm2.createRating(ident3, 1);
assertEquals(Float.valueOf(2.5f), urm.calculateRatingAverage());
assertEquals(Float.valueOf(2.5f), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(3), urm.countRatings());
assertEquals(Long.valueOf(3), urm2.countRatings());
//
assertNotNull(urm.getRating(ident1));
assertNotNull(urm.getRating(ident2));
assertNotNull(urm.getRating(ident3));
// can not create two ratings per person
r1 = urm.createRating(ident1, 2);
r2 = urm2.createRating(ident1, 2);
assertEquals(Float.valueOf(2.5f), urm.calculateRatingAverage());
assertEquals(Float.valueOf(2.5f), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(3), urm.countRatings());
assertEquals(Long.valueOf(3), urm2.countRatings());
// Delete
urm.deleteAllRatings();
assertEquals(Float.valueOf(0), urm.calculateRatingAverage());
assertEquals(Float.valueOf(2.5f), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(0), urm.countRatings());
assertEquals(Long.valueOf(3), urm2.countRatings());
// Recreate and delete ignoring subpath
r1 = urm.createRating(ident1, 2);
r2 = urm2.createRating(ident1, 2);
assertEquals(Float.valueOf(2), urm.calculateRatingAverage());
assertEquals(Float.valueOf(2.5f), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(1), urm.countRatings());
assertEquals(Long.valueOf(3), urm2.countRatings());
urm.deleteAllRatingsIgnoringSubPath();
assertEquals(Float.valueOf(0), urm.calculateRatingAverage());
assertEquals(Float.valueOf(0), urm2.calculateRatingAverage());
assertEquals(Long.valueOf(0), urm.countRatings());
assertEquals(Long.valueOf(0), urm2.countRatings());
//
}