### Question:
TagPullMessageFilter implements PullMessageFilter { @Override @SuppressWarnings("all") public boolean match(PullRequest request, Buffer message) { TagPullFilter filter = getFilter(request, PullFilterType.TAG); return match(message, filter.getTags(), filter.getTagTypeCode()); }  @Override boolean isActive(PullRequest request, Buffer message); @Override @SuppressWarnings("all") boolean match(PullRequest request, Buffer message); @Override void init(DynamicConfig config);  }### Answer:
@Test public void testOrTagMatches() throws Exception { String tag1 = "tag1"; String tag2 = "tag2"; PullRequest request = TestToolBox.createDefaultPullRequest(); request.setFilters(Lists.newArrayList(new TagPullFilter(TagType.OR, Sets.newHashSet(tag1, tag2)))); BaseMessage message = TestToolBox.createDefaultMessage(); message.addTag(tag1); Buffer buffer = TestToolBox.messageToBuffer(message); TagPullMessageFilter filter = Mockito.spy(TagPullMessageFilter.class); boolean match = filter.match(request, buffer); assertTrue(match); }
@Test public void testAndTagMatches() throws Exception { String tag1 = "tag1"; String tag2 = "tag2"; PullRequest request = TestToolBox.createDefaultPullRequest(); request.setFilters(Lists.newArrayList(new TagPullFilter(TagType.AND, Sets.newHashSet(tag1, tag2)))); BaseMessage message = TestToolBox.createDefaultMessage(); message.addTag(tag1); message.addTag(tag2); message.addTag("tag3"); Buffer buffer = TestToolBox.messageToBuffer(message); TagPullMessageFilter filter = Mockito.spy(TagPullMessageFilter.class); boolean match = filter.match(request, buffer); assertTrue(match); }
@Test public void testAndTagNotMatches() throws Exception { String tag1 = "tag1"; String tag2 = "tag2"; String tag3 = "tag3"; PullRequest request = TestToolBox.createDefaultPullRequest(); request.setFilters(Lists.newArrayList(new TagPullFilter(TagType.AND, Sets.newHashSet(tag1, tag2, tag3)))); BaseMessage message = TestToolBox.createDefaultMessage(); message.addTag(tag1); message.addTag(tag2); Buffer buffer = TestToolBox.messageToBuffer(message); TagPullMessageFilter filter = Mockito.spy(TagPullMessageFilter.class); boolean match = filter.match(request, buffer); assertFalse(match); }