AndUrlPatternChecker implements ConditionChecker { @Override public boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters) { List<Parameter> params = parameters.getAllParameters(); Iterator<Parameter> iterator = params.iterator(); boolean result = !params.isEmpty(); while (iterator.hasNext() && result) { Parameter parameter = iterator.next(); result = evaluateParameter(request, parameter); } return result; }  @Override boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters);  }
@Test public void testCheckConditionShouldReturnFalseWhenParameterListIsEmpty() { boolean result = underTest.checkCondition(request, paramList); assertFalse(result); }
@Test public void testCheckConditionShouldReturnFalseWhenParameterListContainsOneElement() { paramList.addParameter(new Parameter("key1", "aba")); given(request.getRequestLine()).willReturn("cba"); boolean result = underTest.checkCondition(request, paramList); assertFalse(result); }
@Test public void testCheckConditionShouldReturnFalseWhenParameterListContainsMoreElementButFirstIsWrong() { paramList.addParameter(new Parameter("key1", "aba")); paramList.addParameter(new Parameter("key2", "ba")); paramList.addParameter(new Parameter("key3", "a")); given(request.getRequestLine()).willReturn("cba"); boolean result = underTest.checkCondition(request, paramList); assertFalse(result); }
@Test public void testCheckConditionShouldReturnTrueWhenParameterListContainsOneElement() { paramList.addParameter(new Parameter("key1", "aba")); given(request.getRequestLine()).willReturn("aba"); boolean result = underTest.checkCondition(request, paramList); Assert.assertTrue(result); }
@Test public void testCheckConditionShouldReturnTrueWhenParameterListContainsMoreElement() { paramList.addParameter(new Parameter("key1", "aba")); paramList.addParameter(new Parameter("key2", "ba")); paramList.addParameter(new Parameter("key3", "a")); given(request.getRequestLine()).willReturn("aba"); boolean result = underTest.checkCondition(request, paramList); Assert.assertTrue(result); }