1
mirror of https://github.com/CarmJos/GithubReleases4J.git synced 2024-09-19 21:55:45 +00:00

修改示例代码

This commit is contained in:
Carm Jos 2022-01-24 17:40:31 +08:00
parent a6ab32a762
commit 3b787b8c0f
3 changed files with 15 additions and 9 deletions

View File

@ -18,7 +18,7 @@ public class GithubReleasesTest {
@Test @Test
public void onTest() { public void onTest() {
GithubReleases4J.listReleases("CarmJos", "EasyPlugin") GithubReleases4J.listReleases("CarmJos", "GithubReleases4J")
.stream().limit(2).forEach(GithubReleasesTest::printInfo); .stream().limit(2).forEach(GithubReleasesTest::printInfo);
GithubRelease release = GithubReleases4J.getLatestRelease("CarmJos", "UltraDepository"); GithubRelease release = GithubReleases4J.getLatestRelease("CarmJos", "UltraDepository");
@ -32,16 +32,18 @@ public class GithubReleasesTest {
private static void printInfo(@Nullable GithubRelease release) { private static void printInfo(@Nullable GithubRelease release) {
if (release == null) System.out.println("# NULL"); if (release == null) System.out.println("# NULL");
else { else {
System.out.println("# " + release.getName() + " [" + FORMAT.format(release.getCreateTime()) + "]"); print("# %s %s [%s] ",
release.getRepository(), release.getName(),
FORMAT.format(release.getCreateTime())
);
List<GithubAsset> assets = release.getAssets(); List<GithubAsset> assets = release.getAssets();
assets.forEach(GithubReleasesTest::printAssets); assets.forEach(GithubReleasesTest::printAssets);
} }
} }
private static void printAssets(@Nullable GithubAsset assets) { private static void printAssets(@Nullable GithubAsset assets) {
if (assets == null) System.out.println("- NULL"); if (assets != null) {
else { print("- %s (%s B)", assets.getName(), assets.getSize());
System.out.println("- " + assets.getName() + " [" + assets.getSize() + "]");
} }
} }
@ -49,12 +51,16 @@ public class GithubReleasesTest {
if (!DOWNLOAD) return; if (!DOWNLOAD) return;
if (assets == null) return; if (assets == null) return;
try { try {
File file = assets.download(); File file = assets.download(StandardCopyOption.REPLACE_EXISTING);
System.out.println("- at " + file.getAbsolutePath()); System.out.println("| -> " + file.getAbsolutePath());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
private static void print(String format, Object... params) {
System.out.printf((format) + "%n", params);
}
} }

View File

@ -5,7 +5,7 @@ import org.junit.Test;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
public class GithubUserTestTest { public class GithubUserInfoTest {
public static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

View File

@ -1,7 +1,7 @@
import cc.carm.lib.githubreleases4j.GithubReleases4J; import cc.carm.lib.githubreleases4j.GithubReleases4J;
import org.junit.Test; import org.junit.Test;
public class GithubVersionTest { public class GithubVersionCheckerTest {
@Test @Test