@Test void getLikers() throws Exception { Rating grading1 = mock(Rating.class); UserReference userReference1 = mock(UserReference.class); when(grading1.getAuthor()).thenReturn(userReference1); Rating grading2 = mock(Rating.class); UserReference userReference2 = mock(UserReference.class); when(grading2.getAuthor()).thenReturn(userReference2); Rating grading3 = mock(Rating.class); UserReference userReference3 = mock(UserReference.class); when(grading3.getAuthor()).thenReturn(userReference3); 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.getRatings(queryMap, 12, 4, RatingsManager.RatingQueryField.UPDATED_DATE, false)) .thenReturn(Arrays.asList(grading1, grading2, grading3)); assertEquals(Arrays.asList(userReference1, userReference2, userReference3), this.defaultLikeManager.getLikers(this.target, 12, 4)); }
@Override public List<UserReference> getLikers(EntityReference target, int offset, int limit) throws LikeException { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { List<Rating> gradings = this.ratingsManager .getRatings(queryMap, offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getAuthor).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting likers of [%s]", target), e); } }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public List<UserReference> getLikers(EntityReference target, int offset, int limit) throws LikeException { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { List<Rating> gradings = this.ratingsManager .getRatings(queryMap, offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getAuthor).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting likers of [%s]", target), e); } } }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public List<UserReference> getLikers(EntityReference target, int offset, int limit) throws LikeException { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { List<Rating> gradings = this.ratingsManager .getRatings(queryMap, offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getAuthor).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting likers of [%s]", target), e); } }  }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public List<UserReference> getLikers(EntityReference target, int offset, int limit) throws LikeException { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { List<Rating> gradings = this.ratingsManager .getRatings(queryMap, offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getAuthor).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting likers of [%s]", target), e); } }  @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 List<UserReference> getLikers(EntityReference target, int offset, int limit) throws LikeException { Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); try { List<Rating> gradings = this.ratingsManager .getRatings(queryMap, offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getAuthor).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException(String.format("Error while getting likers of [%s]", target), e); } }  @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();  }