@Test public void noOperand() { boolean evaluationResult = new AndExpression().evaluate(invocation, cachedDataService); assertThat(evaluationResult, is(true)); }
@Test public void oneOperandTrue() { when(expr1.evaluate(invocation, cachedDataService)).thenReturn(true); AndExpression andExpression = new AndExpression(expr1); boolean evaluationResult = andExpression.evaluate(invocation, cachedDataService); assertThat(evaluationResult, is(true)); }
@Test public void oneOperandFalse() { when(expr1.evaluate(invocation, cachedDataService)).thenReturn(false); AndExpression andExpression = new AndExpression(expr1); boolean evaluationResult = andExpression.evaluate(invocation, cachedDataService); assertThat(evaluationResult, is(false)); }
@Test public void twoOperandsTrue() { when(expr1.evaluate(invocation, cachedDataService)).thenReturn(true); when(expr2.evaluate(invocation, cachedDataService)).thenReturn(true); AndExpression andExpression = new AndExpression(expr1, expr2); boolean evaluationResult = andExpression.evaluate(invocation, cachedDataService); assertThat(evaluationResult, is(true)); }
@Test public void twoOperandsFalse() { when(expr1.evaluate(invocation, cachedDataService)).thenReturn(true); when(expr2.evaluate(invocation, cachedDataService)).thenReturn(false); AndExpression andExpression = new AndExpression(expr1, expr2); boolean evaluationResult = andExpression.evaluate(invocation, cachedDataService); assertThat(evaluationResult, is(false)); }
@Test public void threeOperandsTrue() { when(expr1.evaluate(invocation, cachedDataService)).thenReturn(true); when(expr2.evaluate(invocation, cachedDataService)).thenReturn(true); when(expr3.evaluate(invocation, cachedDataService)).thenReturn(true); AndExpression andExpression = new AndExpression(expr1, expr2, expr3); boolean evaluationResult = andExpression.evaluate(invocation, cachedDataService); assertThat(evaluationResult, is(true)); }
@Test public void threeOperandsFalse() { when(expr1.evaluate(invocation, cachedDataService)).thenReturn(true); when(expr2.evaluate(invocation, cachedDataService)).thenReturn(true); when(expr3.evaluate(invocation, cachedDataService)).thenReturn(false); AndExpression andExpression = new AndExpression(expr1, expr2, expr3); boolean evaluationResult = andExpression.evaluate(invocation, cachedDataService); assertThat(evaluationResult, is(false)); } }