Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 120
insert_final_newline = true
max_line_length = false
tab_width = 4
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class JsonSerialiserConfig : ContextResolver<Jsonb> {
override fun getContext(objectType: Class<*>?): Jsonb {
return jsonb
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AssetsResource {
@GET
@Path("/feature_releases/{feature_version}/{release_type}")
@Operation(summary = "Returns release information",
description = "List of information about builds that match the current query"
description = "List of information about builds that match the current query"
)
@APIResponses(value = [
APIResponse(responseCode = "200", description = "search results matching criteria",
Expand Down Expand Up @@ -133,7 +133,7 @@ class AssetsResource {
@GET
@Path("/version/{version}")
@Operation(summary = "Returns release information about the specified version.",
description = "List of information about builds that match the current query "
description = "List of information about builds that match the current query "
)
@APIResponses(value = [
APIResponse(responseCode = "200", description = "search results matching criteria",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ abstract class AssetsPathTest : BaseTest() {
return runFilterTest("heap_size", HeapSize.values())
}

protected fun <T> createTest(values: Array<T>, path: String, filterParamName: String, exclude: (element: T) -> Boolean = { false }): List<DynamicTest> {
protected fun <T> createTest(
values: Array<T>,
path: String,
filterParamName: String,
exclude: (element: T) -> Boolean = { false }
): List<DynamicTest> {
return values
.filter { !exclude(it) }
.map { value ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class AssetsResourceVersionPathTest : AssetsPathTest() {
@TestFactory
fun filtersLts(): Stream<DynamicTest> {
return listOf(
Pair("${getPath()}/${JAVA8_212}?lts=true", 200),
Pair("${getPath()}/${JAVA8_212}?lts=false", 404),
Pair("${getPath()}/${ABOVE_8}?lts=false", 200),
Pair("${getPath()}/${ABOVE_8}?lts=false", 200)
Pair("${getPath()}/$JAVA8_212?lts=true", 200),
Pair("${getPath()}/$JAVA8_212?lts=false", 404),
Pair("${getPath()}/$ABOVE_8?lts=false", 200),
Pair("${getPath()}/$ABOVE_8?lts=false", 200)
).map { request ->
DynamicTest.dynamicTest(request.first) {
val response = RestAssured.given()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import net.adoptopenjdk.api.v3.models.HeapSize
import net.adoptopenjdk.api.v3.models.ImageType
import net.adoptopenjdk.api.v3.models.JvmImpl
import net.adoptopenjdk.api.v3.models.OperatingSystem
import net.adoptopenjdk.api.v3.models.Project
import net.adoptopenjdk.api.v3.models.ReleaseType
import net.adoptopenjdk.api.v3.models.Vendor
import org.hamcrest.Matchers
Expand All @@ -38,33 +39,35 @@ class BinaryPathTest : BaseTest() {
val path = "/v3/binary"

fun getLatestPath(
featureVersion: Int,
releaseType: ReleaseType,
os: OperatingSystem,
arch: Architecture,
imageType: ImageType,
jvmImpl: JvmImpl,
heapSize: HeapSize,
vendor: Vendor
featureVersion: Int,
releaseType: ReleaseType,
os: OperatingSystem,
arch: Architecture,
imageType: ImageType,
jvmImpl: JvmImpl,
heapSize: HeapSize,
vendor: Vendor,
project: Project
): String {
return "$path/latest/$featureVersion/$releaseType/$os/$arch/$imageType/$jvmImpl/$heapSize/$vendor"
return "$path/latest/$featureVersion/$releaseType/$os/$arch/$imageType/$jvmImpl/$heapSize/$vendor?project=$project"
}

fun getVersionPath(
releaseName: String,
os: OperatingSystem,
arch: Architecture,
imageType: ImageType,
jvmImpl: JvmImpl,
heapSize: HeapSize,
vendor: Vendor
releaseName: String,
os: OperatingSystem,
arch: Architecture,
imageType: ImageType,
jvmImpl: JvmImpl,
heapSize: HeapSize,
vendor: Vendor,
project: Project
): String {
return "$path/version/$releaseName/$os/$arch/$imageType/$jvmImpl/$heapSize/$vendor"
return "$path/version/$releaseName/$os/$arch/$imageType/$jvmImpl/$heapSize/$vendor?project=$project"
}

@Test
fun latestDoesRedirectToBinary() {
val path = getLatestPath(8, ReleaseType.ga, OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk)
val path = getLatestPath(8, ReleaseType.ga, OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk, Project.jdk)
performRequest(path)
.then()
.statusCode(307)
Expand All @@ -73,15 +76,15 @@ class BinaryPathTest : BaseTest() {

@Test
fun noExistantLatestRequestGives404() {
val path = getLatestPath(4, ReleaseType.ga, OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk)
val path = getLatestPath(4, ReleaseType.ga, OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk, Project.jdk)
performRequest(path)
.then()
.statusCode(404)
}

@Test
fun nonExistantVersionRequestRedirects() {
val path = getVersionPath("jdk8u212-b04", OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk)
val path = getVersionPath("jdk8u212-b04", OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk, Project.jdk)
performRequest(path)
.then()
.statusCode(307)
Expand All @@ -90,7 +93,7 @@ class BinaryPathTest : BaseTest() {

@Test
fun nonExistantVersionRequestGives404() {
val path = getVersionPath("fooBar", OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk)
val path = getVersionPath("fooBar", OperatingSystem.linux, Architecture.x64, ImageType.jdk, JvmImpl.hotspot, HeapSize.normal, Vendor.adoptopenjdk, Project.jdk)
performRequest(path)
.then()
.statusCode(404)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ class JsonSerializationTest : BaseTest() {
.statusCode(200)
.body(PrettyPrintMatcher())
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ class ReleaseNamesPathTest : BaseTest() {
.statusCode(200)
}

@Test
fun releaseNamesSortOrder() {

RestAssured.given()
.`when`()
.get("/v3/info/release_names?sort_order=DESC")
.then()
.statusCode(200)
}

@Test
fun releaseVersions() {

Expand All @@ -25,4 +35,14 @@ class ReleaseNamesPathTest : BaseTest() {
.then()
.statusCode(200)
}

@Test
fun releaseVersionsSortOrder() {

RestAssured.given()
.`when`()
.get("/v3/info/release_versions?sort_order=ASC")
.then()
.statusCode(200)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ class AdoptRepos {
return allReleases.getReleases(releaseFilter, sortOrder)
}

fun getFilteredReleases(version: Int, releaseFilter: Predicate<Release>, binaryFilter: Predicate<Binary>, sortOrder: SortOrder): Sequence<Release> {
fun getFilteredReleases(
version: Int,
releaseFilter: Predicate<Release>,
binaryFilter: Predicate<Binary>,
sortOrder: SortOrder
): Sequence<Release> {
val featureRelease = getFeatureRelease(version) ?: return emptySequence()

return getFilteredReleases(featureRelease.releases.getReleases(releaseFilter, sortOrder), binaryFilter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class GithubId {

@JsonCreator
constructor(
@JsonProperty("githubId")
githubId: String) {
@JsonProperty("githubId")
githubId: String
) {
this.githubId = githubId.split("\\.")[0]
}

Expand All @@ -27,6 +28,4 @@ class GithubId {
override fun hashCode(): Int {
return githubId.hashCode()
}


}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package net.adoptopenjdk.api.v3.models

class Installer(name: String, link: String, size: Long, checksum: String?, checksum_link: String?, download_count: Long, signature_link: String? = null) : Asset(name, link, size, checksum, checksum_link, signature_link, download_count)
class Installer(
name: String,
link: String,
size: Long,
checksum: String?,
checksum_link: String?,
download_count: Long,
signature_link: String? = null
) : Asset(name, link, size, checksum, checksum_link, signature_link, download_count)
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
package net.adoptopenjdk.api.v3.models

class Package(name: String, link: String, size: Long, checksum: String?, checksum_link: String?, download_count: Long, signature_link: String? = null) : Asset(name, link, size, checksum, checksum_link, signature_link, download_count)
class Package(
name: String,
link: String,
size: Long,
checksum: String?,
checksum_link: String?,
download_count: Long,
signature_link: String? = null
) : Asset(name, link, size, checksum, checksum_link, signature_link, download_count)
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.eclipse.microprofile.openapi.annotations.media.Schema
import java.time.ZonedDateTime
import java.util.function.Predicate


class Release {

@Schema(example = "VXNlci0xMA==")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ class ReleaseInfo {
@Schema(example = "13")
val most_recent_feature_release: Int

constructor(available_releases: Array<Int>, available_lts_releases: Array<Int>, most_recent_lts: Int, most_recent_feature_release: Int) {
constructor(
available_releases: Array<Int>,
available_lts_releases: Array<Int>,
most_recent_lts: Int,
most_recent_feature_release: Int
) {
this.available_releases = available_releases
this.available_lts_releases = available_lts_releases
this.most_recent_lts = most_recent_lts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ class VersionData : Comparable<VersionData> {
val build: Int
val optional: String?

constructor(major: Int, minor: Int, security: Int, pre: String?, adopt_build_number: Int?, build: Int, optional: String?, openjdk_version: String, semver: String? = null) {
constructor(
major: Int,
minor: Int,
security: Int,
pre: String?,
adopt_build_number: Int?,
build: Int,
optional: String?,
openjdk_version: String,
semver: String? = null
) {
this.major = major
this.minor = minor
this.security = security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ class DownloadStatsInterface(
return calculateDailyDiff(stats, periodStart, periodEnd, days)
}

private suspend fun getStats(start: ZonedDateTime, end: ZonedDateTime, featureVersion: Int?, dockerRepo: String?, statsSource: StatsSource): Collection<StatEntry> {
private suspend fun getStats(
start: ZonedDateTime,
end: ZonedDateTime,
featureVersion: Int?,
dockerRepo: String?,
statsSource: StatsSource
): Collection<StatEntry> {
val githubGrouped = getGithubDownloadStatsByDate(start, end, featureVersion)
val dockerGrouped = getDockerDownloadStatsByDate(start, end, dockerRepo)

Expand All @@ -69,7 +75,12 @@ class DownloadStatsInterface(
return stats
}

private fun calculateDailyDiff(stats: Collection<StatEntry>, periodStart: ZonedDateTime, periodEnd: ZonedDateTime, days: Int?): List<DownloadDiff> {
private fun calculateDailyDiff(
stats: Collection<StatEntry>,
periodStart: ZonedDateTime,
periodEnd: ZonedDateTime,
days: Int?
): List<DownloadDiff> {
return stats
.groupBy { it.dateTime.toLocalDate() }
.map { grouped ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer
import com.fasterxml.jackson.module.kotlin.KotlinModule
import java.time.ZoneId
import java.time.ZonedDateTime

class ZonedTimeUpgrader : SimpleModule() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ class DefaultUpdaterHtmlClient : UpdaterHtmlClient {
}
}

class ResponseHandler(val client: DefaultUpdaterHtmlClient, private val continuation: Continuation<HttpResponse>, val request: UrlRequest?) : FutureCallback<HttpResponse> {
class ResponseHandler(
val client: DefaultUpdaterHtmlClient,
private val continuation: Continuation<HttpResponse>,
val request: UrlRequest?
) : FutureCallback<HttpResponse> {
override fun cancelled() {
continuation.resumeWithException(Exception("cancelled"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer
import com.fasterxml.jackson.datatype.jsr353.JSR353Module
import com.fasterxml.jackson.module.kotlin.KotlinModule
import net.adoptopenjdk.api.v3.TimeSource
import java.time.ZoneId
import java.time.ZonedDateTime

class ZonedTimeUpgrader : SimpleModule() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ open class GraphQLGitHubInterface() {
}
}

protected suspend fun <F : HasRateLimit> queryApi(requestEntityBuilder: GraphQLRequestEntity.RequestBuilder, cursor: String?, clazz: Class<F>): GraphQLResponseEntity<F> {
protected suspend fun <F : HasRateLimit> queryApi(
requestEntityBuilder: GraphQLRequestEntity.RequestBuilder,
cursor: String?,
clazz: Class<F>
): GraphQLResponseEntity<F> {

requestEntityBuilder.variables(Variable("cursorPointer", cursor))
val query = requestEntityBuilder.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ object GithubIdDeserializer : JsonDeserializer<GithubId>() {
override fun deserialize(parser: JsonParser, context: DeserializationContext?): GithubId {
return GithubId(parser.valueAsString)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import net.adoptopenjdk.api.v3.mapping.ReleaseMapper
import java.time.ZonedDateTime

data class GHReleasesSummary @JsonCreator constructor(
@JsonProperty("nodes") val releases: List<GHReleaseSummary>,
@JsonProperty("pageInfo") val pageInfo: PageInfo
@JsonProperty("nodes") val releases: List<GHReleaseSummary>,
@JsonProperty("pageInfo") val pageInfo: PageInfo
) {
fun getIds(): List<GithubId> {
return releases.map { it.id }
}
}

data class GHReleaseSummary @JsonCreator constructor(
@JsonProperty("id")
@JsonDeserialize(using = GithubIdDeserializer::class)
val id: GithubId,
@JsonProperty("publishedAt") val publishedAt: String,
@JsonProperty("updatedAt") val updatedAt: String
@JsonProperty("id")
@JsonDeserialize(using = GithubIdDeserializer::class)
val id: GithubId,
@JsonProperty("publishedAt") val publishedAt: String,
@JsonProperty("updatedAt") val updatedAt: String
) {

fun getUpdatedTime(): ZonedDateTime {
Expand Down
Loading