rename 'fetchAssets' to 'listAssets' and return PagedIterable

This commit is contained in:
Tobias Nett
2020-11-18 19:27:31 +01:00
parent 98b067937a
commit 2676ef2b73
2 changed files with 6 additions and 7 deletions

View File

@@ -272,12 +272,12 @@ public class GHRelease extends GHObject {
* @throws IOException
* the io exception
* @deprecated The behavior of this method will change in a future release. It will then provide cached assets as
* provided by {@link #getCachedAssets()}. Use {@link #fetchAssets()} instead to fetch up-to-date
* provided by {@link #getCachedAssets()}. Use {@link #listAssets()} instead to fetch up-to-date
* information of assets.
*/
@Deprecated
public List<GHAsset> getAssets() throws IOException {
return fetchAssets();
return listAssets().toList();
}
/**
@@ -287,11 +287,10 @@ public class GHRelease extends GHObject {
* @throws IOException
* the io exception
*/
public List<GHAsset> fetchAssets() throws IOException {
public PagedIterable<GHAsset> listAssets() throws IOException {
Requester builder = owner.root.createRequest();
return builder.withUrlPath(getApiTailUrl("assets"))
.toIterable(GHAsset[].class, item -> item.wrap(this))
.toList();
.toIterable(GHAsset[].class, item -> item.wrap(this));
}
/**

View File

@@ -45,7 +45,7 @@ public class LifecycleTest extends AbstractGitHubWireMockTest {
private void updateAsset(GHRelease release, GHAsset asset) throws IOException {
asset.setLabel("test label");
assertEquals("test label", release.fetchAssets().get(0).getLabel());
assertEquals("test label", release.getAssets().get(0).getLabel());
}
private void deleteAsset(GHRelease release, GHAsset asset) throws IOException {
@@ -58,7 +58,7 @@ public class LifecycleTest extends AbstractGitHubWireMockTest {
assertNotNull(asset);
List<GHAsset> cachedAssets = release.getCachedAssets();
assertEquals(0, cachedAssets.size());
List<GHAsset> assets = release.fetchAssets();
List<GHAsset> assets = release.getAssets();
assertEquals(1, assets.size());
assertEquals("LICENSE.txt", assets.get(0).getName());