FileNameCheck extends DoubleDispatchVisitorCheck { @VisibleForTesting void setFormat(String format) { this.format = format; }  @Override void visitProperties(PropertiesTree tree); @Override void validateParameters();  }
@Test public void should_follow_a_custom_naming_convention_and_not_raise_an_issue() { check.setFormat("^[a-z][._a-z]+\\.properties$"); JavaPropertiesCheckVerifier.issues(check, CheckTestUtils.getTestFile("file-name/file_name.ok.properties")) .noMore(); }
@Test public void should_not_follow_a_custom_naming_convention_and_raise_an_issue() { check.setFormat("^[a-z]+\\.properties$"); JavaPropertiesCheckVerifier.issues(check, CheckTestUtils.getTestFile("file-name/file_name.kocustom.properties")) .next().withMessage("Rename this file to match the regular expression: ^[a-z]+\\.properties$") .noMore(); }
@Test public void should_throw_an_illegal_state_exception_as_the_format_parameter_regular_expression_is_not_valid() { try { check.setFormat("("); JavaPropertiesCheckVerifier.issues(check, CheckTestUtils.getTestFile("file-name/file_name.ok.properties")).noMore(); } catch (IllegalStateException e) { assertThat(e.getMessage()).isEqualTo("Check jproperties:S1578 (File names should comply with a naming convention): " + "format parameter \"(\" is not a valid regular expression."); } }