-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Additional tests for the new banner and version verification. (#…
…400)
- Loading branch information
1 parent
8f59c79
commit d334352
Showing
8 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/test/java/org/arquillian/tests/utilities/GitHubProjectVersionExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.arquillian.tests.utilities; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import org.apache.http.client.utils.URIBuilder; | ||
import org.jboss.arquillian.drone.webdriver.utils.HttpClient; | ||
|
||
public class GitHubProjectVersionExtractor { | ||
|
||
private String TAGS_URL = "/tags"; | ||
private String TAG_NAME = "name"; | ||
private String project; | ||
|
||
public GitHubProjectVersionExtractor(String project) { | ||
this.project = String.format("https://api.github.com/repos/arquillian/%s", project); | ||
} | ||
|
||
public String getLatestReleaseFromGitHub() { | ||
try { | ||
final HttpClient.Response response = sentGetRequestWithPagination(project + TAGS_URL, 1); | ||
JsonArray releaseTags = new Gson().fromJson(response.getPayload(), JsonElement.class).getAsJsonArray(); | ||
if (releaseTags.size() == 0) { | ||
return null; | ||
} | ||
return releaseTags.get(0).getAsJsonObject().get(TAG_NAME).getAsString(); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to fetch latest release from GitHub.", e); | ||
} | ||
} | ||
|
||
private HttpClient.Response sentGetRequestWithPagination(String url, int pageNumber) throws Exception { | ||
final URIBuilder uriBuilder = new URIBuilder(url); | ||
if (pageNumber != 1) { | ||
uriBuilder.setParameter("page", String.valueOf(pageNumber)); | ||
} | ||
return new HttpClient().get(uriBuilder.build().toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters