@Test public void testNotClause() throws Exception { final SearchHandlerManager manager = mockController.getMock(SearchHandlerManager.class); final Clause notChildClause = mockController.getMock(Clause.class); final JqlOperandResolver jqlOperandResolver = mockController.getMock(JqlOperandResolver.class); ClauseSanitisingVisitor visitor = new ClauseSanitisingVisitor(manager, jqlOperandResolver, null); EasyMock.expect(notChildClause.accept(visitor)).andReturn(notChildClause); mockController.replay(); NotClause notClause = new NotClause(notChildClause); final Clause sanitisedClause = notClause.accept(visitor); assertEquals(notClause, sanitisedClause); mockController.verify(); }
@Test public void testSanitiseChildren() throws Exception { final SearchHandlerManager manager = mockController.getMock(SearchHandlerManager.class); final Clause childClause = mockController.getMock(Clause.class); final JqlOperandResolver jqlOperandResolver = mockController.getMock(JqlOperandResolver.class); ClauseSanitisingVisitor visitor = new ClauseSanitisingVisitor(manager, jqlOperandResolver, null); EasyMock.expect(childClause.accept(visitor)).andReturn(childClause); mockController.replay(); AndClause andClause = new AndClause(childClause); final List<Clause> sanitisedChildren = visitor.sanitiseChildren(andClause); assertEquals(1, sanitisedChildren.size()); assertEquals(childClause, sanitisedChildren.get(0)); mockController.verify(); }
@Test public void testOrClause() throws Exception { final SearchHandlerManager manager = mockController.getMock(SearchHandlerManager.class); final JqlOperandResolver jqlOperandResolver = mockController.getMock(JqlOperandResolver.class); mockController.replay(); final Clause expectedClause = new OrClause(new TerminalClauseImpl("field", Operator.EQUALS, "Value")); ClauseSanitisingVisitor visitor = new ClauseSanitisingVisitor(manager, jqlOperandResolver, null) { @Override List<Clause> sanitiseChildren(final Clause parentClause) { assertEquals(expectedClause, parentClause); return Collections.singletonList(parentClause); } }; final Clause sanitisedClause = expectedClause.accept(visitor); assertEquals(new OrClause(expectedClause), sanitisedClause); mockController.verify(); }