From 4c24b95c740c2fa71eb1d5af3876d65709f270e4 Mon Sep 17 00:00:00 2001 From: Roman Korostinskiy <70313618+c71n93@users.noreply.github.com> Date: Fri, 19 Apr 2024 18:09:33 +0300 Subject: [PATCH] #2297 resolve empty message duplication for eo-parser --- .../org/eolang/maven/BinarizeParseTest.java | 2 +- .../org/eolang/parser/EoIndentLexerTest.java | 10 +++++-- .../java/org/eolang/parser/EoSyntaxTest.java | 26 ++++++++----------- .../java/org/eolang/parser/ObjectsTest.java | 6 ++--- .../java/org/eolang/parser/StUnhexTest.java | 18 +++++-------- .../java/org/eolang/parser/StXPathTest.java | 2 +- .../test/java/org/eolang/AtCompositeTest.java | 3 +-- 7 files changed, 32 insertions(+), 35 deletions(-) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/BinarizeParseTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/BinarizeParseTest.java index 64bcd49190..b5911b15fd 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/BinarizeParseTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/BinarizeParseTest.java @@ -54,7 +54,7 @@ public final class BinarizeParseTest { /** - * Empty message for JUnit Assertions. To be removed. + * Empty message for JUnit Assertions. */ public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE"; diff --git a/eo-parser/src/test/java/org/eolang/parser/EoIndentLexerTest.java b/eo-parser/src/test/java/org/eolang/parser/EoIndentLexerTest.java index 33af185e43..8fad3b83ab 100644 --- a/eo-parser/src/test/java/org/eolang/parser/EoIndentLexerTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/EoIndentLexerTest.java @@ -33,12 +33,18 @@ * Test for {@link EoIndentLexer}. * * @since 1.0 + * + * @todo #2297:60m Replace all appearances of {@link EoIndentLexerTest#TO_ADD_MESSAGE} field in + * eo-parser with meaningful assert messages. Don't forget to remove + * {@link EoIndentLexerTest#TO_ADD_MESSAGE} field and remove public modifier from this class if no + * longer need. */ -final class EoIndentLexerTest { +@SuppressWarnings("PMD.JUnit5TestShouldBePackagePrivate") +public final class EoIndentLexerTest { /** * Empty message for JUnit Assertions. */ - private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE"; + public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE"; @Test void emitsTab() throws IOException { diff --git a/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java b/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java index d24fa0eb84..6686cba704 100644 --- a/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/EoSyntaxTest.java @@ -50,15 +50,11 @@ */ @SuppressWarnings("PMD.TooManyMethods") final class EoSyntaxTest { - /** - * Empty message for JUnit Assertions. - */ - private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE"; @Test void parsesSimpleCode() throws Exception { MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, XhtmlMatchers.xhtml( new String( new EoSyntax( @@ -92,7 +88,7 @@ void containsCommentCheckErrors( final String message ) throws IOException { MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, XhtmlMatchers.xhtml( new String( new EoSyntax( @@ -125,7 +121,7 @@ void printsProperListingEvenWhenSyntaxIsBroken() throws Exception { "[] > x-н, 1\n" ); MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, XhtmlMatchers.xhtml( new String( new EoSyntax( @@ -157,7 +153,7 @@ void copiesListingCorrectly() throws Exception { ) ); MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, xml.xpath("/program/listing/text()"), Matchers.contains(src) ); @@ -181,14 +177,14 @@ void parsesSuccessfully(final String code) { ); Assertions.assertDoesNotThrow( syntax::parsed, - EoSyntaxTest.TO_ADD_MESSAGE + EoIndentLexerTest.TO_ADD_MESSAGE ); } @Test void parsesArrow() throws IOException { MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new EoSyntax( "test-it-3", new InputOf("1 > x") @@ -212,7 +208,7 @@ void prasesNested() throws IOException { " v\n" ); MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new EoSyntax( "test-it-4", new InputOf(src) @@ -227,7 +223,7 @@ void prasesNested() throws IOException { @Test void parsesDefinition() throws IOException { MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new EoSyntax( "test-it-5", new InputOf( @@ -249,7 +245,7 @@ void parsesDefinition() throws IOException { @Test void parsesMethodCalls() throws IOException { MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new EoSyntax( "test-it-1", new InputOf("add.\n 0\n true") @@ -279,7 +275,7 @@ void storesAsBytes(final String code) throws IOException { ) ); MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, xml, XhtmlMatchers.hasXPaths( "/program/objects[count(o)=1]", @@ -299,7 +295,7 @@ void checksTypoPacks(final String yml) throws IOException { new InputOf(String.format("%s\n", map.get("eo"))) ).parsed(); MatcherAssert.assertThat( - EoSyntaxTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, XhtmlMatchers.xhtml(xml.toString()), XhtmlMatchers.hasXPaths("/program/errors/error/@line") ); diff --git a/eo-parser/src/test/java/org/eolang/parser/ObjectsTest.java b/eo-parser/src/test/java/org/eolang/parser/ObjectsTest.java index 394e26b081..fcdd48cbd9 100644 --- a/eo-parser/src/test/java/org/eolang/parser/ObjectsTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/ObjectsTest.java @@ -43,7 +43,7 @@ void parsesOneObject() { objs.data("xxx"); objs.leave(); MatcherAssert.assertThat( - "TO ADD ASSERTION MESSAGE", + EoIndentLexerTest.TO_ADD_MESSAGE, new XMLDocument(new Xembler(objs).domQuietly()), XhtmlMatchers.hasXPaths( "/o", @@ -65,7 +65,7 @@ void parsesNestedObjects() { objs.leave(); objs.leave(); MatcherAssert.assertThat( - "TO ADD ASSERTION MESSAGE", + EoIndentLexerTest.TO_ADD_MESSAGE, new XMLDocument(new Xembler(objs).domQuietly()), XhtmlMatchers.hasXPaths( "/o", @@ -84,7 +84,7 @@ void parsesObjectsWithEnteringPrevious() { objs.enter(); objs.prop("z", "a"); MatcherAssert.assertThat( - "TO ADD ASSERTION MESSAGE", + EoIndentLexerTest.TO_ADD_MESSAGE, new XMLDocument(new Xembler(objs).domQuietly()), XhtmlMatchers.hasXPaths( "/o/o", diff --git a/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java b/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java index f72e06dc1a..73505acb2d 100644 --- a/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/StUnhexTest.java @@ -35,15 +35,11 @@ * @since 0.29.0 */ final class StUnhexTest { - /** - * Empty message for JUnit Assertions. - */ - private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE"; @Test void convertsIntFromHexToEo() { MatcherAssert.assertThat( - StUnhexTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline(new StUnhex()).pass( new XMLDocument( "

