Skip to content

Commit

Permalink
#2297 resolved empty message duplication for eo-maven-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Apr 19, 2024
1 parent 5228a97 commit 7e465e1
Show file tree
Hide file tree
Showing 54 changed files with 252 additions and 260 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ final class BinarizeMojoTest {
*/
public static final Path SRC = Paths.get("src/test/resources/org/eolang/maven/binarize/");

/**
* Empty message for JUnit Assertions.
*/
private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

/**
* BinarizeMojo can binarize without errors.
* @param temp Temporary directory.
Expand All @@ -72,7 +67,7 @@ void binarizesWithoutErrors(@TempDir final Path temp) throws Exception {
}
Assertions.assertDoesNotThrow(
() -> maven.execute(new FakeMaven.Binarize()),
"TO ADD ASSERTION MESSAGE"
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand All @@ -87,7 +82,7 @@ void failsWithIncorrectInsert(@TempDir final Path temp) throws IOException {
Assertions.assertThrows(
IllegalStateException.class,
() -> maven.execute(new FakeMaven.Binarize()),
"TO ADD ASSERTION MESSAGE"
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand All @@ -105,14 +100,14 @@ void savesToCache(@TempDir final Path temp) throws IOException {
.execute(new FakeMaven.Binarize())
.result();
MatcherAssert.assertThat(
BinarizeMojoTest.TO_ADD_MESSAGE,
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.hasValue(
cache.resolve("Lib")
)
);
MatcherAssert.assertThat(
BinarizeMojoTest.TO_ADD_MESSAGE,
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.not(
Matchers.hasValue(
Expand All @@ -124,7 +119,7 @@ void savesToCache(@TempDir final Path temp) throws IOException {
);
Assertions.assertDoesNotThrow(
() -> maven.execute(new FakeMaven.Binarize()),
"TO ADD ASSERTION MESSAGE"
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand All @@ -147,7 +142,7 @@ void boostsSecondCompilation(@TempDir final Path temp) throws IOException {
finish = System.currentTimeMillis();
final long second = finish - start;
MatcherAssert.assertThat(
BinarizeMojoTest.TO_ADD_MESSAGE,
BinarizeParseTest.TO_ADD_MESSAGE,
second,
Matchers.lessThan(first)
);
Expand All @@ -172,12 +167,12 @@ void doesNotRecompile(@TempDir final Path temp) throws IOException {
maven.execute(new FakeMaven.Binarize());
final long second = executable.lastModified();
MatcherAssert.assertThat(
BinarizeMojoTest.TO_ADD_MESSAGE,
BinarizeParseTest.TO_ADD_MESSAGE,
first,
Matchers.not(0L)
);
MatcherAssert.assertThat(
BinarizeMojoTest.TO_ADD_MESSAGE,
BinarizeParseTest.TO_ADD_MESSAGE,
second,
Matchers.equalTo(first)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,20 @@
* Test case for {@link BinarizeParse}.
*
* @since 0.1
*
* @todo #2297:60m Replace all appearances of {@link BinarizeParseTest#TO_ADD_MESSAGE} field in
* assertions with meaningful assert messages. Don't forget to remove
* {@link BinarizeParseTest#TO_ADD_MESSAGE} field and remove public modifier from this class if no
* longer need.
*/
@SuppressWarnings("PMD.JUnit5TestShouldBePackagePrivate")
@Execution(ExecutionMode.CONCURRENT)
final class BinarizeParseTest {
public final class BinarizeParseTest {

/**
* Empty message for JUnit Assertions.
* Empty message for JUnit Assertions. To be removed.
*/
private static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";
public static final String TO_ADD_MESSAGE = "TO ADD ASSERTION MESSAGE";

@Test
void parsesSimpleEoProgram(@TempDir final Path temp) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class CatalogsTest {
void readsFromTojosConcurrently(@TempDir final Path tmp) {
final Tojos tojos = Catalogs.INSTANCE.make(tmp.resolve("foreign"), "json");
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new SumOf(
new Threads<>(
CatalogsTest.CORES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void cleansSuccessfully(@TempDir final Path temp) throws IOException {
.with("targetDir", dir.toFile())
.execute(CleanMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
!file.toFile().exists() && !small.toFile().exists(),
Matchers.is(true)
);
Expand All @@ -76,7 +76,7 @@ void makesFullCompilingLifecycleSuccessfully(@TempDir final Path temp) throws IO
.execute(AssembleMojo.class)
.execute(CleanMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
temp.resolve("target").toFile().exists(),
Matchers.is(false)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ void copiesSources(@TempDir final Path temp) throws Exception {
.execute(CopyMojo.class);
final Path out = classes.resolve("EO-SOURCES/foo/main.eo");
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new HmBase(classes).exists(classes.relativize(out)),
Matchers.is(true)
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(new HmBase(classes).load(classes.relativize(out))).asString(),
Matchers.allOf(
Matchers.containsString("+rt foo:"),
Expand Down Expand Up @@ -90,7 +90,7 @@ void skipsCopyMojo(@TempDir final Path temp) throws IOException {
.execute(CopyMojo.class);
final Path out = classes.resolve("EO-SOURCES/foo/main.eo");
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new HmBase(classes).exists(classes.relativize(out)),
Matchers.is(false)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ void findsDirs(@TempDir final Path temp) throws IOException {
new HmBase(temp).save("", Paths.get("test/f.txt"));
new HmBase(temp).save("", Paths.get("a/g"));
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new DepDirs(temp),
Matchers.contains(String.format("a%sb%1$sc%1$sf", File.separator))
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new DepDirs(temp),
Matchers.iterableWithSize(1)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ void executesDiscoveryPhaseForCorrectEoPrograms(
);
final Map<String, String> first = json.removeFirst();
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
dependencies,
Matchers.equalTo(json.size())
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
String.valueOf(dependencies),
Matchers.equalTo(first.get("discovered"))
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void convertsXmirtoJavaSuccessfully(@TempDir final Path temp) throws Exception {
Paths.get("sum.xmir")
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new TextOf(
new InputOf(
new JavaFiles(
Expand All @@ -86,7 +86,7 @@ void convertsXmirtoJavaWithoutJavaClasses(@TempDir final Path temp) throws Excep
Paths.get("sum.xmir")
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new JavaFiles(
temp.resolve("xml").resolve("sum.xmir"),
temp.resolve("java")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ final class LatexMojoTest {
@Test
void generatesTexFile(@TempDir final Path temp) throws Exception {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new FakeMaven(temp)
.withHelloWorld()
.execute(new FakeMaven.Latex())
Expand All @@ -64,7 +64,7 @@ void generatesTexFile(@TempDir final Path temp) throws Exception {
@Test
void checksLastName() {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
LatexMojo.last("foo.bar.hello"),
Matchers.equalTo("hello")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void printsFormattedMessage(final Logs out) {
@Test
void matchesCorrectly() {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
"16:02:08 [INFO] org.eolang.maven.LogFormatTest: Wake up, Neo...\n",
Matchers.matchesPattern(LogFormatTest.FORMAT)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void extendsForeignWithNewObjects(@TempDir final Path temp) throws IOException {
final FakeMaven maven = new FakeMaven(temp);
maven.execute(MarkMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
maven.foreignTojos()
.all()
.iterator()
Expand All @@ -71,12 +71,12 @@ void updatesVersionIfItExists(@TempDir final Path temp) throws IOException {
.withVersion("*.*.*");
maven.execute(MarkMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
foreign.all().iterator().next().version(),
Matchers.equalTo(MarkMojoTest.VERSION)
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
foreign.size(),
Matchers.equalTo(1)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void checksPacks(final String pack) throws IOException {
);
}
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
check.failures(),
Matchers.empty()
);
Expand All @@ -83,7 +83,7 @@ void skipsAlreadyOptimized(@TempDir final Path temp) throws IOException {
final long mtime = path.toFile().lastModified();
maven.execute(OptimizeMojo.class);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
path.toFile().lastModified(),
Matchers.is(mtime)
);
Expand Down Expand Up @@ -145,7 +145,7 @@ void getsAlreadyOptimizedResultsFromCache(@TempDir final Path temp) throws Excep
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Optimize());
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new XMLDocument(
new HmBase(temp).load(
Paths.get(
Expand All @@ -171,7 +171,7 @@ void savesOptimizedResultsToCache(@TempDir final Path temp) throws IOException {
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Optimize());
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
cache.resolve(OptimizeMojo.OPTIMIZED)
.resolve(hash)
.resolve("foo/x/main.xmir").toFile(),
Expand All @@ -188,14 +188,14 @@ void optimizesSuccessfully(@TempDir final Path temp) throws IOException {
.execute(new FakeMaven.Optimize())
.result();
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.hasKey(
String.format("target/%s/foo/x/main/01-not-empty-atoms.xml", OptimizeMojo.STEPS)
)
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.hasKey(
String.format("target/%s/foo/x/main.%s", OptimizeMojo.DIR, TranspileMojo.EXT)
Expand All @@ -221,7 +221,7 @@ void optimizesConcurrentlyWithLotsOfPrograms(@TempDir final Path temp) throws IO
.result();
for (int program = 0; program < total; ++program) {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.hasKey(
String.format(
Expand All @@ -238,7 +238,7 @@ void optimizesConcurrentlyWithLotsOfPrograms(@TempDir final Path temp) throws IO
@Test
void doesNotCrashesOnError(@TempDir final Path temp) throws Exception {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new FakeMaven(temp)
.withProgram(
"+package f\n",
Expand All @@ -258,7 +258,7 @@ void doesNotCrashesOnError(@TempDir final Path temp) throws Exception {
@Test
void choosesTransformerFactoryOnce() {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
TransformerFactory.newInstance().getClass(),
Matchers.typeCompatibleWith(TransformerFactoryImpl.class)
);
Expand All @@ -270,7 +270,7 @@ void choosesTransformerFactoryInConcurrentEnvironment() {
.mapToObj(i -> TransformerFactory.newInstance().getClass())
.collect(Collectors.toList())) {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
clazz,
Matchers.typeCompatibleWith(TransformerFactoryImpl.class)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class ParseMojoTest {
void parsesSuccessfully(@TempDir final Path temp) throws Exception {
final FakeMaven maven = new FakeMaven(temp);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
maven.withHelloWorld()
.execute(new FakeMaven.Parse())
.result(),
Expand All @@ -68,7 +68,7 @@ void parsesSuccessfully(@TempDir final Path temp) throws Exception {
)
);
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
maven.foreign().getById("foo.x.main").exists("xmir"),
Matchers.is(true)
);
Expand All @@ -82,7 +82,7 @@ void failsOnTimeout(@TempDir final Path temp) {
.withHelloWorld()
.with("timeout", 0)
.execute(InfiniteMojo.class),
"TO ADD ASSERTION MESSAGE"
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand Down Expand Up @@ -122,7 +122,7 @@ void parsesWithCache(@TempDir final Path temp) throws Exception {
@Test
void doesNotCrashesOnError(@TempDir final Path temp) throws Exception {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
new FakeMaven(temp)
.withProgram("something < is wrong here")
.execute(new FakeMaven.Parse())
Expand Down Expand Up @@ -169,7 +169,7 @@ void parsesConcurrentlyWithLotsOfPrograms(@TempDir final Path temp) throws IOExc
final Map<String, Path> res = maven.execute(new FakeMaven.Parse()).result();
for (int program = 0; program < total; ++program) {
MatcherAssert.assertThat(
"TO ADD ASSERTION MESSAGE",
BinarizeParseTest.TO_ADD_MESSAGE,
res,
Matchers.hasKey(
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void convertsXmirsToPhiWithoutErrors(final String xmir, @TempDir final Path temp
new HmBase(temp).save(xmir, Paths.get("target/2-optimize/test.xmir"));
Assertions.assertDoesNotThrow(
() -> maven.execute(PhiMojo.class),
"TO ADD ASSERTION MESSAGE"
BinarizeParseTest.TO_ADD_MESSAGE
);
}

Expand Down

0 comments on commit 7e465e1

Please sign in to comment.