diff --git a/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java b/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java index e9b7e8a79..9c7efd9d1 100644 --- a/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java +++ b/metaschema-cli/src/test/java/gov/nist/secauto/metaschema/cli/CLITest.java @@ -8,9 +8,11 @@ import static org.junit.jupiter.api.Assertions.assertAll; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.assertj.core.api.Assertions.assertThat; import gov.nist.secauto.metaschema.cli.processor.ExitCode; import gov.nist.secauto.metaschema.cli.processor.ExitStatus; +import nl.altindag.log.LogCaptor; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -180,9 +182,9 @@ private static Stream providesValues() { "../core/metaschema/schema/metaschema/metaschema-module-metaschema.xml", }, ExitCode.OK, NO_EXCEPTION_CLASS)); + ; } }; - return values.stream(); } @@ -202,13 +204,21 @@ void testAllCommands(@NonNull String[] args, @NonNull ExitCode expectedExitCode, @Test void test() { - String[] cliArgs = { "validate-content", - "-m", - "src/test/resources/content/schema-validation-module.xml", - "src/test/resources/content/schema-validation-module-missing-required.xml", - "--as=xml", - "--disable-schema-validation" - }; - CLI.runCli(cliArgs); + try (LogCaptor captor = LogCaptor.forRoot()) { + String[] cliArgs = { "validate-content", + "-m", + "src/test/resources/content/215-module.xml", + "src/test/resources/content/215.xml", + "--disable-schema-validation" + }; + CLI.runCli(cliArgs); + assertThat(captor.getErrorLogs().toString()) + .contains(new String[] { + "expect-default-non-zero: Expect constraint '. > 0' did not match the data", + "expect-custom-non-zero: No default message, custom error message for expect-custom-non-zero constraint.", + "matches-default-regex-letters-only: Value '1' did not match the pattern", + "matches-custom-regex-letters-only: No default message, custom error message for matches-custom-regex-letters-only constraint." + }); + } } } diff --git a/metaschema-cli/src/test/resources/content/215-module.xml b/metaschema-cli/src/test/resources/content/215-module.xml new file mode 100644 index 000000000..922d5038f --- /dev/null +++ b/metaschema-cli/src/test/resources/content/215-module.xml @@ -0,0 +1,29 @@ + + + Module for metaschema-framework/metaschema-java#215 + 0.1.0 + model215 + https://github.com/metaschema-framework/metaschema-java/issues/215 + https://github.com/metaschema-framework/metaschema-java/issues/215 + + message-root + + + + + + + + + + No default message, custom error message for expect-custom-non-zero constraint. + + + + No default message, custom error message for matches-custom-regex-letters-only constraint. + + + + \ No newline at end of file diff --git a/metaschema-cli/src/test/resources/content/215.xml b/metaschema-cli/src/test/resources/content/215.xml new file mode 100644 index 000000000..ed57cbfdb --- /dev/null +++ b/metaschema-cli/src/test/resources/content/215.xml @@ -0,0 +1,7 @@ + + + 0 + 0 + 1 + 1 + \ No newline at end of file