Skip to content

Commit

Permalink
objectionary#3941 resolve, tests that use Farea to integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Suban05 committed Feb 27, 2025
1 parent 8a85c79 commit 6af9710
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 35 deletions.
88 changes: 88 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
* SPDX-License-Identifier: MIT
*/
package org.eolang.maven;

import com.jcabi.manifests.Manifests;
import com.yegor256.MayBeSlow;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.file.Path;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Integration tests for {@link ResolveMojo}.
*
* @since 0.52
*/
@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"})
@ExtendWith({WeAreOnline.class, MktmpResolver.class, MayBeSlow.class})
final class ResolveMojoIT {
@Test
void resolvesJarFile(@Mktmp final Path temp) throws IOException {
new Farea(temp).together(
f -> {
ResolveMojoIT.configureFarea(f);
f.exec("process-classes");
MatcherAssert.assertThat(
"the jar file was resolved and unpacked",
f.files().file(
String.format(
"target/eo/%s/org.eolang/eo-runtime/-/0.39.0/org/eolang/Phi.class",
ResolveMojo.DIR
)
).exists(),
Matchers.is(true)
);
}
);
}

@Test
void removesOldJarFile(@Mktmp final Path temp) throws IOException {
new Farea(temp).together(
f -> {
ResolveMojoIT.configureFarea(f);
f.exec("process-classes");
f.dependencies()
.append("org.eolang", "eo-runtime", "0.40.0");
f.exec("process-classes");
MatcherAssert.assertThat(
"binary files from the old JAR were removed",
f.files().file(
String.format(
"target/eo/%s/org.eolang/eo-runtime/-/0.39.0",
ResolveMojo.DIR
)
).exists(),
Matchers.is(false)
);
}
);
}

private static void configureFarea(final Farea farea) throws IOException {
farea.clean();
farea.dependencies()
.append("org.eolang", "eo-runtime", "0.39.0");
farea.build()
.plugins()
.append(
"org.eolang",
"eo-maven-plugin",
System.getProperty(
"eo.version",
Manifests.read("EO-Version")
)
)
.execution()
.goals("resolve");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collections;
Expand Down Expand Up @@ -41,40 +40,6 @@ final class ResolveMojoTest {
*/
private static final String JAR_NOT_EXIST = "The jar file must not exist, but it doesn't";

@Test
void deletesOtherVersions(@Mktmp final Path temp) throws IOException {
new Farea(temp).together(
f -> {
f.clean();
f.dependencies()
.append("org.eolang", "eo-runtime", "0.39.0");
f.build()
.plugins()
.appendItself()
.execution()
.goals("resolve");
f.exec("process-classes");
MatcherAssert.assertThat(
"the jar file was resolved and unpacked",
f.files().file(
"target/eo/5-resolve/org.eolang/eo-runtime/-/0.39.0/org/eolang/Phi.class"
).exists(),
Matchers.is(true)
);
f.dependencies()
.append("org.eolang", "eo-runtime", "0.40.0");
f.exec("process-classes");
MatcherAssert.assertThat(
"binary files from the old JAR were removed",
f.files().file(
"target/eo/5-resolve/org.eolang/eo-runtime/-/0.39.0"
).exists(),
Matchers.is(false)
);
}
);
}

@Test
void resolvesWithSingleDependency(@Mktmp final Path temp) throws IOException {
new FakeMaven(temp)
Expand Down

0 comments on commit 6af9710

Please sign in to comment.