Skip to content

Commit

Permalink
objectionary#2937 start fixing assertion message warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Mar 14, 2024
1 parent f1f3960 commit 0a6eb97
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/PlaceTest.java
Expand Up @@ -33,10 +33,14 @@
* Test case for {@link Place}.
*
* @since 0.11
* @todo #2297:60min Add message to all JUnit assertions and remove corresponding
* {@code @SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")} annotation.
*/
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
final class PlaceTest {

@Test
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void makesPath() {
MatcherAssert.assertThat(
new Place("hello.foo.bar")
Expand All @@ -48,6 +52,7 @@ void makesPath() {
}

@Test
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void makesSimplePath() {
MatcherAssert.assertThat(
new Place("hey")
Expand Down
Expand Up @@ -53,6 +53,10 @@ void cleans(@TempDir final Path temp) throws IOException {
.with("classesDir", classes.toFile())
.execute(UnspileMojo.class);
MatcherAssert.assertThat(
String.format(
"UnspileMojo unable to remove %s class",
foo
),
Files.exists(foo),
Matchers.is(false)
);
Expand Down
Expand Up @@ -39,6 +39,8 @@
* Test case for {@link DcsDepgraph.DcsJson}.
*
* @since 0.28.11
* @todo #2297:60min Add message to all JUnit assertions and remove corresponding
* {@code @SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")} annotation.
*/
final class DcsDepgraphTest {

Expand All @@ -47,6 +49,7 @@ final class DcsDepgraphTest {
"eo-math-dependencies-transient-dependency.json, 3",
"eo-math-dependencies-without-foreign.json, 7"
})
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void readsAllDependenciesFromJsonFile(
final String name,
final long number,
Expand Down
Expand Up @@ -37,10 +37,13 @@
* Test case for {@link DcsEachWithoutTransitive}.
*
* @since 0.30
* @todo #2297:60min Add message to all JUnit assertions and remove corresponding
* {@code @SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")} annotation.
*/
final class DcsEachWithoutTransitiveTest {

@Test
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void failsIfHasTransitiveDependencies() {
Assertions.assertThrows(
IllegalStateException.class,
Expand All @@ -52,6 +55,7 @@ void failsIfHasTransitiveDependencies() {
}

@Test
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void keepsDependenciesThatHaveTeStDependenciesAsTransitive() {
final DcsFake original = new DcsFake();
MatcherAssert.assertThat(
Expand All @@ -64,6 +68,7 @@ void keepsDependenciesThatHaveTeStDependenciesAsTransitive() {
}

@Test
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void keepsDependencyThatHasTheSameDependencyAsTransitive() {
final DcsFake original = new DcsFake();
MatcherAssert.assertThat(
Expand All @@ -76,6 +81,7 @@ void keepsDependencyThatHasTheSameDependencyAsTransitive() {
}

@Test
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void keepsDependencyThatHasRuntimeDependencyAsTransitive() {
final DcsFake original = new DcsFake();
MatcherAssert.assertThat(
Expand Down
Expand Up @@ -33,11 +33,14 @@
* Test case for {@link DcsWithRuntime}.
*
* @since 0.28.11
* @todo #2297:60min Add message to all JUnit assertions and remove corresponding
* {@code @SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")} annotation.
*/
final class DcsWithRuntimeTest {

@Test
@ExtendWith(WeAreOnline.class)
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void addsHardcodedVersionOfRuntimeDependency() {
MatcherAssert.assertThat(
new DcsWithRuntime(
Expand All @@ -50,6 +53,7 @@ void addsHardcodedVersionOfRuntimeDependency() {

@Test
@ExtendWith(WeAreOnline.class)
@SuppressWarnings("PMD.JUnitAssertionsShouldIncludeMessage")
void addsRemoteVersionOfRuntimeDependency() {
MatcherAssert.assertThat(
new DcsWithRuntime(
Expand Down
Expand Up @@ -46,6 +46,10 @@ final class ChNarrowTest {
})
void cutsHashCorrectly(final String input, final String output) {
MatcherAssert.assertThat(
String.format(
"The hash of %s was calculated incorrectly",
input
),
new ChNarrow(
new CommitHash.ChConstant(input)
).value(),
Expand Down
Expand Up @@ -40,6 +40,7 @@ final class LatexTemplateTest {
@Test
void generatesFullTemplate() {
MatcherAssert.assertThat(
"LatexTemplate.asString() gives incorrect template",
new LatexTemplate(
"+package f\n[args] > main\n stdout \"Hello!\""
).asString(),
Expand Down
Expand Up @@ -54,6 +54,7 @@ String content() {
"//"
).save(new FtDefault(temp));
MatcherAssert.assertThat(
"The auto-generated file has wrong comment",
new TextOf(
temp.resolve("name.ext")
).asString(),
Expand Down
Expand Up @@ -43,6 +43,7 @@ void findsFiles(@TempDir final Path temp) throws Exception {
new HmBase(temp).save("", Paths.get("foo/hello/0.1/EObar/x.bin"));
new HmBase(temp).save("", Paths.get("EOxxx/bar"));
MatcherAssert.assertThat(
"Walk is not iterable with more than 1 item, but it must be",
new Walk(temp).includes(new ListOf<>("EO**/*")),
Matchers.iterableWithSize(1)
);
Expand Down
11 changes: 11 additions & 0 deletions eo-parser/src/test/java/org/eolang/parser/ParsingTrainTest.java
Expand Up @@ -46,6 +46,7 @@ final class ParsingTrainTest {
@Test
void buildsList() {
MatcherAssert.assertThat(
"ParsingTrain is not iterable with more than 1 item, but it must be",
new ParsingTrain(),
Matchers.iterableWithSize(Matchers.greaterThan(1))
);
Expand All @@ -69,6 +70,7 @@ void stopsPipeline() {
)
);
MatcherAssert.assertThat(
"XSL transformation don't work properly.",
new Xsline(
new ParsingTrain()
).pass(xml),
Expand Down Expand Up @@ -97,6 +99,7 @@ void stopsPipeline() {
})
void runsXslFunction(final String bytes, final String num) {
MatcherAssert.assertThat(
"Failed to convert byte to int using the apply-func.xsl transformation",
new Xsline(
new ParsingTrain("/org/eolang/parser/apply-func.xsl")
).pass(new XMLDocument(String.format("<o>%s</o>", bytes))),
Expand All @@ -116,6 +119,10 @@ void parsesPacks(final String pack) throws Exception {
);
}
MatcherAssert.assertThat(
String.format(
"The %s check pack is failed.",
pack
),
check.failures(),
Matchers.empty()
);
Expand All @@ -125,6 +132,10 @@ void parsesPacks(final String pack) throws Exception {
@ClasspathSource(value = "org/eolang/parser/xax/", glob = "**.yml")
void createsXaxStoryWithXslStylesheets(final String yaml) {
MatcherAssert.assertThat(
String.format(
"The %s xax check is failed",
yaml
),
new XaxStory(yaml),
Matchers.is(true)
);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -369,7 +369,7 @@ SOFTWARE.
<plugin>
<groupId>com.qulice</groupId>
<artifactId>qulice-maven-plugin</artifactId>
<version>0.22.0</version>
<version>0.22.2</version>
<configuration>
<excludes combine.children="append">
<exclude>checkstyle:/src/site/resources/.*</exclude>
Expand Down

0 comments on commit 0a6eb97

Please sign in to comment.