use of uk.nhs.digital.common.components.apispecification.commonmark.MarkdownConversionException in project hippo by NHS-digital-website.
the class CommonmarkMarkdownConverterTest method throwsException_onNegativeTopHeadingLevel.
@Test
public void throwsException_onNegativeTopHeadingLevel() {
// given
final String irrelevantMarkdown = randomString();
final String irrelevantHeadingIdPrefix = randomString();
final int illegalTopLevelHeading = -RandomUtils.nextInt();
// when
final ThrowingRunnable action = () -> commonmarkMarkdownConverter.toHtml(irrelevantMarkdown, irrelevantHeadingIdPrefix, illegalTopLevelHeading);
// then
final MarkdownConversionException actualException = assertThrows(MarkdownConversionException.class, action);
assertThat("Exception message provides failure's details.", actualException.getMessage(), is("Failed to convert Markdown " + irrelevantMarkdown));
assertThat("Cause highlights argument validation error.", actualException.getCause().getMessage(), is("Argument topHeadingLevel has to be greater than or equal to zero but was " + illegalTopLevelHeading));
}
Aggregations