KeyRegularExpressionCheck extends DoubleDispatchVisitorCheck { @VisibleForTesting public void setRegularExpression(String regularExpression) { this.regularExpression = regularExpression; }  @Override void visitKey(KeyTree tree); @Override void validateParameters(); @VisibleForTesting void setRegularExpression(String regularExpression); @VisibleForTesting void setMessage(String message);  }
@Test public void should_throw_an_illegal_state_exception_as_the_regular_expression_parameter_is_not_valid() { try { KeyRegularExpressionCheck check = new KeyRegularExpressionCheck(); check.setRegularExpression("("); JSONCheckVerifier.verify(check, CheckTestUtils.getTestFile("keyRegularExpression.json")).noMore(); } catch (IllegalStateException e) { assertThat(e.getMessage()).isEqualTo("Check json:key-regular-expression (Regular expression on key): " + "regularExpression parameter \"(\" is not a valid regular expression."); } }