コード例 #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()));
   }
 }