@Test void sendNotification() { DocumentReference authorReference = new DocumentReference("xwiki", "XWiki", "Author"); DocumentReference documentReference = new DocumentReference("xwiki", "XWiki", "Doc"); DocumentReference mentionedIdentity = new DocumentReference("xwiki", "XWiki", "U2"); Set<String> eventTarget = Collections.singleton("xwiki:XWiki.U2"); when(this.serializer.serialize(mentionedIdentity)).thenReturn("xwiki:XWiki.U2"); when(this.serializer.serialize(authorReference)).thenReturn("xwiki:XWiki.Author"); when(this.serializer.serialize(documentReference)).thenReturn("xwiki:XWiki.Doc"); MentionNotificationParameters anchor = new MentionNotificationParameters(authorReference, documentReference, mentionedIdentity, MentionLocation.COMMENT, "anchor", new XDOM(emptyList())); this.notificationService.sendNotification(anchor); MentionEvent event = new MentionEvent(eventTarget, new MentionEventParams() .setUserReference("xwiki:XWiki.Author") .setDocumentReference("xwiki:XWiki.Doc") .setLocation(MentionLocation.COMMENT) .setAnchor("anchor") ); verify(this.observationManager) .notify(event, "org.xwiki.contrib:mentions-notifications", MentionEvent.EVENT_TYPE); }
@Override public void sendNotification(MentionNotificationParameters mentionNotificationParameters) { String extractedQuote; if (this.configuration.isQuoteActivated()) { extractedQuote = this.quote.extract(mentionNotificationParameters.getXdom(), mentionNotificationParameters.getAnchorId()).orElse(null); } else { extractedQuote = null; } MentionEventParams params = new MentionEventParams() .setUserReference(this.serializer.serialize( mentionNotificationParameters.getAuthorReference())) .setDocumentReference(this.serializer.serialize( mentionNotificationParameters.getDocumentReference())) .setLocation(mentionNotificationParameters.getLocation()) .setAnchor(mentionNotificationParameters.getAnchorId()) .setQuote(extractedQuote); MentionEvent event = new MentionEvent( Collections.singleton(this.serializer.serialize(mentionNotificationParameters.getMentionedIdentity())), params); this.observationManager.notify(event, "org.xwiki.contrib:mentions-notifications", MentionEvent.EVENT_TYPE); }
DefaultMentionNotificationService implements MentionNotificationService { @Override public void sendNotification(MentionNotificationParameters mentionNotificationParameters) { String extractedQuote; if (this.configuration.isQuoteActivated()) { extractedQuote = this.quote.extract(mentionNotificationParameters.getXdom(), mentionNotificationParameters.getAnchorId()).orElse(null); } else { extractedQuote = null; } MentionEventParams params = new MentionEventParams() .setUserReference(this.serializer.serialize( mentionNotificationParameters.getAuthorReference())) .setDocumentReference(this.serializer.serialize( mentionNotificationParameters.getDocumentReference())) .setLocation(mentionNotificationParameters.getLocation()) .setAnchor(mentionNotificationParameters.getAnchorId()) .setQuote(extractedQuote); MentionEvent event = new MentionEvent( Collections.singleton(this.serializer.serialize(mentionNotificationParameters.getMentionedIdentity())), params); this.observationManager.notify(event, "org.xwiki.contrib:mentions-notifications", MentionEvent.EVENT_TYPE); } }
DefaultMentionNotificationService implements MentionNotificationService { @Override public void sendNotification(MentionNotificationParameters mentionNotificationParameters) { String extractedQuote; if (this.configuration.isQuoteActivated()) { extractedQuote = this.quote.extract(mentionNotificationParameters.getXdom(), mentionNotificationParameters.getAnchorId()).orElse(null); } else { extractedQuote = null; } MentionEventParams params = new MentionEventParams() .setUserReference(this.serializer.serialize( mentionNotificationParameters.getAuthorReference())) .setDocumentReference(this.serializer.serialize( mentionNotificationParameters.getDocumentReference())) .setLocation(mentionNotificationParameters.getLocation()) .setAnchor(mentionNotificationParameters.getAnchorId()) .setQuote(extractedQuote); MentionEvent event = new MentionEvent( Collections.singleton(this.serializer.serialize(mentionNotificationParameters.getMentionedIdentity())), params); this.observationManager.notify(event, "org.xwiki.contrib:mentions-notifications", MentionEvent.EVENT_TYPE); }  }
DefaultMentionNotificationService implements MentionNotificationService { @Override public void sendNotification(MentionNotificationParameters mentionNotificationParameters) { String extractedQuote; if (this.configuration.isQuoteActivated()) { extractedQuote = this.quote.extract(mentionNotificationParameters.getXdom(), mentionNotificationParameters.getAnchorId()).orElse(null); } else { extractedQuote = null; } MentionEventParams params = new MentionEventParams() .setUserReference(this.serializer.serialize( mentionNotificationParameters.getAuthorReference())) .setDocumentReference(this.serializer.serialize( mentionNotificationParameters.getDocumentReference())) .setLocation(mentionNotificationParameters.getLocation()) .setAnchor(mentionNotificationParameters.getAnchorId()) .setQuote(extractedQuote); MentionEvent event = new MentionEvent( Collections.singleton(this.serializer.serialize(mentionNotificationParameters.getMentionedIdentity())), params); this.observationManager.notify(event, "org.xwiki.contrib:mentions-notifications", MentionEvent.EVENT_TYPE); }  @Override void sendNotification(MentionNotificationParameters mentionNotificationParameters); }
DefaultMentionNotificationService implements MentionNotificationService { @Override public void sendNotification(MentionNotificationParameters mentionNotificationParameters) { String extractedQuote; if (this.configuration.isQuoteActivated()) { extractedQuote = this.quote.extract(mentionNotificationParameters.getXdom(), mentionNotificationParameters.getAnchorId()).orElse(null); } else { extractedQuote = null; } MentionEventParams params = new MentionEventParams() .setUserReference(this.serializer.serialize( mentionNotificationParameters.getAuthorReference())) .setDocumentReference(this.serializer.serialize( mentionNotificationParameters.getDocumentReference())) .setLocation(mentionNotificationParameters.getLocation()) .setAnchor(mentionNotificationParameters.getAnchorId()) .setQuote(extractedQuote); MentionEvent event = new MentionEvent( Collections.singleton(this.serializer.serialize(mentionNotificationParameters.getMentionedIdentity())), params); this.observationManager.notify(event, "org.xwiki.contrib:mentions-notifications", MentionEvent.EVENT_TYPE); }  @Override void sendNotification(MentionNotificationParameters mentionNotificationParameters);  }