Skip to content

Commit

Permalink
#534 up
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Aug 31, 2023
1 parent 65388d2 commit 39f29c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
20 changes: 18 additions & 2 deletions src/main/java/org/jpeek/web/Reports.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import com.jcabi.xml.XMLDocument;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -95,7 +98,7 @@ public Func<String, Response> apply(final String group,
final String version = new XMLDocument(
new UncheckedText(
new TextOf(
new URL(
Reports.toUrl(
String.format(
// @checkstyle LineLength (1 line)
"https://repo1.maven.org/maven2/%s/%s/maven-metadata.xml",
Expand All @@ -109,7 +112,7 @@ public Func<String, Response> apply(final String group,
new IoChecked<>(
new LengthOf(
new TeeInput(
new URL(
Reports.toUrl(
String.format(
"https://repo1.maven.org/maven2/%s/%s/%s/%s",
grp, artifact, version, name
Expand Down Expand Up @@ -176,4 +179,17 @@ private static void deleteIfPresent(final Path dir) throws IOException {
}
}

/**
* String to URL.
* @param uri The URL
* @return URL
*/
private static URL toUrl(final String uri) {
try {
return new URI(uri).toURL();
} catch (final MalformedURLException | URISyntaxException ex) {
throw new IllegalArgumentException(ex);
}
}

}
7 changes: 7 additions & 0 deletions src/test/java/org/jpeek/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import org.cactoos.Scalar;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.llorllale.cactoos.matchers.Assertion;
Expand All @@ -43,6 +44,12 @@
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
public final class MainTest {

@Test
@Disabled
public void printsHelp() throws IOException {
Main.main("--help");
}

@Test
public void createsXmlReports(@TempDir final Path temp) throws IOException {
final Path output = temp.resolve("x3");
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/jpeek/web/ReportsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URI;
import org.cactoos.BiFunc;
import org.cactoos.Func;
import org.cactoos.text.TextOf;
Expand All @@ -49,7 +49,7 @@ public final class ReportsTest {
@BeforeEach
public void weAreOnline() throws Exception {
try {
new TextOf(new URL("https://www.jpeek.org/")).asString();
new TextOf(new URI("https://www.jpeek.org/").toURL()).asString();
} catch (final IOException ex) {
Logger.debug(this, "We are not online: %s", ex.getMessage());
Assumptions.assumeTrue(false);
Expand Down

0 comments on commit 39f29c5

Please sign in to comment.