diff --git a/.editorconfig b/.editorconfig index 767bf510..e9c04d2a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/JsonSerialiserConfig.kt b/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/JsonSerialiserConfig.kt index 9e17ed67..625ae96a 100644 --- a/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/JsonSerialiserConfig.kt +++ b/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/JsonSerialiserConfig.kt @@ -12,4 +12,4 @@ class JsonSerialiserConfig : ContextResolver { override fun getContext(objectType: Class<*>?): Jsonb { return jsonb } -} \ No newline at end of file +} diff --git a/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/routes/AssetsResource.kt b/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/routes/AssetsResource.kt index 08b38a1c..4a494e9e 100644 --- a/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/routes/AssetsResource.kt +++ b/adoptopenjdk-api-v3-frontend/src/main/kotlin/net/adoptopenjdk/api/v3/routes/AssetsResource.kt @@ -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", @@ -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", diff --git a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsPathTest.kt b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsPathTest.kt index 2a3bb2e7..daf2f4ec 100644 --- a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsPathTest.kt +++ b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsPathTest.kt @@ -51,7 +51,12 @@ abstract class AssetsPathTest : BaseTest() { return runFilterTest("heap_size", HeapSize.values()) } - protected fun createTest(values: Array, path: String, filterParamName: String, exclude: (element: T) -> Boolean = { false }): List { + protected fun createTest( + values: Array, + path: String, + filterParamName: String, + exclude: (element: T) -> Boolean = { false } + ): List { return values .filter { !exclude(it) } .map { value -> diff --git a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsResourceVersionPathTest.kt b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsResourceVersionPathTest.kt index 61ecb459..f029f466 100644 --- a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsResourceVersionPathTest.kt +++ b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/AssetsResourceVersionPathTest.kt @@ -25,10 +25,10 @@ class AssetsResourceVersionPathTest : AssetsPathTest() { @TestFactory fun filtersLts(): Stream { 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() diff --git a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/BinaryPathTest.kt b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/BinaryPathTest.kt index ca5e4319..3189f58a 100644 --- a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/BinaryPathTest.kt +++ b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/BinaryPathTest.kt @@ -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 @@ -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) @@ -73,7 +76,7 @@ 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) @@ -81,7 +84,7 @@ class BinaryPathTest : BaseTest() { @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) @@ -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) diff --git a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/JsonSerializationTest.kt b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/JsonSerializationTest.kt index dc71de3f..ba633d26 100644 --- a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/JsonSerializationTest.kt +++ b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/JsonSerializationTest.kt @@ -31,6 +31,4 @@ class JsonSerializationTest : BaseTest() { .statusCode(200) .body(PrettyPrintMatcher()) } - } - diff --git a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/ReleaseNamesPathTest.kt b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/ReleaseNamesPathTest.kt index 003c9ec5..f2e06a06 100644 --- a/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/ReleaseNamesPathTest.kt +++ b/adoptopenjdk-api-v3-frontend/src/test/kotlin/net/adoptopenjdk/api/ReleaseNamesPathTest.kt @@ -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() { @@ -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) + } } diff --git a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/AdoptRepos.kt b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/AdoptRepos.kt index ad49d92e..45431f11 100644 --- a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/AdoptRepos.kt +++ b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/AdoptRepos.kt @@ -46,7 +46,12 @@ class AdoptRepos { return allReleases.getReleases(releaseFilter, sortOrder) } - fun getFilteredReleases(version: Int, releaseFilter: Predicate, binaryFilter: Predicate, sortOrder: SortOrder): Sequence { + fun getFilteredReleases( + version: Int, + releaseFilter: Predicate, + binaryFilter: Predicate, + sortOrder: SortOrder + ): Sequence { val featureRelease = getFeatureRelease(version) ?: return emptySequence() return getFilteredReleases(featureRelease.releases.getReleases(releaseFilter, sortOrder), binaryFilter) diff --git a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/GithubId.kt b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/GithubId.kt index 7fafc18f..c3e82c60 100644 --- a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/GithubId.kt +++ b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/models/GithubId.kt @@ -8,8 +8,9 @@ class GithubId { @JsonCreator constructor( - @JsonProperty("githubId") - githubId: String) { + @JsonProperty("githubId") + githubId: String + ) { this.githubId = githubId.split("\\.")[0] } @@ -27,6 +28,4 @@ class GithubId { override fun hashCode(): Int { return githubId.hashCode() } - - } diff --git a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Installer.kt b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Installer.kt index 8762c093..07b8b6ad 100644 --- a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Installer.kt +++ b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Installer.kt @@ -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) diff --git a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Package.kt b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Package.kt index 45f6c494..12a4de9a 100644 --- a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Package.kt +++ b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Package.kt @@ -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) diff --git a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Release.kt b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Release.kt index 820d585b..e9e227dd 100644 --- a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Release.kt +++ b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/Release.kt @@ -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==") diff --git a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/ReleaseInfo.kt b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/ReleaseInfo.kt index 4c63d8da..5d11ae21 100644 --- a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/ReleaseInfo.kt +++ b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/ReleaseInfo.kt @@ -16,7 +16,12 @@ class ReleaseInfo { @Schema(example = "13") val most_recent_feature_release: Int - constructor(available_releases: Array, available_lts_releases: Array, most_recent_lts: Int, most_recent_feature_release: Int) { + constructor( + available_releases: Array, + available_lts_releases: Array, + 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 diff --git a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/VersionData.kt b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/VersionData.kt index b0946902..f219fd3d 100644 --- a/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/VersionData.kt +++ b/adoptopenjdk-api-v3-models/src/main/kotlin/net/adoptopenjdk/api/v3/models/VersionData.kt @@ -18,7 +18,17 @@ class VersionData : Comparable { 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 diff --git a/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/DownloadStatsInterface.kt b/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/DownloadStatsInterface.kt index 84ad0906..26ace76e 100644 --- a/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/DownloadStatsInterface.kt +++ b/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/DownloadStatsInterface.kt @@ -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 { + private suspend fun getStats( + start: ZonedDateTime, + end: ZonedDateTime, + featureVersion: Int?, + dockerRepo: String?, + statsSource: StatsSource + ): Collection { val githubGrouped = getGithubDownloadStatsByDate(start, end, featureVersion) val dockerGrouped = getDockerDownloadStatsByDate(start, end, dockerRepo) @@ -69,7 +75,12 @@ class DownloadStatsInterface( return stats } - private fun calculateDailyDiff(stats: Collection, periodStart: ZonedDateTime, periodEnd: ZonedDateTime, days: Int?): List { + private fun calculateDailyDiff( + stats: Collection, + periodStart: ZonedDateTime, + periodEnd: ZonedDateTime, + days: Int? + ): List { return stats .groupBy { it.dateTime.toLocalDate() } .map { grouped -> diff --git a/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/JsonMapper.kt b/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/JsonMapper.kt index 43166d6d..14bd0f5a 100644 --- a/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/JsonMapper.kt +++ b/adoptopenjdk-api-v3-persistance/src/main/kotlin/net/adoptopenjdk/api/v3/JsonMapper.kt @@ -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() { diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterHtmlClient.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterHtmlClient.kt index 9bb80030..2114db76 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterHtmlClient.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterHtmlClient.kt @@ -49,7 +49,11 @@ class DefaultUpdaterHtmlClient : UpdaterHtmlClient { } } - class ResponseHandler(val client: DefaultUpdaterHtmlClient, private val continuation: Continuation, val request: UrlRequest?) : FutureCallback { + class ResponseHandler( + val client: DefaultUpdaterHtmlClient, + private val continuation: Continuation, + val request: UrlRequest? + ) : FutureCallback { override fun cancelled() { continuation.resumeWithException(Exception("cancelled")) } diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterJsonMapper.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterJsonMapper.kt index 59bc036d..c3ce8064 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterJsonMapper.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/UpdaterJsonMapper.kt @@ -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() { diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt index f7b3536e..80ab0850 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt @@ -152,7 +152,11 @@ open class GraphQLGitHubInterface() { } } - protected suspend fun queryApi(requestEntityBuilder: GraphQLRequestEntity.RequestBuilder, cursor: String?, clazz: Class): GraphQLResponseEntity { + protected suspend fun queryApi( + requestEntityBuilder: GraphQLRequestEntity.RequestBuilder, + cursor: String?, + clazz: Class + ): GraphQLResponseEntity { requestEntityBuilder.variables(Variable("cursorPointer", cursor)) val query = requestEntityBuilder.build() diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/GithubIdDeserializer.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/GithubIdDeserializer.kt index 5be5649a..59a5540c 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/GithubIdDeserializer.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/GithubIdDeserializer.kt @@ -9,4 +9,4 @@ object GithubIdDeserializer : JsonDeserializer() { override fun deserialize(parser: JsonParser, context: DeserializationContext?): GithubId { return GithubId(parser.valueAsString) } -} \ No newline at end of file +} diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/summary/GHReleaseSummary.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/summary/GHReleaseSummary.kt index 1a857200..b6f4a7d3 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/summary/GHReleaseSummary.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/github/graphql/models/summary/GHReleaseSummary.kt @@ -10,8 +10,8 @@ import net.adoptopenjdk.api.v3.mapping.ReleaseMapper import java.time.ZonedDateTime data class GHReleasesSummary @JsonCreator constructor( - @JsonProperty("nodes") val releases: List, - @JsonProperty("pageInfo") val pageInfo: PageInfo + @JsonProperty("nodes") val releases: List, + @JsonProperty("pageInfo") val pageInfo: PageInfo ) { fun getIds(): List { return releases.map { it.id } @@ -19,11 +19,11 @@ data class GHReleasesSummary @JsonCreator constructor( } 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 { diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/mongo/CachedGithubHtmlClient.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/mongo/CachedGithubHtmlClient.kt index 3dd61c4e..22a792de 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/mongo/CachedGithubHtmlClient.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/dataSources/mongo/CachedGithubHtmlClient.kt @@ -35,7 +35,7 @@ object CachedGithubHtmlClient { return if (cachedEntry == null) { get(UrlRequest(url)) } else { - LOGGER.info("Scheduling for refresh ${url} ${cachedEntry.lastModified} ${workList.size}") + LOGGER.info("Scheduling for refresh $url ${cachedEntry.lastModified} ${workList.size}") workList.offer(UrlRequest(url, cachedEntry.lastModified)) cachedEntry.data } diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/mapping/adopt/AdoptReleaseMapper.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/mapping/adopt/AdoptReleaseMapper.kt index e756e1ba..6f5ed147 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/mapping/adopt/AdoptReleaseMapper.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/mapping/adopt/AdoptReleaseMapper.kt @@ -58,7 +58,7 @@ object AdoptReleaseMapper : ReleaseMapper() { } .ifEmpty { try { - //if we have no metadata resort to parsing release names + // if we have no metadata resort to parsing release names val version = parseVersionInfo(release, releaseName) val assets = release.releaseAssets.assets val id = release.id.githubId @@ -75,7 +75,7 @@ object AdoptReleaseMapper : ReleaseMapper() { } private fun generateIdForSplitRelease(version: VersionData, release: GHRelease): String { - //using a shortend hash as a suffix to keep id short, probability of clash still very low + // using a shortend hash as a suffix to keep id short, probability of clash still very low val suffix = Base64 .getEncoder() .encodeToString(MessageDigest @@ -86,12 +86,22 @@ object AdoptReleaseMapper : ReleaseMapper() { return release.id.githubId + "." + suffix } - private suspend fun toRelease(releaseName: String, assets: List, metadata: Map, id: String, release_type: ReleaseType, releaseLink: String, timestamp: ZonedDateTime, updatedAt: ZonedDateTime, vendor: Vendor, version: VersionData): Release { + private suspend fun toRelease( + releaseName: String, + assets: List, + metadata: Map, + id: String, + release_type: ReleaseType, + releaseLink: String, + timestamp: ZonedDateTime, + updatedAt: ZonedDateTime, + vendor: Vendor, + version: VersionData + ): Release { LOGGER.info("Getting binaries $releaseName") val binaries = AdoptBinaryMapper.toBinaryList(assets, metadata) LOGGER.info("Done Getting binaries $releaseName") - val downloadCount = assets .filter { asset -> BinaryMapper.BINARY_EXTENSIONS.any { asset.name.endsWith(it) } @@ -107,7 +117,7 @@ object AdoptReleaseMapper : ReleaseMapper() { val hasDate = Pattern.compile(dateMatcher).matcher(release.name) return if (release.url.matches(Regex(".*/openjdk[0-9]+-binaries/.*"))) { - //Can trust isPrerelease from -binaries repos + // Can trust isPrerelease from -binaries repos if (release.isPrerelease) { ReleaseType.ea } else { diff --git a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/stats/StatsInterface.kt b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/stats/StatsInterface.kt index 353b3e13..d46d3f22 100644 --- a/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/stats/StatsInterface.kt +++ b/adoptopenjdk-api-v3-updater/src/main/kotlin/net/adoptopenjdk/api/v3/stats/StatsInterface.kt @@ -26,8 +26,8 @@ class StatsInterface { githubDownloadStatsCalculator.saveStats(repos) dockerStatsInterface.updateDb() - //TODO bring back if we need it and once we understand stats trajectory - //removeBadDownloadStats() + // TODO bring back if we need it and once we understand stats trajectory + // removeBadDownloadStats() } private suspend fun removeBadDownloadStats() { diff --git a/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/AdoptReleaseMapperTest.kt b/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/AdoptReleaseMapperTest.kt index da91e25d..96e85290 100644 --- a/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/AdoptReleaseMapperTest.kt +++ b/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/AdoptReleaseMapperTest.kt @@ -44,7 +44,7 @@ class AdoptReleaseMapperTest : BaseTest() { runBlocking { val source = GHAssets(listOf(jdk), PageInfo(false, "")) - val ghRelease = GHRelease(GithubId("1"), "OpenJDK 123244354325", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "a-url"); + val ghRelease = GHRelease(GithubId("1"), "OpenJDK 123244354325", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "a-url") try { AdoptReleaseMapper.toAdoptRelease(ghRelease) @@ -59,10 +59,9 @@ class AdoptReleaseMapperTest : BaseTest() { fun statsIgnoresNonBinaryAssets() { runBlocking { - val source = GHAssets(listOf(jdk, checksum), PageInfo(false, "")) - val ghRelease = GHRelease(GithubId("1"), "jdk9u-2018-09-27-08-50", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "https://github.com/AdoptOpenJDK/openjdk9-binaries/releases/download/jdk9u-2018-09-27-08-50/OpenJDK9U-jre_aarch64_linux_hotspot_2018-09-27-08-50.tar.gz"); + val ghRelease = GHRelease(GithubId("1"), "jdk9u-2018-09-27-08-50", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "https://github.com/AdoptOpenJDK/openjdk9-binaries/releases/download/jdk9u-2018-09-27-08-50/OpenJDK9U-jre_aarch64_linux_hotspot_2018-09-27-08-50.tar.gz") val release = AdoptReleaseMapper.toAdoptRelease(ghRelease) @@ -76,7 +75,7 @@ class AdoptReleaseMapperTest : BaseTest() { val source = GHAssets(listOf(jdk), PageInfo(false, "")) - val ghRelease = GHRelease(GithubId("1"), "jdk9u-2018-09-27-08-50", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "https://github.com/AdoptOpenJDK/openjdk9-binaries/releases/download/jdk9u-2018-09-27-08-50/OpenJDK9U-jre_aarch64_linux_hotspot_2018-09-27-08-50.tar.gz"); + val ghRelease = GHRelease(GithubId("1"), "jdk9u-2018-09-27-08-50", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "https://github.com/AdoptOpenJDK/openjdk9-binaries/releases/download/jdk9u-2018-09-27-08-50/OpenJDK9U-jre_aarch64_linux_hotspot_2018-09-27-08-50.tar.gz") val release = AdoptReleaseMapper.toAdoptRelease(ghRelease) @@ -84,7 +83,6 @@ class AdoptReleaseMapperTest : BaseTest() { } } - @Test fun copesWithMultipleVersionsInSingleRelease() { runBlocking { @@ -129,7 +127,6 @@ class AdoptReleaseMapperTest : BaseTest() { ), PageInfo(false, "")) - UpdaterHtmlClientFactory.client = object : UpdaterHtmlClient { override suspend fun get(url: String): String? { return getMetadata(url) @@ -149,10 +146,10 @@ class AdoptReleaseMapperTest : BaseTest() { "pre": null, "adopt_build_number": 1, "major": 8, - "version": "1.8.0_242-${opt}-b0${url}", - "semver": "8.0.242+${url}.1.${opt}", - "build": ${url}, - "opt": "${opt}" + "version": "1.8.0_242-$opt-b0$url", + "semver": "8.0.242+$url.1.$opt", + "build": $url, + "opt": "$opt" }, "scmRef": "", "version_data": "jdk8u", @@ -161,7 +158,6 @@ class AdoptReleaseMapperTest : BaseTest() { } """.trimIndent() .replace("\n", "") - } override suspend fun getFullResponse(request: UrlRequest): HttpResponse? { @@ -177,7 +173,7 @@ class AdoptReleaseMapperTest : BaseTest() { } } - val ghRelease = GHRelease(GithubId("1"), "jdk9u-2018-09-27-08-50", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "https://github.com/AdoptOpenJDK/openjdk9-binaries/releases/download/jdk9u-2018-09-27-08-50/OpenJDK9U-jre_aarch64_linux_hotspot_2018-09-27-08-50.tar.gz"); + val ghRelease = GHRelease(GithubId("1"), "jdk9u-2018-09-27-08-50", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "https://github.com/AdoptOpenJDK/openjdk9-binaries/releases/download/jdk9u-2018-09-27-08-50/OpenJDK9U-jre_aarch64_linux_hotspot_2018-09-27-08-50.tar.gz") val release = AdoptReleaseMapper.toAdoptRelease(ghRelease) diff --git a/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/DockerStatsInterfaceTest.kt b/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/DockerStatsInterfaceTest.kt index 1223917b..b3cda3e0 100644 --- a/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/DockerStatsInterfaceTest.kt +++ b/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/DockerStatsInterfaceTest.kt @@ -71,7 +71,6 @@ class DockerStatsInterfaceTest { stats = downloadStatsInterface.getTrackingStats(10) assertEquals(240, stats[0].total) - } } } diff --git a/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/UpstreamReleaseMapperTest.kt b/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/UpstreamReleaseMapperTest.kt index 2230d645..b3140f5d 100644 --- a/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/UpstreamReleaseMapperTest.kt +++ b/adoptopenjdk-api-v3-updater/src/test/kotlin/net/adoptopenjdk/api/UpstreamReleaseMapperTest.kt @@ -25,7 +25,6 @@ class UpstreamReleaseMapperTest { } } - @Test fun statsOnlyLooksAtBinaryAssets() { runBlocking { @@ -49,7 +48,7 @@ class UpstreamReleaseMapperTest { PageInfo(false, "") ) - val ghRelease = GHRelease(GithubId("1"), "OpenJDK 8u232 GA Release", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "a-url"); + val ghRelease = GHRelease(GithubId("1"), "OpenJDK 8u232 GA Release", true, true, "2013-02-27T19:35:32Z", "2013-02-27T19:35:32Z", source, "8", "a-url") return ghRelease } }