### Question:
DefaultLikeManager implements LikeManager, Initializable, Disposable { @Override public boolean isLiked(UserReference source, EntityReference target) throws LikeException { Boolean result = this.likeExistCache.get(getExistCacheKey(source, 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); queryMap.put(RatingsManager.RatingQueryField.USER_REFERENCE, source); try { List<Rating> gradings = this.ratingsManager .getRatings(queryMap, 0, 1, RatingsManager.RatingQueryField.UPDATED_DATE, false); result = !gradings.isEmpty(); this.likeExistCache.set(getExistCacheKey(source, target), result); } catch (RatingsException e) { throw new LikeException("Error while checking if grading exists", 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();  }### Answer:
@Test void isLiked() throws Exception { assertFalse(this.defaultLikeManager.isLiked(this.userReference, target)); Map<RatingsManager.RatingQueryField, Object> queryMap = new LinkedHashMap<>(); queryMap.put(RatingsManager.RatingQueryField.ENTITY_TYPE, target.getType()); queryMap.put(RatingsManager.RatingQueryField.ENTITY_REFERENCE, target); queryMap.put(RatingsManager.RatingQueryField.USER_REFERENCE, this.userReference); when(this.ratingsManager.getRatings(queryMap, 0, 1, RatingsManager.RatingQueryField.UPDATED_DATE, false)). thenReturn(Collections.singletonList(mock(Rating.class))); assertTrue(this.defaultLikeManager.isLiked(this.userReference, target)); verify(this.likeExistCache).set("xwiki:XWiki.User_xwiki:Foo.WebHome", true); }