@Test(expected=IllegalStateException.class) public void throwsExceptionWhenTryingToGetNonExistentChildMatcher() { new NotMatcher().originalMatcher(); }
@Test public void writeXMLOutputAddsNotTagsAroundWrappedMatchersOutput() throws Exception { Matcher wrappedMatcher = new TestMatcher(true); NotMatcher notMatcher = new NotMatcher(); notMatcher.addChild(wrappedMatcher); String xmlOutputCreated = writeXMLAndGetStringOutput(notMatcher); assertTrue(containsString("<Not>").matches(xmlOutputCreated)); assertTrue(containsString("<TestMatch>").matches(xmlOutputCreated)); assertTrue(containsString("</TestMatch>").matches(xmlOutputCreated)); assertTrue(containsString("</Not>").matches(xmlOutputCreated)); }
@Test public void canReturnChildMatcher() { Matcher wrappedMatcher = new TestMatcher(true); NotMatcher notMatcher = new NotMatcher(); notMatcher.addChild(wrappedMatcher); assertSame("Should return child matcher.", wrappedMatcher, notMatcher.originalMatcher()); }
@Test public void invertsResultsFromWrappedMatcher_doesntMatchWhenWrappedDoesMatch() throws Exception { Matcher wrappedMatcher = new TestMatcher(true); NotMatcher notMatcher = new NotMatcher(); notMatcher.addChild(wrappedMatcher); assertFalse(notMatcher.match(bug)); }
@Test public void invertsResultsFromWrappedMatcher_doesMatchWhenWrappedDoesnt() throws Exception { Matcher wrappedMatcher = new TestMatcher(false); NotMatcher notMatcher = new NotMatcher(); notMatcher.addChild(wrappedMatcher); assertTrue(notMatcher.match(bug)); }
NotMatcher matcher = new NotMatcher(); pushCompoundMatcherAsChild(matcher); } else if ("Source".equals(qName)) {
public static Matcher invertMatcher(Matcher originalMatcher) { if (originalMatcher instanceof NotMatcher) { return ((NotMatcher) originalMatcher).originalMatcher(); } NotMatcher notMatcher = new NotMatcher(); notMatcher.addChild(originalMatcher); return notMatcher; }
NotMatcher matcher = new NotMatcher(); pushCompoundMatcherAsChild(matcher); } else if ("Source".equals(qName)) {