@Test void groupAnchorsByUserReferenceThree() { Map<DocumentReference, List<String>> actual = this.xdomService.groupAnchorsByUserReference(asList( initMentionMacro("A", "A1"), initMentionMacro("B", "B1"), initMentionMacro("A", "A2") ), new WikiReference("xwiki")); Map<DocumentReference, List<String>> expected = new HashMap<>(); expected.put(this.documentReferenceB, Collections.singletonList("B1")); expected.put(this.documentReferenceA, Arrays.asList("A1", "A2")); assertEquals(expected, actual); }
@Override public Map<DocumentReference, List<String>> groupAnchorsByUserReference(List<MacroBlock> mentions, WikiReference wikiReference) { Map<DocumentReference, List<String>> ret = new HashMap<>(); for (MacroBlock block : mentions) { String serializedUserReference = block.getParameter(REFERENCE_PARAM_NAME); DocumentReference reference = this.documentReferenceResolver.resolve(serializedUserReference, wikiReference); String anchor = block.getParameter(ANCHORID_PARAM_NAME); ret.merge(reference, new ArrayList<>(Collections.singletonList(anchor)), (l1, l2) -> { l1.addAll(l2); return l1; }); } return ret; }
DefaultMentionXDOMService implements MentionXDOMService { @Override public Map<DocumentReference, List<String>> groupAnchorsByUserReference(List<MacroBlock> mentions, WikiReference wikiReference) { Map<DocumentReference, List<String>> ret = new HashMap<>(); for (MacroBlock block : mentions) { String serializedUserReference = block.getParameter(REFERENCE_PARAM_NAME); DocumentReference reference = this.documentReferenceResolver.resolve(serializedUserReference, wikiReference); String anchor = block.getParameter(ANCHORID_PARAM_NAME); ret.merge(reference, new ArrayList<>(Collections.singletonList(anchor)), (l1, l2) -> { l1.addAll(l2); return l1; }); } return ret; } }
DefaultMentionXDOMService implements MentionXDOMService { @Override public Map<DocumentReference, List<String>> groupAnchorsByUserReference(List<MacroBlock> mentions, WikiReference wikiReference) { Map<DocumentReference, List<String>> ret = new HashMap<>(); for (MacroBlock block : mentions) { String serializedUserReference = block.getParameter(REFERENCE_PARAM_NAME); DocumentReference reference = this.documentReferenceResolver.resolve(serializedUserReference, wikiReference); String anchor = block.getParameter(ANCHORID_PARAM_NAME); ret.merge(reference, new ArrayList<>(Collections.singletonList(anchor)), (l1, l2) -> { l1.addAll(l2); return l1; }); } return ret; }  }
DefaultMentionXDOMService implements MentionXDOMService { @Override public Map<DocumentReference, List<String>> groupAnchorsByUserReference(List<MacroBlock> mentions, WikiReference wikiReference) { Map<DocumentReference, List<String>> ret = new HashMap<>(); for (MacroBlock block : mentions) { String serializedUserReference = block.getParameter(REFERENCE_PARAM_NAME); DocumentReference reference = this.documentReferenceResolver.resolve(serializedUserReference, wikiReference); String anchor = block.getParameter(ANCHORID_PARAM_NAME); ret.merge(reference, new ArrayList<>(Collections.singletonList(anchor)), (l1, l2) -> { l1.addAll(l2); return l1; }); } return ret; }  @Override List<MacroBlock> listMentionMacros(XDOM xdom); @Override Map<DocumentReference, List<String>> groupAnchorsByUserReference(List<MacroBlock> mentions,
        WikiReference wikiReference); @Override Optional<XDOM> parse(String payload, Syntax syntax); }
DefaultMentionXDOMService implements MentionXDOMService { @Override public Map<DocumentReference, List<String>> groupAnchorsByUserReference(List<MacroBlock> mentions, WikiReference wikiReference) { Map<DocumentReference, List<String>> ret = new HashMap<>(); for (MacroBlock block : mentions) { String serializedUserReference = block.getParameter(REFERENCE_PARAM_NAME); DocumentReference reference = this.documentReferenceResolver.resolve(serializedUserReference, wikiReference); String anchor = block.getParameter(ANCHORID_PARAM_NAME); ret.merge(reference, new ArrayList<>(Collections.singletonList(anchor)), (l1, l2) -> { l1.addAll(l2); return l1; }); } return ret; }  @Override List<MacroBlock> listMentionMacros(XDOM xdom); @Override Map<DocumentReference, List<String>> groupAnchorsByUserReference(List<MacroBlock> mentions,
        WikiReference wikiReference); @Override Optional<XDOM> parse(String payload, Syntax syntax);  }