Skip to content

Commit

Permalink
#1602 - minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Jul 10, 2023
1 parent f14b8aa commit ef2b83c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
32 changes: 19 additions & 13 deletions eo-maven-plugin/src/test/java/org/eolang/maven/FakeMaven.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ public TjSmart external() {
* @throws java.io.IOException If some problem with filesystem have happened.
*/
public <T extends AbstractMojo> FakeMaven execute(final Class<T> mojo) throws IOException {
this.fillUpTojos(this.foreign().select(all -> true));
this.fillUpTojos(this.external().select(all -> true));
this.fillUp(this.foreign().select(all -> true));
this.fillUp(this.external().select(all -> true));
this.params.putIfAbsent("targetDir", this.targetPath().toFile());
this.params.putIfAbsent("foreign", this.foreignPath().toFile());
this.params.putIfAbsent("external", this.externalPath().toFile());
Expand Down Expand Up @@ -319,14 +319,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.
*
Expand Down Expand Up @@ -467,10 +459,24 @@ private static Set<String> mojoFields(final Class<?> mojo, final Set<String> fie
}

/**
* Fill up given tojos by attributes.
* @param tojos Tojos to fill up.
* Path to or eo-external.* file after all changes.
* @return Path to eo-foreign.* file.
*/
private void fillUpTojos(final List<Tojo> tojos) {
private Path externalPath() {
return this.workspace.absolute(Paths.get("eo-external.csv"));
}

/**
* Fill up given tojos by the attributes.
* @param tojos Tojos to fill up.
* @todo #1602:30min Move the method to ForeignTojos if possible.
* Let's treat ForeignTojos as an object (not as a collection of data)
* and give it a chance to fulfill itself. It knows better how to do so.
* ForeignTojo in current implementation does not have method set() so
* we either need to implement it or just stay with the method here in
* FakeMaven class.
*/
private void fillUp(final List<Tojo> tojos) {
for (final Tojo tojo : tojos) {
for (final Map.Entry<ForeignTojos.Attribute, Object> entry
: this.attributes.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,7 @@ void registersInExternal(@TempDir final Path temp) throws IOException {
.execute(new FakeMaven.Register());
MatcherAssert.assertThat(
String.format(
String.join(
" ",
"Source object %s placed in %s should have been registered in external tojos",
"but it have not"
),
"Source object %s placed in %s should have been registered in external tojos but it didn't",
name,
source
),
Expand All @@ -119,7 +115,7 @@ void registersInExternal(@TempDir final Path temp) throws IOException {
Matchers.is(true)
);
MatcherAssert.assertThat(
"External and foreign tojos should have the same status after registering",
"External and foreign tojos should have the same status after registering because of identical behaviour at the step but they didn't",
maven.foreignTojos().status(),
Matchers.equalTo(maven.externalTojos().status())
);
Expand Down

0 comments on commit ef2b83c

Please sign in to comment.