BonitaVariableResourcePredicate implements Predicate<Variable> { @Override public boolean apply(Variable variable) { return URL.equals(variable.getType()) && variable.getValue() != null && !variable.getValue().isEmpty() && valueOf(variable.getValue().get(0)).matches(bonitaResourceRegex); } BonitaVariableResourcePredicate(String bonitaResourceRegex); @Override boolean apply(Variable variable);  }
@Test public void should_return_true_if_match_regex() throws Exception { variable.setType(URL); variable.setDisplayValue("matches"); assertThat(predicate.apply(variable)).isTrue(); }
@Test public void should_not_accept_url_not_accessing_bonita_api() throws Exception { variable.setType(URL); variable.setDisplayValue("do not match"); assertThat(predicate.apply(variable)).isFalse(); }
@Test public void should_not_accept_a_constant_data() throws Exception { variable.setType(CONSTANT); variable.setDisplayValue("matches"); assertThat(predicate.apply(variable)).isFalse(); }
@Test public void should_not_accept_an_expression_data() throws Exception { variable.setType(EXPRESSION); variable.setDisplayValue("matches"); assertThat(predicate.apply(variable)).isFalse(); }
@Test public void should_not_accept_a_JSON_data() throws Exception { variable.setType(JSON); variable.setDisplayValue("matches"); assertThat(predicate.apply(variable)).isFalse(); }