From ada3ede3953dd23f1f9d56b77538be80898c039c Mon Sep 17 00:00:00 2001 From: maxonfjvipon Date: Fri, 8 Sep 2023 11:01:12 +0300 Subject: [PATCH 1/5] feat(#2226): removed from FakeMaven --- .../test/java/org/eolang/maven/FakeMaven.java | 47 +------------------ 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java index a7d03ed528..7e1cdceb1a 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java @@ -197,7 +197,6 @@ public FakeMaven execute(final Class mojo) throws IO if (this.defaults) { this.params.putIfAbsent("targetDir", this.targetPath().toFile()); this.params.putIfAbsent("foreign", this.foreignPath().toFile()); - this.params.putIfAbsent("external", this.externalPath().toFile()); this.params.putIfAbsent("foreignFormat", "csv"); this.params.putIfAbsent("project", new MavenProjectStub()); final Path transpiled = Paths.get("transpiled"); @@ -285,28 +284,6 @@ ForeignTojos foreignTojos() { ); } - /** - * External tojos for eo-external.* file. - * @return External tojos. - */ - ForeignTojos externalTojos() { - return new ForeignTojos( - () -> Catalogs.INSTANCE.make(this.externalPath()), - this::scope - ); - } - - /** - * Tojo for eo-external.* file. - * - * @return TjSmart of the current eo-external.file. - */ - TjSmart external() { - return new TjSmart( - Catalogs.INSTANCE.make(this.externalPath()) - ); - } - /** * Sets placed tojo attribute. * @@ -415,23 +392,17 @@ FakeMaven withProgram(final String content, final ObjectName object) .withScope(scope) .withVersion(version) .withSource(source); - this.externalTojos() - .add(object) - .withScope(scope) - .withVersion(version) - .withSource(source); this.current.incrementAndGet(); return this; } /** - * Specify hash for all foreign and external tojos. + * Specify hash for all foreign tojos. * @param hash Commit hash * @return The same maven instance. */ FakeMaven allTojosWithHash(final CommitHash hash) { this.foreignTojos().all().forEach(tojo -> tojo.withHash(hash)); - this.externalTojos().all().forEach(tojo -> tojo.withHash(hash)); return this; } @@ -451,14 +422,6 @@ Path foreignPath() { return this.workspace.absolute(Paths.get("eo-foreign.csv")); } - /** - * Path to or eo-external.* file after all changes. - * @return Path to eo-foreign.* file. - */ - Path externalPath() { - return this.workspace.absolute(Paths.get("eo-external.csv")); - } - /** * Tojo for placed.json file. * @@ -496,14 +459,6 @@ ForeignTojo programTojo() { return this.foreignTojos().find(FakeMaven.tojoId(this.current.get() - 1)); } - /** - * Same as {@link FakeMaven#programTojo()} but for external tojos. - * @return Tojo entry. - */ - ForeignTojo programExternalTojo() { - return this.externalTojos().find(FakeMaven.tojoId(this.current.get() - 1)); - } - /** * The version of eo-maven-plugin for tests. * @return Version. From e4cd8c5b6eec5a8ba47fcdd3c6296c5d9e83de22 Mon Sep 17 00:00:00 2001 From: maxonfjvipon Date: Fri, 8 Sep 2023 11:08:54 +0300 Subject: [PATCH 2/5] feat(#2226): removed in SafeMojo --- .../main/java/org/eolang/maven/SafeMojo.java | 40 +------------------ 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java index 548eb2c588..e5b9f662e9 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java @@ -93,17 +93,6 @@ abstract class SafeMojo extends AbstractMojo { ) protected File foreign; - /** - * File with external "tojos". - * @checkstyle VisibilityModifierCheck (10 lines) - */ - @Parameter( - property = "eo.external", - required = true, - defaultValue = "${project.build.directory}/eo-external.csv" - ) - protected File external; - /** * Format of "foreign" file ("json" or "csv"). * @checkstyle MemberNameCheck (7 lines) @@ -202,8 +191,7 @@ abstract class SafeMojo extends AbstractMojo { /** * Used for object versioning implementation. - * If set to TRUE, external tojos are used instead of foreign ones and all - * inherited Mojos behave a bit differently. + * If set to TRUE all inherited Mojos behave a bit differently. * @todo #1602:30min Remove the flag when objection versioned is * implemented. The variable is used for implementation of object * versioning. It allows to use external tojos instead of foreign in Mojos. @@ -215,21 +203,6 @@ abstract class SafeMojo extends AbstractMojo { @Parameter(property = "eo.withVersions", defaultValue = "false") protected boolean withVersions; - /** - * External tojos. - * @todo #1602:30min Use external tojos to implement object versioning. - * Implementation of object versioning will bring a lot significant - * changes. That's why it's better to use independent separated tojos for - * that purpose. At the end when object versioning works - just replace - * them and remove unnecessary one. - * @checkstyle MemberNameCheck (7 lines) - * @checkstyle VisibilityModifierCheck (5 lines) - */ - protected final ForeignTojos externalTojos = new ForeignTojos( - () -> Catalogs.INSTANCE.make(this.external.toPath(), this.foreignFormat), - () -> this.scope - ); - /** * Commit hashes. * @checkstyle VisibilityModifierCheck (5 lines) @@ -323,9 +296,6 @@ public final void execute() throws MojoFailureException, MojoExecutionException if (this.foreign != null) { SafeMojo.closeTojos(this.tojos); } - if (this.external != null) { - SafeMojo.closeTojos(this.externalTojos); - } if (this.placed != null) { SafeMojo.closeTojos(this.placedTojos); } @@ -342,13 +312,7 @@ public final void execute() throws MojoFailureException, MojoExecutionException * @checkstyle AnonInnerLengthCheck (100 lines) */ protected final ForeignTojos scopedTojos() { - final ForeignTojos tjs; - if (this.external != null && this.withVersions) { - tjs = this.externalTojos; - } else { - tjs = this.tojos; - } - return tjs; + return this.tojos; } /** From 395337b4f7fedbbf24f854bc08733d5e929ee7cd Mon Sep 17 00:00:00 2001 From: maxonfjvipon Date: Fri, 8 Sep 2023 11:13:09 +0300 Subject: [PATCH 3/5] feat(#2226): clear tests --- .../org/eolang/maven/DiscoverMojoTest.java | 14 ++--- .../java/org/eolang/maven/MarkMojoTest.java | 2 +- .../java/org/eolang/maven/ProbeMojoTest.java | 12 ++-- .../java/org/eolang/maven/PullMojoTest.java | 2 +- .../org/eolang/maven/RegisterMojoTest.java | 55 ------------------- 5 files changed, 15 insertions(+), 70 deletions(-) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/DiscoverMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/DiscoverMojoTest.java index 13b2968776..9784f31bf0 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/DiscoverMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/DiscoverMojoTest.java @@ -62,13 +62,13 @@ final class DiscoverMojoTest { * Default assertion message. */ private static final String SHOULD_CONTAIN = - "External tojos should contain %s object after discovering, but they didn't"; + "Tojos should contain %s object after discovering, but they didn't"; /** * Default assertion message. */ private static final String SHOULD_NOT = - "External tojos should not contain %s object after discovering, but they did"; + "Tojos should not contain %s object after discovering, but they did"; @ParameterizedTest @CsvSource({ @@ -121,7 +121,7 @@ void discoversWithVersions(@TempDir final Path tmp) throws IOException { .execute(new FakeMaven.Discover()); final ObjectName stdout = new OnVersioned("org.eolang.stdout", "9c93528"); final String nop = "org.eolang.nop"; - final ForeignTojos tojos = maven.externalTojos(); + final ForeignTojos tojos = maven.foreignTojos(); MatcherAssert.assertThat( String.format(DiscoverMojoTest.SHOULD_CONTAIN, DiscoverMojoTest.TEXT), tojos.contains(DiscoverMojoTest.TEXT), @@ -163,7 +163,7 @@ void discoversWithSeveralObjectsWithDifferentVersions( .execute(new FakeMaven.Discover()); final ObjectName first = new OnVersioned("org.eolang.txt.sprintf", hashes.get("0.28.1")); final ObjectName second = new OnVersioned("org.eolang.txt.sprintf", hashes.get("0.28.2")); - final ForeignTojos tojos = maven.externalTojos(); + final ForeignTojos tojos = maven.foreignTojos(); MatcherAssert.assertThat( String.format(DiscoverMojoTest.SHOULD_CONTAIN, first), tojos.contains(first), @@ -193,7 +193,7 @@ void discoversDifferentUnversionedObjectsFromDifferentVersionedObjects(@TempDir .withProgram(second, new OnVersioned(object, two)) .withProgram(first, new OnDefault(object)) .execute(new FakeMaven.Discover()) - .externalTojos(); + .foreignTojos(); MatcherAssert.assertThat( String.format( "Tojos should contained 3 similar objects %s: 2 with different hashes %s and one without; but they didn't", @@ -219,12 +219,12 @@ void doesNotDiscoverWithVersions(@TempDir final Path tmp) throws IOException { final ObjectName seq = new OnVersioned("org.eolang.seq", "6c6269d"); MatcherAssert.assertThat( String.format(DiscoverMojoTest.SHOULD_NOT, seq), - maven.externalTojos().contains(seq), + maven.foreignTojos().contains(seq), Matchers.is(false) ); MatcherAssert.assertThat( String.format(DiscoverMojoTest.SHOULD_NOT, DiscoverMojoTest.TEXT), - maven.externalTojos().contains(DiscoverMojoTest.TEXT), + maven.foreignTojos().contains(DiscoverMojoTest.TEXT), Matchers.is(false) ); } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/MarkMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/MarkMojoTest.java index 793b94cf36..8f73baefec 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/MarkMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/MarkMojoTest.java @@ -85,7 +85,7 @@ void extendsTojosWithVersionedOne(@TempDir final Path temp) throws IOException { final ForeignTojos tojos = new FakeMaven(temp) .with("withVersions", true) .execute(MarkMojo.class) - .externalTojos(); + .foreignTojos(); final ObjectName object = new OnVersioned("foo.bar", "6a70071"); MatcherAssert.assertThat( String.format( diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/ProbeMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/ProbeMojoTest.java index 8dd9c7f793..131d9219dc 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/ProbeMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/ProbeMojoTest.java @@ -160,17 +160,17 @@ void findsProbesWithVersionsInOneObjectionary(@TempDir final Path temp) throws I "Tojos should contain versioned object %s after probing, but they didn't", ProbeMojoTest.STDOUT ), - maven.externalTojos().contains(ProbeMojoTest.STDOUT), + maven.foreignTojos().contains(ProbeMojoTest.STDOUT), Matchers.is(true) ); MatcherAssert.assertThat( "Program tojo entry in tojos after probing should contain one probed object", - maven.programExternalTojo().probed(), + maven.programTojo().probed(), Matchers.equalTo("1") ); MatcherAssert.assertThat( "Program tojo entry in tojos after probing should contain given hash", - maven.programExternalTojo().hash(), + maven.programTojo().hash(), Matchers.equalTo(hash.value()) ); } @@ -200,17 +200,17 @@ void findsProbesWithVersionsInDifferentObjectionaries(@TempDir final Path temp) "Tojos should contain versioned objects '%s' after probing, but they didn't", Arrays.asList(text, ProbeMojoTest.STDOUT) ), - maven.externalTojos().contains(text, ProbeMojoTest.STDOUT), + maven.foreignTojos().contains(text, ProbeMojoTest.STDOUT), Matchers.is(true) ); MatcherAssert.assertThat( "Program tojo after probing should contain exactly two probed objects", - maven.programExternalTojo().probed(), + maven.programTojo().probed(), Matchers.equalTo("2") ); MatcherAssert.assertThat( "Program tojo after probing should have given hash", - maven.programExternalTojo().hash(), + maven.programTojo().hash(), Matchers.equalTo(first.value()) ); } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java index f73441fa46..d366454bee 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java @@ -175,7 +175,7 @@ void skipsPullMojo(@TempDir final Path temp) throws IOException { @Test void pullsVersionedObjectSuccessfully(@TempDir final Path temp) throws IOException { final FakeMaven maven = new FakeMaven(temp); - maven.externalTojos() + maven.foreignTojos() .add(new OnVersioned(PullMojoTest.STDOUT, "9c93528")) .withVersion("*.*.*"); maven.with("withVersions", true) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java index 9875f74d11..420f737593 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java @@ -102,61 +102,6 @@ void doesNotFailWhenNoStrictNames(@TempDir final Path temp) throws IOException { ); } - @Test - void registersInExternal(@TempDir final Path temp) throws IOException { - new Home(temp).save( - new ResourceOf("org/eolang/maven/file-name/abc-def.eo"), - Paths.get("src/eo/org/eolang/maven/foo.eo") - ); - final String name = "org.eolang.maven.foo"; - final FakeMaven maven = new FakeMaven(temp) - .with(RegisterMojoTest.PARAM, temp.resolve(RegisterMojoTest.SOURCES).toFile()) - .with("withVersions", true) - .execute(new FakeMaven.Register()); - MatcherAssert.assertThat( - String.format( - "Source object %s placed in %s should have been registered in external tojos but it didn't", - name, - RegisterMojoTest.SOURCES - ), - maven.external() - .getById(name) - .exists("id"), - Matchers.is(true) - ); - MatcherAssert.assertThat( - "External and foreign tojos should not have the same status after registering because external should replace foreign but they didn't", - maven.foreignTojos().status(), - Matchers.not( - Matchers.equalTo( - maven.externalTojos().status() - ) - ) - ); - } - - @Test - void doesNotRegisterInExternal(@TempDir final Path temp) throws IOException { - new Home(temp).save( - new ResourceOf("org/eolang/maven/file-name/abc-def.eo"), - Paths.get("src/eo/org/eolang/maven/foo.eo") - ); - final String name = "org.eolang.maven.foo"; - Assertions.assertThrows( - NoSuchElementException.class, - () -> new FakeMaven(temp) - .with(RegisterMojoTest.PARAM, temp.resolve(RegisterMojoTest.SOURCES).toFile()) - .with("withVersions", false) - .execute(new FakeMaven.Register()) - .external() - .getById(name), - String.format( - "External tojos should not have contained %s because \"withVersions\" is FALSE, but they did", - name - ) - ); - } - @Test void throwsExceptionInCaseSourceDirIsNotSet(@TempDir final Path temp) { Assertions.assertThrows( From 4d4d44f3a7c6fc523739cbbcf22a7735ec66d49b Mon Sep 17 00:00:00 2001 From: maxonfjvipon Date: Fri, 8 Sep 2023 11:19:17 +0300 Subject: [PATCH 4/5] feat(#2226): checkstyle --- .../src/test/java/org/eolang/maven/RegisterMojoTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java index 420f737593..b8919bfb0f 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/RegisterMojoTest.java @@ -26,7 +26,6 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.NoSuchElementException; import org.cactoos.io.ResourceOf; import org.eolang.maven.util.Home; import org.hamcrest.MatcherAssert; From 089a62505fe582928e71ad469561e6c249be4697 Mon Sep 17 00:00:00 2001 From: maxonfjvipon Date: Fri, 8 Sep 2023 16:48:10 +0300 Subject: [PATCH 5/5] feat(#2226): changed description --- eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java index e5b9f662e9..7f31db209d 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java @@ -191,11 +191,10 @@ abstract class SafeMojo extends AbstractMojo { /** * Used for object versioning implementation. - * If set to TRUE all inherited Mojos behave a bit differently. + * If set to TRUE - objects are parsed, stored in tojos and processed as versioned. * @todo #1602:30min Remove the flag when objection versioned is * implemented. The variable is used for implementation of object - * versioning. It allows to use external tojos instead of foreign in Mojos. - * for the test purposes. When object versioning is implemented there + * versioning. When object versioning is implemented there * will be no need for that variable * @checkstyle VisibilityModifierCheck (10 lines) * @checkstyle MemberNameCheck (10 lines)