OrUrlPatternChecker implements ConditionChecker { @Override public boolean checkCondition(final WilmaHttpRequest request, final ParameterList parameters) { List<Parameter> params = parameters.getAllParameters(); Iterator<Parameter> iterator = params.iterator(); boolean result = false; if (!params.isEmpty()) { while (iterator.hasNext() && !result) { result = evaluateParameter(request, iterator.next()); } } 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 testCheckConditionShouldReturnFalseWhenParameterListContainsOneWrongElement() { paramList.addParameter(new Parameter("key1", "aba")); given(request.getRequestLine()).willReturn("cba"); boolean result = underTest.checkCondition(request, paramList); assertFalse(result); }
@Test public void testCheckConditionShouldReturnTrueWhenParameterListContainsMoreElementButAnyOfThemContaindByTheURL() { 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); assertTrue(result); }
@Test public void testCheckConditionShouldReturnTrueWhenParameterListContainsOneMatcherElement() { paramList.addParameter(new Parameter("key1", "aba")); given(request.getRequestLine()).willReturn("aba"); boolean result = underTest.checkCondition(request, paramList); assertTrue(result); }
@Test public void testCheckConditionShouldReturnTrueWhenParameterListContainsWrongElements() { paramList.addParameter(new Parameter("key1", "fff")); paramList.addParameter(new Parameter("key2", "ff")); paramList.addParameter(new Parameter("key3", "fffsa")); given(request.getRequestLine()).willReturn("aba"); boolean result = underTest.checkCondition(request, paramList); assertFalse(result); }