コード例 #1
0
 @Test
 public void testCustomerReviewService() {
   Assert.assertEquals(
       "no rating",
       0,
       customerReviewService.getNumberOfReviews(productModel01).doubleValue(),
       0.001);
   customerReviewService.createCustomerReview(
       Double.valueOf(1), "headline_anonymous", "comment_anonymous", userModel01, productModel01);
   Assert.assertEquals(
       "rating 1",
       1,
       customerReviewService.getNumberOfReviews(productModel01).doubleValue(),
       0.001);
   customerReviewService.createCustomerReview(
       Double.valueOf(2), "headline_admin", "comment_admin", userModel02, productModel01);
   Assert.assertEquals(
       "rating 2",
       2,
       customerReviewService.getNumberOfReviews(productModel01).doubleValue(),
       0.001);
   Assert.assertEquals(
       "average rating 1.5",
       1.5,
       customerReviewService.getAverageRating(productModel01).doubleValue(),
       0.001);
   final List<CustomerReviewModel> reviews = customerReviewService.getAllReviews(productModel01);
   final Set<String> comments = new TreeSet<String>();
   comments.add("comment_anonymous");
   comments.add("comment_admin");
   for (final CustomerReviewModel reviewModel : reviews) {
     Assert.assertTrue(comments.contains(reviewModel.getComment()));
   }
 }
コード例 #2
0
 private void createCustomerReview(
     final String headline,
     final UserModel user,
     final ProductModel product,
     final CustomerReviewApprovalType approvalStatus) {
   final CustomerReviewModel review =
       customerReviewService.createCustomerReview(
           Double.valueOf(3.0), headline, COMMENT, user, product);
   review.setApprovalStatus(approvalStatus);
   review.setLanguage(commonI18NService.getCurrentLanguage());
   modelService.save(review);
 }