diff --git a/eo-maven-plugin/pom.xml b/eo-maven-plugin/pom.xml index a8d310f826..559551bd50 100644 --- a/eo-maven-plugin/pom.xml +++ b/eo-maven-plugin/pom.xml @@ -281,6 +281,12 @@ SOFTWARE. jping + + com.tngtech.archunit + archunit + 1.3.0 + test + diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/ArchitectureTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/ArchitectureTest.java new file mode 100644 index 0000000000..7cbfcd719e --- /dev/null +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/ArchitectureTest.java @@ -0,0 +1,48 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2025 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.eolang.maven; + +import com.tngtech.archunit.core.importer.ClassFileImporter; +import com.tngtech.archunit.lang.syntax.ArchRuleDefinition; +import org.junit.jupiter.api.Test; + +/** + * Test case for architectural conventions. + * + * @since 0.51.0 + */ +@SuppressWarnings({ "JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleAssertionMessage" }) +final class ArchitectureTest { + + @Test + void mojosAreInPlace() { + ArchRuleDefinition.classes() + .that().haveSimpleNameEndingWith("Mojo") + .and().doNotHaveSimpleName("SafeMojo") + .should().resideInAPackage("org.eolang.maven") + .andShould().bePublic() + .check(new ClassFileImporter().importPackages("org.eolang.maven")); + } + +} diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoTest.java index 2297591f96..2c5abb7822 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/ParseMojoTest.java @@ -108,7 +108,7 @@ void failsOnTimeout(@Mktmp final Path temp) { () -> new FakeMaven(temp) .withHelloWorld() .with("timeout", 0) - .execute(InfiniteMojo.class), + .execute(Infinite.class), CatalogsTest.TO_ADD_MESSAGE ); } @@ -229,7 +229,7 @@ void parsesConcurrentlyWithLotsOfPrograms(@Mktmp final Path temp) throws IOExcep * @since 0.29 */ @Mojo(name = "infinite", defaultPhase = LifecyclePhase.VALIDATE) - private static final class InfiniteMojo extends SafeMojo { + private static final class Infinite extends SafeMojo { @Override public void exec() { try {