Skip to content

Commit

Permalink
Reorganize test util functions for vectorized tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-nist committed Dec 6, 2023
1 parent 8635384 commit cbed72c
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,23 @@
* Unit test for simple CLI.
*/
public class CLITest {
void evaluateResult(@NonNull ExitStatus status, @NonNull ExitCode expectedCode) {
status.generateMessage(true);
assertAll(
() -> assertEquals(expectedCode, status.getExitCode(), "exit code mismatch"),
() -> assertNull(status.getThrowable(), "expected null Throwable"));
}

void evaluateResult(@NonNull ExitStatus status, @NonNull ExitCode expectedCode,
@NonNull Class<? extends Throwable> thrownClass) {
status.generateMessage(true);
Throwable thrown = status.getThrowable();
assert thrown != null;
assertAll(
() -> assertEquals(expectedCode, status.getExitCode(), "exit code mismatch"),
() -> assertEquals(thrownClass, thrown.getClass(), "expected Throwable mismatch"));
}

@Test
void testHelp() {
String[] args = {};
Expand All @@ -67,21 +84,4 @@ void testMetaschemaGenerateSchema() {
"target/schema-test.json" };
evaluateResult(CLI.runCli(args), ExitCode.OK);
}

void evaluateResult(@NonNull ExitStatus status, @NonNull ExitCode expectedCode) {
status.generateMessage(true);
assertAll(
() -> assertEquals(expectedCode, status.getExitCode(), "exit code mismatch"),
() -> assertNull(status.getThrowable(), "expected null Throwable"));
}

void evaluateResult(@NonNull ExitStatus status, @NonNull ExitCode expectedCode,
@NonNull Class<? extends Throwable> thrownClass) {
status.generateMessage(true);
Throwable thrown = status.getThrowable();
assert thrown != null;
assertAll(
() -> assertEquals(expectedCode, status.getExitCode(), "exit code mismatch"),
() -> assertEquals(thrownClass, thrown.getClass(), "expected Throwable mismatch"));
}
}

0 comments on commit cbed72c

Please sign in to comment.