$VNUM_REGEX(\\+\\-$OPT_REGEX)?)"
@@ -104,7 +103,7 @@ object VersionParser {
if (version != null) {
return version
}
- } catch (e: Exception) {
+ } catch (_: Exception) {
}
throw FailedToParse("Failed to parse $publishName")
}
@@ -126,7 +125,7 @@ object VersionParser {
if (!sanityCheck || sanityCheck(parsed)) {
return parsed
}
- } catch (e: Exception) {
+ } catch (_: Exception) {
}
return null
}
@@ -185,7 +184,7 @@ object VersionParser {
private fun sanityCheck(parsed: VersionData): Boolean {
- if (!(parsed.major in 101 downTo 7)) {
+ if (parsed.major !in 101 downTo 7) {
// Sanity check as javas parser can match a single number
// sane range is 8 to 100
// TODO update me before 2062 and java 100 is released
diff --git a/adoptium-models-parent/adoptium-api-v3-models/src/main/kotlin/net/adoptium/api/v3/parser/maven/SemverParser.kt b/adoptium-models-parent/adoptium-api-v3-models/src/main/kotlin/net/adoptium/api/v3/parser/maven/SemverParser.kt
index 3aadc2618..69722c602 100644
--- a/adoptium-models-parent/adoptium-api-v3-models/src/main/kotlin/net/adoptium/api/v3/parser/maven/SemverParser.kt
+++ b/adoptium-models-parent/adoptium-api-v3-models/src/main/kotlin/net/adoptium/api/v3/parser/maven/SemverParser.kt
@@ -1,14 +1,14 @@
-package net.adoptium.api.v3.parser.maven;
+package net.adoptium.api.v3.parser.maven
import net.adoptium.api.v3.models.VersionData
import net.adoptium.api.v3.parser.FailedToParse
import java.util.regex.Pattern
object SemverParser {
- val PRE = """(\-(?[\.A-Za-z0-9]+))?"""
- val BUILD = """(\+(?[\.A-Za-z0-9]+))?"""
- val VERSION_CORE = """(?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)$PRE$BUILD"""
- val MATCHER = Pattern.compile("^$VERSION_CORE$")
+ private const val PRE = """(\-(?[\.A-Za-z0-9]+))?"""
+ private const val BUILD = """(\+(?[\.A-Za-z0-9]+))?"""
+ private const val VERSION_CORE = """(?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)$PRE$BUILD"""
+ private val MATCHER = Pattern.compile("^$VERSION_CORE$")
fun parseAdoptSemverNonNull(version: String): VersionData {
return parseAdoptSemver(version) ?: throw FailedToParse("Failed to parse $version")
@@ -49,7 +49,7 @@ object SemverParser {
optional = if (parts.size > 2) parts[2] else null
adoptBuildNum = if (parts.size > 1) parts[1].toInt() else null
- build = if (parts.size > 0) parts[0].toInt() else null
+ build = if (parts.isNotEmpty()) parts[0].toInt() else null
if (build != null) {
patch = build / 100
diff --git a/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/api/SemverParserTest.kt b/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/net/adoptium/api/SemverParserTest.kt
similarity index 99%
rename from adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/api/SemverParserTest.kt
rename to adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/net/adoptium/api/SemverParserTest.kt
index 5bb85b1ff..df1b28c60 100644
--- a/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/api/SemverParserTest.kt
+++ b/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/net/adoptium/api/SemverParserTest.kt
@@ -1,4 +1,4 @@
-package api;
+package net.adoptium.api
import net.adoptium.api.v3.models.VersionData
import net.adoptium.api.v3.parser.VersionParser
diff --git a/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/api/VersionParserTest.kt b/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/net/adoptium/api/VersionParserTest.kt
similarity index 100%
rename from adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/api/VersionParserTest.kt
rename to adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/net/adoptium/api/VersionParserTest.kt
diff --git a/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/api/VersionRangeTest.kt b/adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/net/adoptium/api/VersionRangeTest.kt
similarity index 100%
rename from adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/api/VersionRangeTest.kt
rename to adoptium-models-parent/adoptium-api-v3-models/src/test/kotlin/net/adoptium/api/VersionRangeTest.kt
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/pom.xml b/adoptium-updater-parent/adoptium-api-v3-updater/pom.xml
index b4fbf4f96..a0bbbce6e 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/pom.xml
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/pom.xml
@@ -74,17 +74,6 @@
weld-junit5
test
-
- org.litote.kmongo
- kmongo-flapdoodle
- test
-
-
- org.slf4j
- slf4j-simple
-
-
-
io.mockk
mockk-jvm
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptReposBuilder.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptReposBuilder.kt
index 1f64e338e..6a6a1bf4b 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptReposBuilder.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptReposBuilder.kt
@@ -1,6 +1,5 @@
package net.adoptium.api.v3
-import ReleaseIncludeFilter
import jakarta.enterprise.context.ApplicationScoped
import jakarta.inject.Inject
import net.adoptium.api.v3.dataSources.VersionSupplier
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptRepository.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptRepository.kt
index f528a0696..91e39fa09 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptRepository.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/AdoptRepository.kt
@@ -1,6 +1,5 @@
package net.adoptium.api.v3
-import ReleaseIncludeFilter
import jakarta.enterprise.context.ApplicationScoped
import jakarta.inject.Inject
import kotlinx.coroutines.Deferred
@@ -76,7 +75,7 @@ open class AdoptRepositoryImpl @Inject constructor(
override suspend fun getReleaseById(gitHubId: GitHubId): ReleaseResult? {
val release = client.getReleaseById(gitHubId)
- if (release == null) return null;
+ if (release == null) return null
return getMapperForRepo(release.url)
.toAdoptRelease(release)
@@ -147,7 +146,7 @@ open class AdoptRepositoryImpl @Inject constructor(
}
}
- private suspend fun getDataForEachRepo(
+ private fun getDataForEachRepo(
version: Int,
filter: ReleaseIncludeFilter,
getFun: suspend (Vendor, String, String) -> E
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/ReleaseIncludeFilter.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/ReleaseIncludeFilter.kt
index 566c27f9e..949040caa 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/ReleaseIncludeFilter.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/ReleaseIncludeFilter.kt
@@ -1,4 +1,5 @@
-import net.adoptium.api.v3.TimeSource
+package net.adoptium.api.v3
+
import net.adoptium.api.v3.config.APIConfig
import net.adoptium.api.v3.mapping.ReleaseMapper
import net.adoptium.api.v3.models.Vendor
@@ -24,10 +25,10 @@ class ReleaseIncludeFilter(
}
fun filterVendor(vendor: Vendor): Boolean {
- if (includeAll || APIConfig.UPDATE_ADOPTOPENJDK) {
- return true // include all vendors
+ return if (includeAll || APIConfig.UPDATE_ADOPTOPENJDK) {
+ true // include all vendors
} else {
- return !excludedVendors.contains(vendor)
+ !excludedVendors.contains(vendor)
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/V3Updater.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/V3Updater.kt
index a3ea1f1ba..1764c6ed8 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/V3Updater.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/V3Updater.kt
@@ -1,7 +1,5 @@
package net.adoptium.api.v3
-import ReleaseFilterType
-import ReleaseIncludeFilter
import io.quarkus.arc.profile.UnlessBuildProfile
import io.quarkus.runtime.Startup
import jakarta.enterprise.context.ApplicationScoped
@@ -76,10 +74,6 @@ class V3Updater @Inject constructor(
.toList())
}
- init {
- //AppInsightsTelemetry.start()
- }
-
override fun addToUpdate(toUpdate: String): List {
val repo = apiDataStore.loadDataFromDb(true)
val toUpdateList = repo
@@ -145,10 +139,10 @@ class V3Updater @Inject constructor(
.forEach { releaseA ->
val releaseB = repoB.allReleases.getReleaseById(releaseA.id)
if (releaseB == null) {
- LOGGER.debug("Release disapeared ${releaseA.id} ${releaseA.version_data.semver}")
+ LOGGER.debug("Release disappeared ${releaseA.id} ${releaseA.version_data.semver}")
} else if (releaseA != releaseB) {
- LOGGER.debug("Release changedA $releaseA")
- LOGGER.debug("Release changedB $releaseB")
+ LOGGER.debug("Release changedA {}", releaseA)
+ LOGGER.debug("Release changedB {}", releaseB)
releaseA
.binaries
.forEach { binaryA ->
@@ -242,7 +236,7 @@ class V3Updater @Inject constructor(
)
}
- fun fullUpdate(currentRepo: AdoptRepos, releasesOnly: Boolean): AdoptRepos? {
+ private fun fullUpdate(currentRepo: AdoptRepos, releasesOnly: Boolean): AdoptRepos? {
// Must catch errors or may kill the scheduler
try {
return runBlocking {
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/ReleaseVersionResolver.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/ReleaseVersionResolver.kt
index 0c1ef8c0a..913c8dba3 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/ReleaseVersionResolver.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/ReleaseVersionResolver.kt
@@ -11,7 +11,7 @@ class ReleaseVersionResolver @Inject constructor(
private val versionSupplier: VersionSupplier
) {
- suspend fun formReleaseInfo(repo: AdoptRepos): ReleaseInfo {
+ fun formReleaseInfo(repo: AdoptRepos): ReleaseInfo {
val gaReleases = repo
.allReleases
.getReleases()
@@ -26,7 +26,7 @@ class ReleaseVersionResolver @Inject constructor(
.toTypedArray()
val mostRecentFeatureRelease: Int = availableReleases.lastOrNull() ?: 0
- val ltsVersions = versionSupplier.getLtsVersions();
+ val ltsVersions = versionSupplier.getLtsVersions()
val availableLtsReleases: Array = gaReleases
.asSequence()
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdatableVersionSupplierImpl.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdatableVersionSupplierImpl.kt
index eb15c6be7..6d51b22f9 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdatableVersionSupplierImpl.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdatableVersionSupplierImpl.kt
@@ -9,7 +9,7 @@ import org.slf4j.LoggerFactory
@ApplicationScoped
class UpdatableVersionSupplierImpl @Inject constructor(val updaterHtmlClient: UpdaterHtmlClient) : VersionSupplier, UpdatableVersionSupplier {
companion object {
- private val LOGGER: Logger = LoggerFactory.getLogger(UpdatableVersionSupplierImpl::class.java);
+ private val LOGGER: Logger = LoggerFactory.getLogger(UpdatableVersionSupplierImpl::class.java)
}
private val DEFAULT_LATEST_JAVA_VERSION = 24
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/stats/GitHubDownloadStatsCalculator.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/stats/GitHubDownloadStatsCalculator.kt
index f56aa7eb6..552f1b1a7 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/stats/GitHubDownloadStatsCalculator.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/main/kotlin/net/adoptium/api/v3/stats/GitHubDownloadStatsCalculator.kt
@@ -1,6 +1,7 @@
package net.adoptium.api.v3.stats
import jakarta.enterprise.context.ApplicationScoped
+import jakarta.inject.Inject
import net.adoptium.api.v3.TimeSource
import net.adoptium.api.v3.dataSources.models.AdoptRepos
import net.adoptium.api.v3.dataSources.persitence.ApiPersistence
@@ -9,7 +10,6 @@ import net.adoptium.api.v3.models.JvmImpl
import net.adoptium.api.v3.models.Vendor
import org.slf4j.LoggerFactory
import java.time.ZonedDateTime
-import jakarta.inject.Inject
@ApplicationScoped
open class GitHubDownloadStatsCalculator @Inject constructor(private val database: ApiPersistence) {
@@ -32,7 +32,7 @@ open class GitHubDownloadStatsCalculator @Inject constructor(private val databas
val stats = repos
.repos
.values
- .map { featureRelease ->
+ .sumOf { featureRelease ->
val total = featureRelease
.releases
.getReleases()
@@ -48,7 +48,6 @@ open class GitHubDownloadStatsCalculator @Inject constructor(private val databas
LOGGER.info("Stats ${featureRelease.featureVersion} $total")
total
}
- .sum()
LOGGER.info("Stats total $stats")
}
@@ -67,21 +66,21 @@ open class GitHubDownloadStatsCalculator @Inject constructor(private val databas
}
// Tally up jvmImpl download stats
- val jvmImplMap: Map = JvmImpl.values().map { jvmImpl ->
- jvmImpl to
- featureRelease
- .releases
- .getReleases()
- .filter { it.vendor == Vendor.getDefault() }
- .sumOf {
- it.binaries
- .filter { binary -> binary.jvm_impl == jvmImpl }
- .sumOf { binary ->
- binary.download_count.toInt()
- }
- }
+ val jvmImplMap: Map = JvmImpl.entries
+ .associateWith { jvmImpl ->
+ featureRelease
+ .releases
+ .getReleases()
+ .filter { it.vendor == Vendor.getDefault() }
+ .sumOf {
+ it.binaries
+ .filter { binary -> binary.jvm_impl == jvmImpl }
+ .sumOf { binary ->
+ binary.download_count.toInt()
+ }
+ }
.toLong()
- }.toMap()
+ }
GitHubDownloadStatsDbEntry(
date,
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/APIDataStoreTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/APIDataStoreTest.kt
index 86b6ac46a..0341f1097 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/APIDataStoreTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/APIDataStoreTest.kt
@@ -27,7 +27,7 @@ class APIDataStoreTest : MongoTest() {
fun reposHasElements() {
runBlocking {
val repo = BaseTest.adoptRepos
- assert(repo.getFeatureRelease(8)!!.releases.getReleases().toList().size > 0)
+ assert(repo.getFeatureRelease(8)!!.releases.getReleases().toList().isNotEmpty())
}
}
@@ -77,6 +77,6 @@ class APIDataStoreTest : MongoTest() {
@Test
fun `update is not scheduled by default`(apiDataStore: APIDataStoreImpl) {
- assertNull(apiDataStore.schedule)
+ assertNull(apiDataStore.getSchedule())
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptMetadataVersionParsingTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptMetadataVersionParsingTest.kt
index d225eee13..b890a3c2a 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptMetadataVersionParsingTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptMetadataVersionParsingTest.kt
@@ -23,7 +23,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
class AdoptMetadataVersionParsingTest : BaseTest() {
val client: UpdaterHtmlClient = object : UpdaterHtmlClient {
- override suspend fun get(url: String): String? {
+ override suspend fun get(url: String): String {
return """
{
"WARNING": "THIS METADATA FILE IS STILL IN ALPHA DO NOT USE ME",
@@ -49,10 +49,10 @@ class AdoptMetadataVersionParsingTest : BaseTest() {
""".trimIndent()
}
- override suspend fun getFullResponse(request: UrlRequest): HttpResponse? {
+ override suspend fun getFullResponse(request: UrlRequest): HttpResponse {
val metadataResponse = mockk()
val entity = mockk()
- every { entity.content } returns get(request.url)?.byteInputStream()
+ every { entity.content } returns get(request.url).byteInputStream()
every { metadataResponse.statusLine } returns BasicStatusLine(ProtocolVersion("", 1, 1), 200, "")
every { metadataResponse.entity } returns entity
every { metadataResponse.getFirstHeader("Last-Modified") } returns BasicHeader("Last-Modified", "Thu, 01 Jan 1970 00:00:00 GMT")
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseMapperTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseMapperTest.kt
index 79e579bfd..1b88224ef 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseMapperTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseMapperTest.kt
@@ -197,11 +197,11 @@ class AdoptReleaseMapperTest : BaseTest() {
private fun buildGhAssets(assetNames: List>) =
GHAssets(assetNames
- .map { it ->
+ .map {
GHAsset(
it.first,
1L,
- "${it.second}",
+ it.second,
1L,
"2013-02-27T19:35:32Z"
)
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseNotesTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseNotesTest.kt
index f40b53612..8699ad6ca 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseNotesTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReleaseNotesTest.kt
@@ -1,6 +1,6 @@
package net.adoptium.api
-import ReleaseIncludeFilter
+import net.adoptium.api.v3.ReleaseIncludeFilter
import kotlinx.coroutines.runBlocking
import net.adoptium.api.testDoubles.InMemoryApiPersistence
import net.adoptium.api.v3.AdoptRepository
@@ -57,7 +57,7 @@ class AdoptReleaseNotesTest : BaseTest() {
]
""".trimIndent()
} else {
- return null;
+ return null
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposBuilderTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposBuilderTest.kt
index 23a5a56a3..8e69ef132 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposBuilderTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposBuilderTest.kt
@@ -84,12 +84,9 @@ class AdoptReposBuilderTest : BaseTest() {
fun updatedReleaseIsNotUpdatedWhenThingsDontChange() {
runBlocking {
- val updated2 = runBlocking {
- adoptReposBuilder.incrementalUpdate(emptySet(), before) { null }
- }
- val updated3 = runBlocking {
- adoptReposBuilder.incrementalUpdate(emptySet(), before) { null }
- }
+ val updated2 = adoptReposBuilder.incrementalUpdate(emptySet(), before) { null }
+
+ val updated3 = adoptReposBuilder.incrementalUpdate(emptySet(), before) { null }
assertTrue { updated == updated2 }
assertTrue { updated2 == updated3 }
@@ -99,7 +96,7 @@ class AdoptReposBuilderTest : BaseTest() {
@Test
fun `young releases continue to be pulled`() {
runBlocking {
- val repo = stub.repo;
+ val repo = stub.repo
val adoptRepository = AdoptRepositoryStub()
val adoptRepo = spyk(adoptRepository)
val adoptReposBuilder = AdoptReposBuilder(adoptRepo, UpdatableVersionSupplierStub())
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposTestDataGenerator.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposTestDataGenerator.kt
index 2144e8b24..831553cfc 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposTestDataGenerator.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/AdoptReposTestDataGenerator.kt
@@ -28,7 +28,7 @@ object AdoptReposTestDataGenerator {
private val TEST_VERSIONS = listOf(8, 10, 11, 12)
private val TEST_RESOURCES = listOf(
PermittedValues(
- ReleaseType.values().asList(),
+ ReleaseType.entries,
listOf(Vendor.adoptopenjdk),
listOf(Project.jdk),
listOf(JvmImpl.hotspot),
@@ -38,17 +38,17 @@ object AdoptReposTestDataGenerator {
listOf(HeapSize.normal),
),
PermittedValues(
- ReleaseType.values().asList(),
+ ReleaseType.entries,
listOf(Vendor.adoptopenjdk),
listOf(Project.jdk),
listOf(JvmImpl.openj9),
listOf(ImageType.jre, ImageType.jdk),
listOf(Architecture.x64, Architecture.x32, Architecture.arm),
listOf(OperatingSystem.linux, OperatingSystem.mac, OperatingSystem.windows),
- HeapSize.values().asList()
+ HeapSize.entries
),
PermittedValues(
- ReleaseType.values().asList(),
+ ReleaseType.entries,
listOf(Vendor.openjdk),
listOf(Project.jdk),
listOf(JvmImpl.hotspot),
@@ -59,7 +59,7 @@ object AdoptReposTestDataGenerator {
listOf(8, 11)
),
PermittedValues(
- ReleaseType.values().asList(),
+ ReleaseType.entries,
listOf(Vendor.alibaba),
listOf(Project.jdk),
listOf(JvmImpl.dragonwell),
@@ -70,7 +70,7 @@ object AdoptReposTestDataGenerator {
listOf(8, 11)
),
PermittedValues(
- ReleaseType.values().asList(),
+ ReleaseType.entries,
listOf(Vendor.eclipse),
listOf(Project.jdk),
listOf(JvmImpl.hotspot),
@@ -81,7 +81,7 @@ object AdoptReposTestDataGenerator {
listOf(8, 11, 12)
),
PermittedValues(
- ReleaseType.values().asList(),
+ ReleaseType.entries,
listOf(Vendor.eclipse),
listOf(Project.jdk),
listOf(JvmImpl.hotspot),
@@ -232,7 +232,7 @@ object AdoptReposTestDataGenerator {
}
private fun exhaustiveBinaryList(): List {
- return HeapSize.values()
+ return HeapSize.entries
.map {
Binary(
createPackage(),
@@ -250,7 +250,7 @@ object AdoptReposTestDataGenerator {
)
}
.union(
- OperatingSystem.values()
+ OperatingSystem.entries
.map {
Binary(
createPackage(),
@@ -269,7 +269,7 @@ object AdoptReposTestDataGenerator {
}
)
.union(
- Architecture.values()
+ Architecture.entries
.map {
Binary(
createPackage(),
@@ -288,7 +288,7 @@ object AdoptReposTestDataGenerator {
}
)
.union(
- ImageType.values()
+ ImageType.entries
.map {
Binary(
createPackage(),
@@ -307,7 +307,7 @@ object AdoptReposTestDataGenerator {
}
)
.union(
- JvmImpl.values()
+ JvmImpl.entries
.map {
Binary(
createPackage(),
@@ -326,7 +326,7 @@ object AdoptReposTestDataGenerator {
}
)
.union(
- Project.values()
+ Project.entries
.map {
Binary(
createPackage(),
@@ -383,6 +383,7 @@ object AdoptReposTestDataGenerator {
return emptyList()
}
return releaseType
+ .asSequence()
.map { releaseBuilder()(it) }
.flatMap { builder -> vendor.map { builder(it) } }
.flatMap { builder -> getVersions(majorVersion).map { builder(it) } }
@@ -390,6 +391,7 @@ object AdoptReposTestDataGenerator {
.filter {
Vendor.validVendor(it.vendor)
}
+ .toList()
}
private fun getBinaries(): Array {
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/BaseTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/BaseTest.kt
index aebee413f..d9a556d96 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/BaseTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/BaseTest.kt
@@ -52,7 +52,7 @@ abstract class BaseTest {
return null
}
- override suspend fun getFullResponse(request: UrlRequest): HttpResponse? {
+ override suspend fun getFullResponse(request: UrlRequest): HttpResponse {
val metadataResponse = mockk()
val entity = mockk()
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/CachedGitHubHtmlClientTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/CachedGitHubHtmlClientTest.kt
index 23cda7411..c8718de7c 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/CachedGitHubHtmlClientTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/CachedGitHubHtmlClientTest.kt
@@ -1,6 +1,5 @@
package net.adoptium.api
-import io.mockk.Called
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.confirmVerified
@@ -15,14 +14,14 @@ import net.adoptium.api.v3.dataSources.UpdaterHtmlClient
import net.adoptium.api.v3.dataSources.UrlRequest
import net.adoptium.api.v3.dataSources.github.CachedGitHubHtmlClient
import net.adoptium.api.v3.dataSources.mongo.CacheDbEntry
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Assertions.assertNull
import org.junit.jupiter.api.DynamicTest
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestFactory
import org.junit.jupiter.api.extension.ExtendWith
import java.time.ZonedDateTime
import java.util.stream.Stream
-import org.junit.jupiter.api.Assertions.assertEquals
-import org.junit.jupiter.api.Assertions.assertNull
@ExtendWith(MockKExtension::class)
class CachedGitHubHtmlClientTest {
@@ -115,9 +114,11 @@ class CachedGitHubHtmlClientTest {
while (client.getQueueLength() > 0) {
delay(1000)
}
- coVerify(timeout = 3000) {
- updaterHtmlClient.getFullResponse(request)?.wasNot(Called)
+
+ coVerify(timeout = 3000, exactly = 0) {
+ updaterHtmlClient.getFullResponse(request)
}
+
confirmVerified(updaterHtmlClient)
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DateTimeMigrationTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DateTimeMigrationTest.kt
index 8064d0178..dbfcfca58 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DateTimeMigrationTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DateTimeMigrationTest.kt
@@ -1,23 +1,28 @@
package net.adoptium.api
+import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.runBlocking
import net.adoptium.api.v3.JsonMapper
import net.adoptium.api.v3.TimeSource
import net.adoptium.api.v3.dataSources.persitence.mongo.MongoClient
import net.adoptium.api.v3.models.DateTime
+import org.bson.Document
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.time.Instant
import java.time.ZoneOffset
import java.time.ZonedDateTime
-import java.util.UUID
+import java.util.*
import java.util.concurrent.TimeUnit
-class DateTimeMigrationTest : MongoTest() {
+data class HasZonedDateTime(
+ val zdt: ZonedDateTime)
+
+data class HasDateTime(
+ val zdt: DateTime)
- class HasZonedDateTime(val zdt: ZonedDateTime)
+class DateTimeMigrationTest : MongoTest() {
- class HasDateTime(val zdt: DateTime)
@Test
fun `can serialize as zdt and deserialize as DateTime`() {
@@ -39,17 +44,17 @@ class DateTimeMigrationTest : MongoTest() {
.minus(1, TimeUnit.MILLISECONDS.toChronoUnit())
val hzdt = HasZonedDateTime(date)
- val client1 = mongoClient.database.getCollection(collectionName)
+ val client1 = mongoClient.getDatabase().getCollection(collectionName)
client1.insertOne(hzdt)
- val hzdt2 = client1.findOne()
+ val hzdt2 = client1.find().firstOrNull()
assertEquals(hzdt.zdt, hzdt2?.zdt)
- val client2 = mongoClient.database.getCollection(collectionName)
- val fromDb = client2.findOne("{}")
- assertEquals(hzdt.zdt, fromDb?.zdt?.dateTime)
+ val client2 = mongoClient.getDatabase().getCollection(collectionName)
+ val fromDb = client2.find().firstOrNull()
+ assertEquals(hzdt.zdt, fromDb?.zdt)
} finally {
- mongoClient.database.dropCollection(collectionName)
+ mongoClient.getDatabase().getCollection(collectionName).drop()
}
}
}
@@ -67,22 +72,22 @@ class DateTimeMigrationTest : MongoTest() {
runBlocking {
try {
val hzdt = HasZonedDateTime(TimeSource.now())
- val client1 = mongoClient.database.getCollection(collectionName)
+ val client1 = mongoClient.getDatabase().getCollection(collectionName)
client1.insertOne(hzdt)
- val hzdt2 = client1.findOne()
+ val hzdt2 = client1.find().firstOrNull()
assertEquals(hzdt.zdt, hzdt2?.zdt)
- val client2 = mongoClient.database.getCollection(collectionName)
- val fromDb = client2.findOne("{}")
- assertEquals(hzdt.zdt, fromDb?.zdt?.dateTime)
+ val client2 = mongoClient.getDatabase().getCollection(collectionName)
+ val fromDb = client2.find(Document.parse("{}")).firstOrNull()
+ assertEquals(hzdt.zdt, fromDb?.zdt)
- client2.deleteMany()
+ client2.deleteMany(Document.parse("{}"))
client2.insertOne(fromDb!!)
- val fromDb2 = client2.findOne("{}")
- assertEquals(fromDb.zdt.dateTime, fromDb2?.zdt?.dateTime)
+ val fromDb2 = client2.find(Document.parse("{}")).firstOrNull()
+ assertEquals(fromDb.zdt, fromDb2?.zdt)
} finally {
- mongoClient.database.dropCollection(collectionName)
+ mongoClient.getDatabase().getCollection(collectionName).drop()
}
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DockerStatsInterfaceTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DockerStatsInterfaceTest.kt
index 2eb616b07..04cd682e7 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DockerStatsInterfaceTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/DockerStatsInterfaceTest.kt
@@ -34,7 +34,7 @@ class DockerStatsInterfaceTest : BaseTest() {
dockerStatsInterface.updateDb()
val stats = apiPersistence.getLatestAllDockerStats()
- Assertions.assertTrue(stats.size > 0)
+ Assertions.assertTrue(stats.isNotEmpty())
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/GraphQLGitHubReleaseClientTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/GraphQLGitHubReleaseClientTest.kt
index bf1890a25..59ff296bb 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/GraphQLGitHubReleaseClientTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/GraphQLGitHubReleaseClientTest.kt
@@ -1,7 +1,7 @@
package net.adoptium.api
-import ReleaseFilterType
-import ReleaseIncludeFilter
+import net.adoptium.api.v3.ReleaseFilterType
+import net.adoptium.api.v3.ReleaseIncludeFilter
import com.expediagroup.graphql.client.types.GraphQLClientRequest
import com.expediagroup.graphql.client.types.GraphQLClientResponse
import io.mockk.coEvery
@@ -124,14 +124,14 @@ class GraphQLGitHubReleaseClientTest : BaseTest() {
every { builder.errors } returns null
return builder
}
- };
+ }
val graphQLGitHubInterface = GraphQLGitHubInterface(graphQLRequest, mockkHttpClient())
val graphQLGitHubReleaseRequest = GraphQLGitHubReleaseRequest(graphQLGitHubInterface)
val client = GraphQLGitHubRepositoryClient(graphQLGitHubInterface, graphQLGitHubReleaseRequest)
- val repo = client.getRepository(AdoptRepositoryImpl.ADOPT_ORG, "a-repo-name", { _, _ -> true })
+ val repo = client.getRepository(AdoptRepositoryImpl.ADOPT_ORG, "a-repo-name") { _, _ -> true }
assertEquals(Companion.repo, repo)
}
@@ -208,7 +208,7 @@ class GraphQLGitHubReleaseClientTest : BaseTest() {
val client = GraphQLGitHubRepositoryClient(graphQLGitHubInterface, graphQLGitHubReleaseRequest)
- val repo = client.getRepository(AdoptRepositoryImpl.ADOPT_ORG, "a-repo-name", { _, _ -> true })
+ val repo = client.getRepository(AdoptRepositoryImpl.ADOPT_ORG, "a-repo-name") { _, _ -> true }
assertEquals(2, repo.releases.releases.size)
}
@@ -307,7 +307,7 @@ class GraphQLGitHubReleaseClientTest : BaseTest() {
every { builder.errors } returns null
return builder
}
- };
+ }
val graphQLGitHubInterface = GraphQLGitHubInterface(graphQLRequest, mockkHttpClient())
val graphQLGitHubReleaseRequest = GraphQLGitHubReleaseRequest(graphQLGitHubInterface)
@@ -315,7 +315,7 @@ class GraphQLGitHubReleaseClientTest : BaseTest() {
val client = GraphQLGitHubRepositoryClient(graphQLGitHubInterface, graphQLGitHubReleaseRequest)
- val htmlClient = mockk();
+ val htmlClient = mockk()
coEvery { htmlClient.getUrl(any()) }.returns(null)
val adoptReleaseMapperFactory = mockk()
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/InternalDbStoreTests.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/InternalDbStoreTests.kt
index a51196edc..639431528 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/InternalDbStoreTests.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/InternalDbStoreTests.kt
@@ -5,16 +5,15 @@ import net.adoptium.api.v3.TimeSource
import net.adoptium.api.v3.dataSources.mongo.CacheDbEntry
import net.adoptium.api.v3.dataSources.mongo.InternalDbStoreImpl
import net.adoptium.api.v3.dataSources.persitence.mongo.MongoClient
-import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
class InternalDbStoreTests : MongoTest() {
@Test
- fun `checked time is set`(mongoClient: MongoClient) {
+ fun `checked time is set`() {
runBlocking {
- val internalDbStore = InternalDbStoreImpl(mongoClient)
+ val internalDbStore = InternalDbStoreImpl(MongoClient())
val now = TimeSource.now()
val data = CacheDbEntry("foo", "bar", now, "some data")
@@ -30,7 +29,7 @@ class InternalDbStoreTests : MongoTest() {
internalDbStore.updateCheckedTime("foo", newTime)
val updated = internalDbStore.getCachedWebpage("foo")
- Assertions.assertEquals(CacheDbEntry(data.url, data.lastModified, newTime, data.data), updated)
+ assertEquals(CacheDbEntry(data.url, data.lastModified, newTime, data.data), updated)
}
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MetadataSerializationTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MetadataSerializationTest.kt
index d7e5aa52b..f56b4f692 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MetadataSerializationTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MetadataSerializationTest.kt
@@ -55,7 +55,7 @@ class MetadataSerializationTest {
val metadata = generateMetadata()
val serialized = UpdaterJsonMapper.mapper.writeValueAsString(metadata)
- var json = UpdaterJsonMapper.mapper.readValue(serialized, ObjectNode::class.java)
+ val json = UpdaterJsonMapper.mapper.readValue(serialized, ObjectNode::class.java)
json.remove("WARNING")
val noWarning = GHMetaData(null, metadata.os, metadata.arch, metadata.variant, metadata.version, metadata.scmRef, metadata.version_data, metadata.binary_type, metadata.sha256)
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoAPIPersistenceTests.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoAPIPersistenceTests.kt
index 3cd0ee542..fc8082866 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoAPIPersistenceTests.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoAPIPersistenceTests.kt
@@ -4,16 +4,15 @@ import kotlinx.coroutines.runBlocking
import net.adoptium.api.v3.TimeSource
import net.adoptium.api.v3.dataSources.models.GitHubId
import net.adoptium.api.v3.dataSources.persitence.mongo.MongoApiPersistence
+import net.adoptium.api.v3.dataSources.persitence.mongo.MongoClient
import net.adoptium.api.v3.models.GHReleaseMetadata
-import org.junit.jupiter.api.Assertions
-import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
class MongoAPIPersistenceTests : MongoTest() {
@Test
- fun `update time is set`(apiPersistence: MongoApiPersistence) {
+ fun `update time is set`(api: MongoApiPersistence) {
runBlocking {
- val api = apiPersistence
api.updateUpdatedTime(TimeSource.now(), "", 0)
api.updateUpdatedTime(TimeSource.now(), "", 0)
api.updateUpdatedTime(TimeSource.now(), "", 0)
@@ -22,19 +21,21 @@ class MongoAPIPersistenceTests : MongoTest() {
val stored = api.getUpdatedAt()
- Assertions.assertEquals(time, stored.time)
+ assertEquals(time, stored.time)
}
}
@Test
- fun `metadata is persisted`(apiPersistence: MongoApiPersistence) {
+ fun `metadata is persisted`() {
runBlocking {
+ val apiPersistence = MongoApiPersistence(MongoClient())
val metadata = GHReleaseMetadata(10, GitHubId("foo"))
apiPersistence.setGhReleaseMetadata(metadata)
val saved = apiPersistence.getGhReleaseMetadata(GitHubId("foo"))
+
assertEquals(metadata, saved)
}
}
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoTest.kt
index c823b2c99..7c1a6d854 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/MongoTest.kt
@@ -4,7 +4,6 @@ import de.flapdoodle.embed.mongo.config.Net
import de.flapdoodle.embed.mongo.distribution.Version
import de.flapdoodle.embed.mongo.transitions.Mongod
import de.flapdoodle.embed.mongo.transitions.RunningMongodProcess
-import de.flapdoodle.embed.process.runtime.Network
import de.flapdoodle.reverse.transitions.Start
import net.adoptium.api.testDoubles.UpdatableVersionSupplierStub
import net.adoptium.api.v3.dataSources.APIDataStoreImpl
@@ -34,12 +33,13 @@ abstract class MongoTest {
@JvmStatic
fun startFongo() {
val bindIp = "localhost"
- val net = Net.of("localhost",
- Network.freeServerPort(Network.getLocalHost()),
- Network.localhostIsIPv6()
- )
- val mongodbTestConnectionString = "mongodb://$bindIp:${net.port}"
+ val port = de.flapdoodle.net.Net.freeServerPort()
+
+ val net = Net.builder().bindIp(bindIp).port(port).isIpv6(false).build()
+
+ val mongodbTestConnectionString = "mongodb://$bindIp:$port"
+
LOGGER.info("Mongo test connection string - $mongodbTestConnectionString")
System.setProperty("MONGODB_TEST_CONNECTION_STRING", mongodbTestConnectionString)
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/UpdateRunner.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/UpdateRunner.kt
index 9c3c72f25..7f5c56121 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/UpdateRunner.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/UpdateRunner.kt
@@ -3,6 +3,7 @@ package net.adoptium.api
import kotlinx.coroutines.runBlocking
import net.adoptium.api.testDoubles.InMemoryInternalDbStore
import net.adoptium.api.v3.AdoptRepositoryImpl
+import net.adoptium.api.v3.ReleaseIncludeFilter
import net.adoptium.api.v3.V3Updater
import net.adoptium.api.v3.dataSources.DefaultUpdaterHtmlClient
import net.adoptium.api.v3.dataSources.HttpClientFactory
@@ -35,7 +36,7 @@ class UpdateRunner {
fun run(updater: V3Updater) {
System.clearProperty("GITHUB_TOKEN")
updater.run(false)
- Awaitility.await().atMost(Long.MAX_VALUE, TimeUnit.NANOSECONDS).until({ 4 == 5 })
+ Awaitility.await().atMost(Long.MAX_VALUE, TimeUnit.NANOSECONDS).until { 4 == 5 }
}
@Test
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/V3UpdaterTest.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/V3UpdaterTest.kt
index 852807df3..75997d588 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/V3UpdaterTest.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/V3UpdaterTest.kt
@@ -1,7 +1,8 @@
package net.adoptium.api
-import ReleaseIncludeFilter
+import net.adoptium.api.v3.ReleaseIncludeFilter
import kotlinx.coroutines.runBlocking
+import net.adoptium.api.v3.ReleaseFilterType
import net.adoptium.api.v3.TimeSource
import net.adoptium.api.v3.V3Updater
import net.adoptium.api.v3.dataSources.models.AdoptRepos
@@ -33,7 +34,7 @@ class V3UpdaterTest {
fun `adoptOpenJdk releases are copied over`() {
runBlocking {
- val repo = AdoptReposTestDataGenerator.generate();
+ val repo = AdoptReposTestDataGenerator.generate()
val filter = ReleaseIncludeFilter(
TimeSource.now(),
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/AdoptRepositoryStub.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/AdoptRepositoryStub.kt
index 82c1bb420..b08bd2477 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/AdoptRepositoryStub.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/AdoptRepositoryStub.kt
@@ -1,6 +1,6 @@
package net.adoptium.api.testDoubles
-import ReleaseIncludeFilter
+import net.adoptium.api.v3.ReleaseIncludeFilter
import jakarta.annotation.Priority
import jakarta.enterprise.context.ApplicationScoped
import jakarta.enterprise.inject.Alternative
@@ -49,7 +49,7 @@ open class AdoptRepositoryStub : AdoptRepository {
.addRelease(8, toAddSemiYoungRelease)
companion object {
- val unchangedIndex = 3
+ const val unchangedIndex = 3
val toAdd = Release(
"foo", ReleaseType.ga, "openjdk-8u", "jdk8u-2018-09-27-08-50",
diff --git a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/UpdatableVersionSupplierStub.kt b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/UpdatableVersionSupplierStub.kt
index f63238649..5e5db25c3 100644
--- a/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/UpdatableVersionSupplierStub.kt
+++ b/adoptium-updater-parent/adoptium-api-v3-updater/src/test/kotlin/net/adoptium/api/testDoubles/UpdatableVersionSupplierStub.kt
@@ -13,7 +13,7 @@ class UpdatableVersionSupplierStub : UpdatableVersionSupplier {
// NOP
}
- override fun getTipVersion(): Int? {
+ override fun getTipVersion(): Int {
return 15
}
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/pom.xml b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/pom.xml
index d4547cc4d..7b2a7360e 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/pom.xml
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/pom.xml
@@ -56,6 +56,21 @@
net.adoptium.api
adoptium-api-v3-persistence
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ ${kotlin.version}
+
+
+ org.jetbrains.kotlin
+ kotlin-test
+ ${kotlin.version}
+ test
+
+
+ jakarta.ws.rs
+ jakarta.ws.rs-api
+
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdaterJsonMapper.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdaterJsonMapper.kt
index 1a6bbaa20..27afdb0da 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdaterJsonMapper.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/UpdaterJsonMapper.kt
@@ -5,11 +5,21 @@ import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jsonp.JSONPModule
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.fasterxml.jackson.module.kotlin.KotlinModule
+import jakarta.ws.rs.Produces
+import jakarta.ws.rs.ext.Provider
-object UpdaterJsonMapper {
- val mapper: ObjectMapper = ObjectMapper()
- .setSerializationInclusion(JsonInclude.Include.NON_NULL)
- .registerModule(KotlinModule.Builder().build())
- .registerModule(JavaTimeModule())
- .registerModule(JSONPModule())
+@Provider
+class UpdaterJsonMapper {
+ companion object {
+ val mapper: ObjectMapper = ObjectMapper()
+ .setSerializationInclusion(JsonInclude.Include.NON_NULL)
+ .registerModule(KotlinModule.Builder().build())
+ .registerModule(JavaTimeModule())
+ .registerModule(JSONPModule())
+ }
+
+ @Produces
+ fun getObjectMapper(): ObjectMapper {
+ return mapper
+ }
}
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/GitHubAuth.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/GitHubAuth.kt
index 354b9187b..c4b129b08 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/GitHubAuth.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/GitHubAuth.kt
@@ -75,7 +75,7 @@ class GitHubAuth {
return token
}
- private suspend fun authenticateAsGitHubApp(appId: String, privateKey: String, installationId: String): GHAppInstallationToken {
+ private fun authenticateAsGitHubApp(appId: String, privateKey: String, installationId: String): GHAppInstallationToken {
try {
// Remove the first and last lines
val sanitizedKey = privateKey
@@ -101,7 +101,7 @@ class GitHubAuth {
.compact()
val gitHubApp: GitHub = GitHubBuilder().withJwtToken(jwtToken).build()
- val appInstallation: GHAppInstallation = gitHubApp.getApp().getInstallationById(installationId.toLong())
+ val appInstallation: GHAppInstallation = gitHubApp.app.getInstallationById(installationId.toLong())
return appInstallation.createToken().create()
} catch (e: Exception) {
LOGGER.error("Error authenticating as GitHub App", e)
@@ -110,5 +110,5 @@ class GitHubAuth {
}
}
- class FailedToAuthenticateException : Exception("Failed to authenticate to GitHub") {}
+ class FailedToAuthenticateException : Exception("Failed to authenticate to GitHub")
}
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt
index 11ada77b3..d17f0b0e1 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubInterface.kt
@@ -188,7 +188,7 @@ open class GraphQLGitHubInterface @Inject constructor(
}
} catch (e: MismatchedInputException) {
- return null;
+ return null
} catch (e: Exception) {
LOGGER.error("Query failed", e)
throw e
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubReleaseRequest.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubReleaseRequest.kt
index eff1d4cc1..05678ccad 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubReleaseRequest.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLGitHubReleaseRequest.kt
@@ -3,7 +3,6 @@ package net.adoptium.api.v3.dataSources.github.graphql.clients
import com.expediagroup.graphql.client.types.GraphQLClientRequest
import jakarta.enterprise.context.ApplicationScoped
import jakarta.inject.Inject
-import net.adoptium.api.v3.dataSources.UpdaterHtmlClient
import net.adoptium.api.v3.dataSources.github.graphql.models.GHAssets
import net.adoptium.api.v3.dataSources.github.graphql.models.GHRelease
import net.adoptium.api.v3.dataSources.github.graphql.models.PageInfo
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLRequestImpl.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLRequestImpl.kt
index ac2ea79f3..f044e55b6 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLRequestImpl.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/github/graphql/clients/GraphQLRequestImpl.kt
@@ -15,11 +15,10 @@ import java.net.URL
open class GraphQLRequestImpl : GraphQLRequest {
private val client: GraphQLKtorClient
- private val httpClient: HttpClient
+ private val httpClient: HttpClient = HttpClient()
val BASE_URL = "https://api.github.com/graphql"
init {
- httpClient = HttpClient()
client = GraphQLKtorClient(
url = URL(BASE_URL),
httpClient = httpClient,
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/mongo/InternalDbStore.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/mongo/InternalDbStore.kt
index dc9779039..13f3f1f48 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/mongo/InternalDbStore.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-github-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/mongo/InternalDbStore.kt
@@ -1,11 +1,13 @@
package net.adoptium.api.v3.dataSources.mongo
import com.mongodb.client.model.IndexOptions
-import com.mongodb.client.model.UpdateOptions
+import com.mongodb.client.model.ReplaceOptions
+import com.mongodb.kotlin.client.coroutine.MongoCollection
import jakarta.enterprise.context.ApplicationScoped
import jakarta.inject.Inject
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.Job
+import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import net.adoptium.api.v3.dataSources.persitence.mongo.MongoClient
@@ -13,7 +15,6 @@ import net.adoptium.api.v3.dataSources.persitence.mongo.MongoInterface
import org.bson.BsonDateTime
import org.bson.BsonDocument
import org.bson.Document
-import org.litote.kmongo.coroutine.CoroutineCollection
import java.time.ZonedDateTime
interface InternalDbStore {
@@ -24,27 +25,26 @@ interface InternalDbStore {
@ApplicationScoped
open class InternalDbStoreImpl @Inject constructor(mongoClient: MongoClient) : MongoInterface(), InternalDbStore {
- private val webCache: CoroutineCollection = createCollection(mongoClient.database, "web-cache")
+ private val webCache: MongoCollection = createCollection(mongoClient.getDatabase(), "web-cache")
init {
runBlocking {
- webCache.createIndex("""{"url":1}""", IndexOptions().background(true))
+ webCache.createIndex(Document.parse("""{"url":1}"""), IndexOptions().background(true))
}
}
override fun putCachedWebpage(url: String, lastModified: String?, date: ZonedDateTime, data: String?): Job {
return GlobalScope.launch {
- webCache.updateOne(
+ webCache.replaceOne(
Document("url", url),
CacheDbEntry(url, lastModified, date, data),
- UpdateOptions().upsert(true),
- false
+ ReplaceOptions().upsert(true)
)
}
}
override suspend fun getCachedWebpage(url: String): CacheDbEntry? {
- return webCache.findOne(Document("url", url))
+ return webCache.find(Document("url", url)).firstOrNull()
}
override suspend fun updateCheckedTime(url: String, dateTime: ZonedDateTime) {
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/pom.xml b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/pom.xml
index 5a60e7b12..026ca9380 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/pom.xml
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/pom.xml
@@ -70,6 +70,17 @@
github-api
1.323
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ ${kotlin.version}
+
+
+ org.jetbrains.kotlin
+ kotlin-test
+ ${kotlin.version}
+ test
+
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/DefaultUpdaterHtmlClient.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/DefaultUpdaterHtmlClient.kt
index 07e75b73e..9ca335361 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/DefaultUpdaterHtmlClient.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/DefaultUpdaterHtmlClient.kt
@@ -141,7 +141,7 @@ open class DefaultUpdaterHtmlClient @Inject constructor(
try {
LOGGER.debug("Getting ${request.url} ${request.lastModified}")
val response: HttpResponse = withTimeout(REQUEST_TIMEOUT) {
- suspendCoroutine { continuation ->
+ suspendCoroutine { continuation ->
getData(request, continuation, authInfo?.token)
}
}
diff --git a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/GitHubAuth.kt b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/GitHubAuth.kt
index c2cc24a74..0f5532943 100644
--- a/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/GitHubAuth.kt
+++ b/adoptium-updater-parent/adoptium-datasources-parent/adoptium-http-client-datasource/src/main/kotlin/net/adoptium/api/v3/dataSources/GitHubAuth.kt
@@ -73,7 +73,7 @@ class GitHubAuth {
return token
}
- private suspend fun authenticateAsGitHubApp(appId: String, privateKey: String, installationId: String): GHAppInstallationToken {
+ private fun authenticateAsGitHubApp(appId: String, privateKey: String, installationId: String): GHAppInstallationToken {
try {
// Remove the first and last lines
val sanitizedKey = privateKey
@@ -99,7 +99,7 @@ class GitHubAuth {
.compact()
val gitHubApp: GitHub = GitHubBuilder().withJwtToken(jwtToken).build()
- val appInstallation: GHAppInstallation = gitHubApp.getApp().getInstallationById(installationId.toLong())
+ val appInstallation: GHAppInstallation = gitHubApp.app.getInstallationById(installationId.toLong())
return appInstallation.createToken().create()
} catch (e: Exception) {
LOGGER.error("Error authenticating as GitHub App", e)
@@ -108,5 +108,5 @@ class GitHubAuth {
}
}
- class FailedToAuthenticateException : Exception("Failed to authenticate as GitHub App") {}
+ class FailedToAuthenticateException : Exception("Failed to authenticate as GitHub App")
}
diff --git a/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/pom.xml b/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/pom.xml
index 0cf0cc5c1..2e63a2388 100644
--- a/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/pom.xml
+++ b/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/pom.xml
@@ -22,11 +22,21 @@
adoptium-github-datasource
${project.version}
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ ${kotlin.version}
+
+
+ org.jetbrains.kotlin
+ kotlin-test
+ ${kotlin.version}
+ test
+
src/main/kotlin
- src/test/kotlin
diff --git a/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptBinaryMapper.kt b/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptBinaryMapper.kt
index adcac54d4..ab9dafe71 100644
--- a/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptBinaryMapper.kt
+++ b/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptBinaryMapper.kt
@@ -28,12 +28,13 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
companion object {
@JvmStatic
- private val LOGGER = LoggerFactory.getLogger(this::class.java)
+ private val LOGGER = LoggerFactory.getLogger(AdoptBinaryMapper::class.java)
private const val HOTSPOT_JFR = "hotspot-jfr"
private const val TEMURIN = "temurin"
+
+ private val EXCLUDED = listOf("corretto")
}
- private val EXCLUDED = listOf("corretto")
suspend fun toBinaryList(ghBinaryAssets: List, allGhAssets: List, ghAssetsWithMetadata: Map): List {
// probably whitelist rather than black list
@@ -55,9 +56,9 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
val binaryMetadata = ghAssetsWithMetadata[ghBinaryAsset]
- val heapSize = getEnumFromFileName(ghBinaryAsset.name, HeapSize.values(), HeapSize.normal)
+ val heapSize = getEnumFromFileName(ghBinaryAsset.name, HeapSize.entries.toTypedArray(), HeapSize.normal)
- val cLib = getEnumFromFileNameNullable(ghBinaryAsset.name, CLib.values(), null)
+ val cLib = getEnumFromFileNameNullable(ghBinaryAsset.name, CLib.entries.toTypedArray(), null)
val installer = getInstaller(ghBinaryAsset, allGhAssets)
val `package` = getPackage(allGhAssets, ghBinaryAsset, binaryMetadata)
@@ -90,13 +91,13 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
val binarySize = binaryAsset.size
val binaryChecksumLink = getCheckSumLink(fullAssetList, binaryName)
val signatureLink = getSignatureLink(fullAssetList, binaryAsset.name)
- val binaryChecksum: String?
- binaryChecksum = if (binaryMetadata != null && binaryMetadata.sha256.isNotEmpty()) {
- binaryMetadata.sha256
- } else {
- getChecksum(binaryChecksumLink)
- }
+ val binaryChecksum: String? =
+ if (binaryMetadata != null && binaryMetadata.sha256.isNotEmpty()) {
+ binaryMetadata.sha256
+ } else {
+ getChecksum(binaryChecksumLink)
+ }
val metadataLink = getMetadataLink(fullAssetList, binaryName)
@@ -115,7 +116,7 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
private suspend fun getInstaller(binaryAsset: GHAsset, fullAssetList: List): Installer? {
val nameWithoutExtension =
- BINARY_ASSET_WHITELIST.fold(binaryAsset.name, { assetName, extension -> assetName.replace(extension, "") })
+ BINARY_ASSET_WHITELIST.fold(binaryAsset.name) { assetName, extension -> assetName.replace(extension, "") }
val installer = fullAssetList
.filter { it.name.startsWith(nameWithoutExtension) }
@@ -171,10 +172,10 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
}
private fun removeExtensionFromName(binary_name: String): String {
- return BINARY_ASSET_WHITELIST.foldRight(binary_name, { extension, name -> name.removeSuffix(extension) })
+ return BINARY_ASSET_WHITELIST.foldRight(binary_name) { extension, name -> name.removeSuffix(extension) }
}
- private fun isBinaryAsset(asset: GHAsset) = ARCHIVE_WHITELIST.any { asset.name.endsWith(it) } || ( asset.name.endsWith(".json") && asset.name.contains("-sbom_") )
+ private fun isBinaryAsset(asset: GHAsset) = ARCHIVE_WHITELIST.any { asset.name.endsWith(it) } || (asset.name.endsWith(".json") && asset.name.contains("-sbom_"))
private fun binaryFromName(
asset: GHAsset,
@@ -186,11 +187,11 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
cLib: CLib?
): Binary {
val scmRef = null
- val os = getEnumFromFileName(asset.name, OperatingSystem.values())
- val architecture = getEnumFromFileName(asset.name, Architecture.values())
- val binaryType = getEnumFromFileName(asset.name, ImageType.values(), ImageType.jdk)
- val jvmImpl = getEnumFromFileName(asset.name, JvmImpl.values(), JvmImpl.hotspot)
- val project = getEnumFromFileName(asset.name, Project.values(), Project.jdk)
+ val os = getEnumFromFileName(asset.name, OperatingSystem.entries.toTypedArray())
+ val architecture = getEnumFromFileName(asset.name, Architecture.entries.toTypedArray())
+ val binaryType = getEnumFromFileName(asset.name, ImageType.entries.toTypedArray(), ImageType.jdk)
+ val jvmImpl = getEnumFromFileName(asset.name, JvmImpl.entries.toTypedArray(), JvmImpl.hotspot)
+ val project = getEnumFromFileName(asset.name, Project.entries.toTypedArray(), Project.jdk)
return Binary(
pack,
@@ -242,7 +243,7 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
private fun getImageType(asset: GHAsset, binaryMetadata: GHMetaData): ImageType {
// static-libs incorrectly labeled as JDK, if the name tells us it's a static-lib, trust that over the metadata file
- val binaryTypeFromName = getEnumFromFileName(asset.name, ImageType.values(), ImageType.jdk)
+ val binaryTypeFromName = getEnumFromFileName(asset.name, ImageType.entries.toTypedArray(), ImageType.jdk)
return if (binaryTypeFromName == ImageType.staticlibs) {
ImageType.staticlibs
} else {
@@ -271,7 +272,7 @@ class AdoptBinaryMapper @Inject constructor(private val gitHubHtmlClient: GitHub
private suspend fun getChecksum(binary_checksum_link: String?): String? {
try {
- if (!(binary_checksum_link == null || binary_checksum_link.isEmpty())) {
+ if (!binary_checksum_link.isNullOrEmpty()) {
LOGGER.debug("Pulling checksum for $binary_checksum_link")
val checksum = gitHubHtmlClient.getUrl(binary_checksum_link)
if (checksum != null) {
diff --git a/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptReleaseMapper.kt b/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptReleaseMapper.kt
index 6fa176ad8..036198742 100644
--- a/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptReleaseMapper.kt
+++ b/adoptium-updater-parent/adoptium-mappers-parent/adopt-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/adopt/AdoptReleaseMapper.kt
@@ -1,7 +1,7 @@
package net.adoptium.api.v3.mapping.adopt
import jakarta.enterprise.context.ApplicationScoped
-import jakarta.enterprise.inject.Model
+import jakarta.inject.Inject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import net.adoptium.api.v3.ReleaseResult
@@ -29,8 +29,6 @@ import java.security.MessageDigest
import java.time.ZonedDateTime
import java.util.*
import java.util.regex.Pattern
-import jakarta.inject.Inject
-import jakarta.inject.Singleton
@ApplicationScoped
open class AdoptReleaseMapperFactory @Inject constructor(
@@ -50,7 +48,7 @@ open class AdoptReleaseMapperFactory @Inject constructor(
}
}
-private class AdoptReleaseMapper constructor(
+private class AdoptReleaseMapper(
val adoptBinaryMapper: AdoptBinaryMapper,
val htmlClient: GitHubHtmlClient,
val vendor: Vendor
@@ -196,7 +194,7 @@ private class AdoptReleaseMapper constructor(
.filter { asset ->
BinaryMapper.BINARY_EXTENSIONS.any { asset.name.endsWith(it) }
}
- .map { it.downloadCount }.sum()
+ .sumOf { it.downloadCount }
return Release(
id,
diff --git a/adoptium-updater-parent/adoptium-mappers-parent/mappers-common/pom.xml b/adoptium-updater-parent/adoptium-mappers-parent/mappers-common/pom.xml
index a417251cf..7e38b04d3 100644
--- a/adoptium-updater-parent/adoptium-mappers-parent/mappers-common/pom.xml
+++ b/adoptium-updater-parent/adoptium-mappers-parent/mappers-common/pom.xml
@@ -25,6 +25,17 @@
net.adoptium.api
adoptium-api-v3-persistence
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ ${kotlin.version}
+
+
+ org.jetbrains.kotlin
+ kotlin-test
+ ${kotlin.version}
+ test
+
diff --git a/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/pom.xml b/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/pom.xml
index 2f37b8434..947da21dd 100644
--- a/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/pom.xml
+++ b/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/pom.xml
@@ -22,11 +22,21 @@
adoptium-github-datasource
${project.version}
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+ ${kotlin.version}
+
+
+ org.jetbrains.kotlin
+ kotlin-test
+ ${kotlin.version}
+ test
+
src/main/kotlin
- src/test/kotlin
diff --git a/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamBinaryMapper.kt b/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamBinaryMapper.kt
index e86868d2e..b7f427dcc 100644
--- a/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamBinaryMapper.kt
+++ b/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamBinaryMapper.kt
@@ -39,11 +39,11 @@ object UpstreamBinaryMapper : BinaryMapper() {
val signatureLink = getSignatureLink(assets, asset.name)
val pack = Package(asset.name, asset.downloadUrl, asset.size, null, null, asset.downloadCount, signatureLink, null)
- val os = getEnumFromFileName(asset.name, OperatingSystem.values())
- val architecture = getEnumFromFileName(asset.name, Architecture.values())
- val imageType = getEnumFromFileName(asset.name, ImageType.values(), ImageType.jdk)
+ val os = getEnumFromFileName(asset.name, OperatingSystem.entries.toTypedArray())
+ val architecture = getEnumFromFileName(asset.name, Architecture.entries.toTypedArray())
+ val imageType = getEnumFromFileName(asset.name, ImageType.entries.toTypedArray(), ImageType.jdk)
val updatedAt = getUpdatedTime(asset)
- val projectType = getEnumFromFileName(asset.name, Project.values(), Project.jdk)
+ val projectType = getEnumFromFileName(asset.name, Project.entries.toTypedArray(), Project.jdk)
Binary(
pack,
diff --git a/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamReleaseMapper.kt b/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamReleaseMapper.kt
index cc44380b8..77ce74687 100644
--- a/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamReleaseMapper.kt
+++ b/adoptium-updater-parent/adoptium-mappers-parent/upstream-mappers/src/main/kotlin/net/adoptium/api/v3/mapping/upstream/UpstreamReleaseMapper.kt
@@ -31,7 +31,7 @@ object UpstreamReleaseMapper : ReleaseMapper() {
.filter { asset ->
BinaryMapper.BINARY_EXTENSIONS.any { asset.name.endsWith(it) }
}
- .map { it.downloadCount }.sum()
+ .sumOf { it.downloadCount }
val vendor = Vendor.openjdk
diff --git a/pom.xml b/pom.xml
index cb7010c73..24fb632b3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
- 3.9.6
+ 3.9.8
@@ -19,7 +19,7 @@
0.8.12
17
17
- 1.9.23
+ 2.0.10
3.1.0
3.7.1
3.5.0
@@ -82,7 +82,7 @@
4.7.3
UTF-8
UTF-8
- 3.13.0
+ 3.13.2