@Test void getUserLikes() throws Exception { Rating grading1 = mock(Rating.class); EntityReference entityReference1 = mock(EntityReference.class); when(grading1.getReference()).thenReturn(entityReference1); Rating grading2 = mock(Rating.class); EntityReference entityReference2 = mock(EntityReference.class); when(grading2.getReference()).thenReturn(entityReference2); Rating grading3 = mock(Rating.class); EntityReference entityReference3 = mock(EntityReference.class); when(grading3.getReference()).thenReturn(entityReference3); when(this.ratingsManager.getRatings( Collections.singletonMap(RatingsManager.RatingQueryField.USER_REFERENCE, this.userReference), 5, 3, RatingsManager.RatingQueryField.UPDATED_DATE, false)).thenReturn(Arrays.asList(grading1, grading2, grading3)); assertEquals(Arrays.asList(entityReference1, entityReference2, entityReference3), this.defaultLikeManager.getUserLikes(this.userReference, 5, 3)); }
@Override public List<EntityReference> getUserLikes(UserReference source, int offset, int limit) throws LikeException { try { List<Rating> gradings = this.ratingsManager.getRatings( Collections.singletonMap(RatingsManager.RatingQueryField.USER_REFERENCE, source), offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getReference).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException( String.format("Error when trying to retrieve user likes for user [%s]", source), e); } }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public List<EntityReference> getUserLikes(UserReference source, int offset, int limit) throws LikeException { try { List<Rating> gradings = this.ratingsManager.getRatings( Collections.singletonMap(RatingsManager.RatingQueryField.USER_REFERENCE, source), offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getReference).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException( String.format("Error when trying to retrieve user likes for user [%s]", source), e); } } }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public List<EntityReference> getUserLikes(UserReference source, int offset, int limit) throws LikeException { try { List<Rating> gradings = this.ratingsManager.getRatings( Collections.singletonMap(RatingsManager.RatingQueryField.USER_REFERENCE, source), offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getReference).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException( String.format("Error when trying to retrieve user likes for user [%s]", source), e); } }  }
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public List<EntityReference> getUserLikes(UserReference source, int offset, int limit) throws LikeException { try { List<Rating> gradings = this.ratingsManager.getRatings( Collections.singletonMap(RatingsManager.RatingQueryField.USER_REFERENCE, source), offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getReference).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException( String.format("Error when trying to retrieve user likes for user [%s]", source), 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<EntityReference> getUserLikes(UserReference source, int offset, int limit) throws LikeException { try { List<Rating> gradings = this.ratingsManager.getRatings( Collections.singletonMap(RatingsManager.RatingQueryField.USER_REFERENCE, source), offset, limit, RatingsManager.RatingQueryField.UPDATED_DATE, false); return gradings.stream().map(Rating::getReference).collect(Collectors.toList()); } catch (RatingsException e) { throw new LikeException( String.format("Error when trying to retrieve user likes for user [%s]", source), 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();  }