@Test void getLikesError() throws LikeException { EntityReference entityReference = new DocumentReference("xwiki", "Foo", "Foo"); when(this.likeManager.getEntityLikes(entityReference)).thenThrow(new LikeException("Problem")); assertFalse(this.likeScriptService.getLikes(entityReference).isPresent()); assertEquals("Error while getting like information for [xwiki:Foo.Foo]", logCapture.getMessage(0)); }
public Optional<Long> getLikes(EntityReference entityReference) { try { return Optional.of(this.likeManager.getEntityLikes(entityReference)); } catch (LikeException e) { this.logger.warn("Error while getting like information for [{}]", entityReference, ExceptionUtils.getRootCause(e)); } return Optional.empty(); }
LikeScriptService implements ScriptService { public Optional<Long> getLikes(EntityReference entityReference) { try { return Optional.of(this.likeManager.getEntityLikes(entityReference)); } catch (LikeException e) { this.logger.warn("Error while getting like information for [{}]", entityReference, ExceptionUtils.getRootCause(e)); } return Optional.empty(); } }
LikeScriptService implements ScriptService { public Optional<Long> getLikes(EntityReference entityReference) { try { return Optional.of(this.likeManager.getEntityLikes(entityReference)); } catch (LikeException e) { this.logger.warn("Error while getting like information for [{}]", entityReference, ExceptionUtils.getRootCause(e)); } return Optional.empty(); }  }
LikeScriptService implements ScriptService { public Optional<Long> getLikes(EntityReference entityReference) { try { return Optional.of(this.likeManager.getEntityLikes(entityReference)); } catch (LikeException e) { this.logger.warn("Error while getting like information for [{}]", entityReference, ExceptionUtils.getRootCause(e)); } return Optional.empty(); }  boolean isAuthorized(EntityReference entityReference); boolean displayButton(EntityReference entityReference); Optional<Long> like(EntityReference entityReference); Optional<Long> unlike(EntityReference entityReference); Optional<Long> getLikes(EntityReference entityReference); List<EntityReference> getUserLikes(UserReference userReference, int offset, int limit); boolean isLiked(EntityReference entityReference); @Unstable List<UserReference> getLikers(EntityReference target, int offset, int limit); void cleanCacheUIX(); }
LikeScriptService implements ScriptService { public Optional<Long> getLikes(EntityReference entityReference) { try { return Optional.of(this.likeManager.getEntityLikes(entityReference)); } catch (LikeException e) { this.logger.warn("Error while getting like information for [{}]", entityReference, ExceptionUtils.getRootCause(e)); } return Optional.empty(); }  boolean isAuthorized(EntityReference entityReference); boolean displayButton(EntityReference entityReference); Optional<Long> like(EntityReference entityReference); Optional<Long> unlike(EntityReference entityReference); Optional<Long> getLikes(EntityReference entityReference); List<EntityReference> getUserLikes(UserReference userReference, int offset, int limit); boolean isLiked(EntityReference entityReference); @Unstable List<UserReference> getLikers(EntityReference target, int offset, int limit); void cleanCacheUIX();  }