@Test void getEntityLikes() throws Exception { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); when(this.ratingsManager.countRatings(queryMap)).thenReturn(43L); assertEquals(43L, this.defaultLikeManager.getEntityLikes(target)); verify(this.likedEntityCache).set("xwiki:Foo.WebHome", 43L); }
@Override public long getEntityLikes(EntityReference target) throws LikeException { Long result = this.likeCountCache.get(this.entityReferenceSerializer.serialize(target)); if (result == null) { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { result = this.ratingsManager.countRatings(queryMap); this.likeCountCache.set(this.entityReferenceSerializer.serialize(target), result); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting ratings for entity [%s]", target), e); } } return result; }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public long getEntityLikes(EntityReference target) throws LikeException { Long result = this.likeCountCache.get(this.entityReferenceSerializer.serialize(target)); if (result == null) { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { result = this.ratingsManager.countRatings(queryMap); this.likeCountCache.set(this.entityReferenceSerializer.serialize(target), result); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting ratings for entity [%s]", target), e); } } return result; } }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public long getEntityLikes(EntityReference target) throws LikeException { Long result = this.likeCountCache.get(this.entityReferenceSerializer.serialize(target)); if (result == null) { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { result = this.ratingsManager.countRatings(queryMap); this.likeCountCache.set(this.entityReferenceSerializer.serialize(target), result); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting ratings for entity [%s]", target), e); } } return result; }  }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public long getEntityLikes(EntityReference target) throws LikeException { Long result = this.likeCountCache.get(this.entityReferenceSerializer.serialize(target)); if (result == null) { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { result = this.ratingsManager.countRatings(queryMap); this.likeCountCache.set(this.entityReferenceSerializer.serialize(target), result); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting ratings for entity [%s]", target), e); } } return result; }  @Override void initialize(); @Override void dispose(); @Override long saveLike(UserReference source, EntityReference target); @Override List<EntityReference> getUserLikes(UserReference source, int offset, int limit); @Override long getEntityLikes(EntityReference target); @Override boolean removeLike(UserReference source, EntityReference target); @Override boolean isLiked(UserReference source, EntityReference target); @Override List<UserReference> getLikers(EntityReference target, int offset, int limit); @Override Right getLikeRight(); }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public long getEntityLikes(EntityReference target) throws LikeException { Long result = this.likeCountCache.get(this.entityReferenceSerializer.serialize(target)); if (result == null) { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { result = this.ratingsManager.countRatings(queryMap); this.likeCountCache.set(this.entityReferenceSerializer.serialize(target), result); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting ratings for entity [%s]", target), e); } } return result; }  @Override void initialize(); @Override void dispose(); @Override long saveLike(UserReference source, EntityReference target); @Override List<EntityReference> getUserLikes(UserReference source, int offset, int limit); @Override long getEntityLikes(EntityReference target); @Override boolean removeLike(UserReference source, EntityReference target); @Override boolean isLiked(UserReference source, EntityReference target); @Override List<UserReference> getLikers(EntityReference target, int offset, int limit); @Override Right getLikeRight();  }