From 54fa98fb15940cd42de35dafd815760b5fa0de00 Mon Sep 17 00:00:00 2001 From: Abdelhak Zaaim Date: Thu, 14 Nov 2024 20:40:38 +0100 Subject: [PATCH] Refactor tests to use assertThat instead of assertEquals (#1087) --- .../asciidoctor/IncludePreprocessorTest.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/maven-plugins/sitegen-maven-plugin/src/test/java/io/helidon/build/maven/sitegen/asciidoctor/IncludePreprocessorTest.java b/maven-plugins/sitegen-maven-plugin/src/test/java/io/helidon/build/maven/sitegen/asciidoctor/IncludePreprocessorTest.java index b62084163..b466b5921 100644 --- a/maven-plugins/sitegen-maven-plugin/src/test/java/io/helidon/build/maven/sitegen/asciidoctor/IncludePreprocessorTest.java +++ b/maven-plugins/sitegen-maven-plugin/src/test/java/io/helidon/build/maven/sitegen/asciidoctor/IncludePreprocessorTest.java @@ -32,7 +32,6 @@ import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; /** @@ -94,10 +93,10 @@ void testIncludeAnalysisFromNumberedInclude() { Include ia = Include.fromNumberedInclude(content, 2, String.format("// _include::%d-%d:%s", expectedStartWithinBlock, expectedEndWithinBlock, expectedIncludeTarget)); - assertEquals(expectedStartWithinBlock, ia.startWithinBlock(), "unexpected starting line number"); - assertEquals(expectedEndWithinBlock, ia.endWithinBlock(), "unexpected ending line number"); - assertEquals(includedContent, ia.body(), "unexpected body"); - assertEquals(expectedIncludeTarget, ia.includeTarget(), "unexpected include target"); + assertThat("unexpected starting line number", ia.startWithinBlock(), is(expectedStartWithinBlock)); + assertThat("unexpected ending line number", ia.endWithinBlock(), is(expectedEndWithinBlock)); + assertThat("unexpected body", ia.body(), is(includedContent)); + assertThat("unexpected include target", ia.includeTarget(), is(expectedIncludeTarget)); } @Test @@ -124,11 +123,11 @@ void testIncludeAnalysisFromBracketedInclude() { List result = new ArrayList<>(); Include ia = Include.consumeBracketedInclude(content, lineNumber, result, result.size()); - assertEquals(expectedStartWithinBlock, ia.startWithinBlock(), "unexpected start within block"); - assertEquals(expectedEndWithinBlock, ia.endWithinBlock(), "unexpected end within block"); - assertEquals(includedContent, ia.body(), "unexpected body"); - assertEquals(expectedIncludeTarget, ia.includeTarget(), "unexpected include target"); - assertEquals(expectedFinalLineAfterConsuming, lineNumber.get(), "unexpected final line number"); + assertThat("unexpected start within block", ia.startWithinBlock(), is(expectedStartWithinBlock)); + assertThat("unexpected end within block", ia.endWithinBlock(), is(expectedEndWithinBlock)); + assertThat("unexpected body", ia.body(), is(includedContent)); + assertThat("unexpected include target", ia.includeTarget(), is(expectedIncludeTarget)); + assertThat("unexpected final line number", lineNumber.get(), is(expectedFinalLineAfterConsuming)); } @Test @@ -242,8 +241,8 @@ void testOverallConversion() throws DiffException { List numberedContent = IncludePreprocessor.convertBracketedToNumbered(content); - assertEquals(expectedNumberedContent, numberedContent, "overall resulting content did not match; " + - DiffUtils.diff(expectedNumberedContent, numberedContent)); + assertThat("overall resulting content did not match; " + + DiffUtils.diff(expectedNumberedContent, numberedContent), numberedContent, is(expectedNumberedContent)); } @Test @@ -260,10 +259,11 @@ void testInitialProcessing() throws IOException, DiffException, URISyntaxExcepti List actualAfterInitialPreprocessingLines = IncludePreprocessor.convertHybridToBracketed(originalLines); - assertEquals(expectedAfterInitialPreprocessingLines, - actualAfterInitialPreprocessingLines, + assertThat("overall resulting content did not match; " + DiffUtils.diff(expectedAfterInitialPreprocessingLines, - actualAfterInitialPreprocessingLines).toString()); + actualAfterInitialPreprocessingLines), + actualAfterInitialPreprocessingLines, + is(expectedAfterInitialPreprocessingLines)); } private List loadFromPath(Path path) throws URISyntaxException, IOException { @@ -320,8 +320,7 @@ void testSourceBlockIncludeBracketing() throws DiffException { Block sba = Block.consumeBlock(orig, lineNumber); List bracketed = sba.asBracketedBlock(); - assertEquals(expectedBracketed, bracketed, - DiffUtils.diff(orig, bracketed).toString()); + assertThat("overall resulting content did not match; " + DiffUtils.diff(orig, bracketed).toString(), bracketed, is(expectedBracketed)); } private static List asList(String text) {