01 02 E4 F3 04 67 32 E1

" @@ -56,7 +52,7 @@ void convertsIntFromHexToEo() { @Test void convertsMaxIntFromHexToEo() { MatcherAssert.assertThat( - StUnhexTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline(new StUnhex()).pass( new XMLDocument( "

FF FF FF FF FF FF FF FF

" @@ -69,7 +65,7 @@ void convertsMaxIntFromHexToEo() { @Test void convertsStringFromHexToEo() { MatcherAssert.assertThat( - StUnhexTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline(new StUnhex()).pass( new XMLDocument( String.join( @@ -89,7 +85,7 @@ void convertsStringFromHexToEo() { @Test void convertsEmptyStringFromHexToEo() { MatcherAssert.assertThat( - StUnhexTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline(new StUnhex()).pass( new XMLDocument( "

" @@ -104,7 +100,7 @@ void convertsEmptyStringFromHexToEo() { @Test void convertsFloatFromHexToEo() { MatcherAssert.assertThat( - StUnhexTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline(new StUnhex()).pass( new XMLDocument( "

41 42 43 67 AE CD 3E FD

" @@ -119,7 +115,7 @@ void convertsFloatFromHexToEo() { @Test void convertsTrueFromHexToEo() { MatcherAssert.assertThat( - StUnhexTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline(new StUnhex()).pass( new XMLDocument( String.join( @@ -139,7 +135,7 @@ void convertsTrueFromHexToEo() { @Test void convertsFalseFromHexToEo() { MatcherAssert.assertThat( - StUnhexTest.TO_ADD_MESSAGE, + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline(new StUnhex()).pass( new XMLDocument( "

00

" diff --git a/eo-parser/src/test/java/org/eolang/parser/StXPathTest.java b/eo-parser/src/test/java/org/eolang/parser/StXPathTest.java index c0920cb5a6..9509a74e5e 100644 --- a/eo-parser/src/test/java/org/eolang/parser/StXPathTest.java +++ b/eo-parser/src/test/java/org/eolang/parser/StXPathTest.java @@ -41,7 +41,7 @@ final class StXPathTest { @Test void modifiesSimpleNode() { MatcherAssert.assertThat( - "TO ADD ASSERTION MESSAGE", + EoIndentLexerTest.TO_ADD_MESSAGE, new Xsline( new StEndless( new StXPath( diff --git a/eo-runtime/src/test/java/org/eolang/AtCompositeTest.java b/eo-runtime/src/test/java/org/eolang/AtCompositeTest.java index 7c2ffafcb3..edf376ab1f 100644 --- a/eo-runtime/src/test/java/org/eolang/AtCompositeTest.java +++ b/eo-runtime/src/test/java/org/eolang/AtCompositeTest.java @@ -34,7 +34,6 @@ * * @since 0.16 * - * * @todo #2297:60m Replace all appearances of {@link AtCompositeTest#TO_ADD_MESSAGE} field in * eo-runtime with meaningful assert messages. Don't forget to remove * {@link AtCompositeTest#TO_ADD_MESSAGE} field and remove public modifier from this class if no @@ -45,7 +44,7 @@ public final class AtCompositeTest { /** * Empty message for JUnit Assertions. To be removed. */ - public static final String TO_ADD_MESSAGE = AtCompositeTest.TO_ADD_MESSAGE; + public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE"; @Test void decoratesCheckedException() {