@Test void getAverageRating() throws Exception { String managerId = "averageId2"; this.manager.setIdentifer(managerId); EntityReference reference = new EntityReference("xwiki:Something", EntityType.PAGE); AverageRating expectedAverageRating = new DefaultAverageRating("average1") .setAverageVote(2.341f) .setTotalVote(242) .setUpdatedAt(new Date(42)) .setManagerId(managerId) .setScaleUpperBound(12) .setReference(reference); when(this.averageRatingManager.getAverageRating(reference)).thenReturn(expectedAverageRating); when(this.configuration.isAverageStored()).thenReturn(true); AverageRating averageRating = this.manager.getAverageRating(reference); assertEquals(expectedAverageRating, averageRating); }
@Override public AverageRating getAverageRating(EntityReference entityReference) throws RatingsException { if (this.getRatingConfiguration().isAverageStored()) { return this.getAverageRatingManager().getAverageRating(entityReference); } else { throw new RatingsException(AVERAGE_RATING_NOT_ENABLED_ERROR_MESSAGE); } }
SolrRatingsManager implements RatingsManager { @Override public AverageRating getAverageRating(EntityReference entityReference) throws RatingsException { if (this.getRatingConfiguration().isAverageStored()) { return this.getAverageRatingManager().getAverageRating(entityReference); } else { throw new RatingsException(AVERAGE_RATING_NOT_ENABLED_ERROR_MESSAGE); } } }
SolrRatingsManager implements RatingsManager { @Override public AverageRating getAverageRating(EntityReference entityReference) throws RatingsException { if (this.getRatingConfiguration().isAverageStored()) { return this.getAverageRatingManager().getAverageRating(entityReference); } else { throw new RatingsException(AVERAGE_RATING_NOT_ENABLED_ERROR_MESSAGE); } }  }
SolrRatingsManager implements RatingsManager { @Override public AverageRating getAverageRating(EntityReference entityReference) throws RatingsException { if (this.getRatingConfiguration().isAverageStored()) { return this.getAverageRatingManager().getAverageRating(entityReference); } else { throw new RatingsException(AVERAGE_RATING_NOT_ENABLED_ERROR_MESSAGE); } }  @Override String getIdentifier(); @Override void setIdentifer(String identifier); @Override int getScale(); @Override void setRatingConfiguration(RatingsConfiguration configuration); @Override RatingsConfiguration getRatingConfiguration(); @Override Rating saveRating(EntityReference reference, UserReference user, int vote); @Override List<Rating> getRatings(Map<RatingQueryField, Object> queryParameters, int offset, int limit,
        RatingQueryField orderBy, boolean asc); @Override long countRatings(Map<RatingQueryField, Object> queryParameters); @Override boolean removeRating(String ratingIdentifier); @Override AverageRating getAverageRating(EntityReference entityReference); @Override void saveRating(Rating rating); @Override AverageRating recomputeAverageRating(EntityReference entityReference); }
SolrRatingsManager implements RatingsManager { @Override public AverageRating getAverageRating(EntityReference entityReference) throws RatingsException { if (this.getRatingConfiguration().isAverageStored()) { return this.getAverageRatingManager().getAverageRating(entityReference); } else { throw new RatingsException(AVERAGE_RATING_NOT_ENABLED_ERROR_MESSAGE); } }  @Override String getIdentifier(); @Override void setIdentifer(String identifier); @Override int getScale(); @Override void setRatingConfiguration(RatingsConfiguration configuration); @Override RatingsConfiguration getRatingConfiguration(); @Override Rating saveRating(EntityReference reference, UserReference user, int vote); @Override List<Rating> getRatings(Map<RatingQueryField, Object> queryParameters, int offset, int limit,
        RatingQueryField orderBy, boolean asc); @Override long countRatings(Map<RatingQueryField, Object> queryParameters); @Override boolean removeRating(String ratingIdentifier); @Override AverageRating getAverageRating(EntityReference entityReference); @Override void saveRating(Rating rating); @Override AverageRating recomputeAverageRating(EntityReference entityReference);  }