public void testElementMatcherWithRestrictions() { String xml = "text <image attachment=\"nR_0YFT75\" style=\"full\">" + "<caption>good times</caption></image> hello"; ApiView apiView = createApiViewFromXml(xml); Map<String, String> restrictions = Maps.newHashMap(); assertEquals(1, countHits(new DocumentHitIterator.ElementMatcher( apiView, ElementType.ATTACHMENT, Collections.<String, String>emptyMap(), -1))); Restriction restriction = Attachment.restrictByAttachmentId("nR_0YFT75"); assertEquals(1, countHits(new DocumentHitIterator.ElementMatcher(apiView, ElementType.ATTACHMENT, ImmutableMap.of(restriction.getKey(), restriction.getValue()), -1))); restriction = Attachment.restrictByAttachmentId("nR_0YFT76"); assertEquals(0, countHits(new DocumentHitIterator.ElementMatcher(apiView, ElementType.ATTACHMENT, ImmutableMap.of(restriction.getKey(), restriction.getValue()), -1))); }
public void testElementMatcherWithRestrictions() { String xml = "text <image attachment=\"nR_0YFT75\" style=\"full\">" + "<caption>good times</caption></image> hello"; ApiView apiView = createApiViewFromXml(xml); Map<String, String> restrictions = Maps.newHashMap(); assertEquals(1, countHits(new DocumentHitIterator.ElementMatcher( apiView, ElementType.ATTACHMENT, Collections.<String, String>emptyMap(), -1))); Restriction restriction = Attachment.restrictByAttachmentId("nR_0YFT75"); assertEquals(1, countHits(new DocumentHitIterator.ElementMatcher(apiView, ElementType.ATTACHMENT, ImmutableMap.of(restriction.getKey(), restriction.getValue()), -1))); restriction = Attachment.restrictByAttachmentId("nR_0YFT76"); assertEquals(0, countHits(new DocumentHitIterator.ElementMatcher(apiView, ElementType.ATTACHMENT, ImmutableMap.of(restriction.getKey(), restriction.getValue()), -1))); }