@Test void countRatings() throws Exception { UserReference userReference = mock(UserReference.class); EntityReference reference = new EntityReference("toto", EntityType.BLOCK); Map<RatingQueryField, Object> queryParameters = new LinkedHashMap<>(); queryParameters.put(RatingQueryField.ENTITY_REFERENCE, reference); queryParameters.put(RatingQueryField.USER_REFERENCE, userReference); queryParameters.put(RatingQueryField.SCALE, 12); String managerId = "managerTest"; this.manager.setIdentifer(managerId); when(this.configuration.hasDedicatedCore()).thenReturn(true); when(this.solr.getClient(managerId)).thenReturn(this.solrClient); when(this.entityReferenceSerializer.serialize(reference)).thenReturn("block:toto"); when(this.userReferenceSerializer.serialize(userReference)).thenReturn("user:Foobar"); String query = "filter(reference:block\\:toto) AND filter(author:user\\:Foobar) " + "AND filter(scale:12) AND filter(managerId:managerTest)"; SolrQuery expectedQuery = new SolrQuery().addFilterQuery(query).setStart(0).setRows(0); QueryResponse response = prepareSolrClientQueryWhenStatement(this.solrClient, expectedQuery); when(response.getResults()).thenReturn(this.documentList); when(this.documentList.getNumFound()).thenReturn(455L); assertEquals(455L, this.manager.countRatings(queryParameters)); }
@Override public long countRatings(Map<RatingQueryField, Object> queryParameters) throws RatingsException { SolrQuery solrQuery = new SolrQuery() .addFilterQuery(this.mapToQuery(queryParameters)) .setStart(0) .setRows(0); try { QueryResponse query = this.getRatingSolrClient().query(solrQuery); return query.getResults().getNumFound(); } catch (SolrServerException | IOException | SolrException e) { throw new RatingsException("Error while trying to get count of rankings", e); } }
SolrRatingsManager implements RatingsManager { @Override public long countRatings(Map<RatingQueryField, Object> queryParameters) throws RatingsException { SolrQuery solrQuery = new SolrQuery() .addFilterQuery(this.mapToQuery(queryParameters)) .setStart(0) .setRows(0); try { QueryResponse query = this.getRatingSolrClient().query(solrQuery); return query.getResults().getNumFound(); } catch (SolrServerException | IOException | SolrException e) { throw new RatingsException("Error while trying to get count of rankings", e); } } }
SolrRatingsManager implements RatingsManager { @Override public long countRatings(Map<RatingQueryField, Object> queryParameters) throws RatingsException { SolrQuery solrQuery = new SolrQuery() .addFilterQuery(this.mapToQuery(queryParameters)) .setStart(0) .setRows(0); try { QueryResponse query = this.getRatingSolrClient().query(solrQuery); return query.getResults().getNumFound(); } catch (SolrServerException | IOException | SolrException e) { throw new RatingsException("Error while trying to get count of rankings", e); } }  }
SolrRatingsManager implements RatingsManager { @Override public long countRatings(Map<RatingQueryField, Object> queryParameters) throws RatingsException { SolrQuery solrQuery = new SolrQuery() .addFilterQuery(this.mapToQuery(queryParameters)) .setStart(0) .setRows(0); try { QueryResponse query = this.getRatingSolrClient().query(solrQuery); return query.getResults().getNumFound(); } catch (SolrServerException | IOException | SolrException e) { throw new RatingsException("Error while trying to get count of rankings", e); } }  @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 long countRatings(Map<RatingQueryField, Object> queryParameters) throws RatingsException { SolrQuery solrQuery = new SolrQuery() .addFilterQuery(this.mapToQuery(queryParameters)) .setStart(0) .setRows(0); try { QueryResponse query = this.getRatingSolrClient().query(solrQuery); return query.getResults().getNumFound(); } catch (SolrServerException | IOException | SolrException e) { throw new RatingsException("Error while trying to get count of rankings", e); } }  @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);  }