@Test public void testFailFirst() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.FAIL); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.PASS); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.FAIL, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testFailSecond() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.PASS); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.FAIL); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.FAIL, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testStopFirst() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.STOP); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.PASS); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.STOP, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testStopFirst() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.STOP); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.PASS); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.STOP, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testFailFirst() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.FAIL); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.PASS); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.FAIL, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testFailBoth() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.FAIL); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.FAIL); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.FAIL, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testFailBoth() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.FAIL); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.FAIL); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.FAIL, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testStopFail() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.STOP); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.FAIL); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.STOP.combine(Result.FAIL), and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testPass() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.PASS); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.PASS); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.PASS, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testStopSecond() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.PASS); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.STOP); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.STOP, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testPass() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.PASS); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.PASS); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.PASS, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testStopSecond() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.PASS); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.STOP); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.STOP, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testFailSecond() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.PASS); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.FAIL); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.FAIL, and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }
@Test public void testStopFail() throws IOException { And and = new And(); PathData pathData = mock(PathData.class); Expression first = mock(Expression.class); when(first.apply(pathData, -1)).thenReturn(Result.STOP); Expression second = mock(Expression.class); when(second.apply(pathData, -1)).thenReturn(Result.FAIL); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); assertEquals(Result.STOP.combine(Result.FAIL), and.apply(pathData, -1)); verify(first).apply(pathData, -1); verify(second).apply(pathData, -1); verifyNoMoreInteractions(first); verifyNoMoreInteractions(second); }