Skip to content

Commit

Permalink
Merge pull request #379 from RADAR-base/release-0.8.10
Browse files Browse the repository at this point in the history
Release 0.8.10
  • Loading branch information
Bdegraaf1234 committed Jun 12, 2024
2 parents d224854 + 1041404 commit fc2972e
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 23 deletions.
20 changes: 10 additions & 10 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
indent_size = 4

# Markdown
[*.md]
trim_trailing_whitespace = false
[{*.yml, *.yaml}]
indent_size = 2

# Gradle
[*.gradle]
indent_size = 4

# Java
[*.{java,kt,kts}]
indent_size = 4
continuation_indent_size = 8
[*.{kt,kts}]
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_allow_trailing_comma = true
# To satisfy ktlint rules, see: https://stackoverflow.com/questions/59849619/intellij-does-not-sort-kotlin-imports-according-to-ktlints-expectations
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^
12 changes: 9 additions & 3 deletions java-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ val githubIssueUrl = "https://github.com/$githubRepoName/issues"
subprojects {
apply(plugin = "org.radarbase.radar-kotlin")

repositories{
mavenCentral()
gradlePluginPortal()
maven(url = "https://jitpack.io")
}

radarKotlin {
javaVersion.set(Versions.java)
kotlinVersion.set(Versions.kotlin)
Expand Down Expand Up @@ -64,9 +70,9 @@ configure(listOf(
githubUrl.set("https://github.com/$githubRepoName")
developers {
developer {
id.set("blootsvoets")
name.set("Joris Borgdorff")
email.set("joris@thehyve.nl")
id.set("bdegraaf1234")
name.set("Bastiaan de Graaf")
email.set("bastiaan@thehyve.nl")
organization.set("The Hyve")
}
developer {
Expand Down
2 changes: 1 addition & 1 deletion java-sdk/buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Versions {
const val project = "0.8.9"
const val project = "0.8.10"

const val kotlin = "1.9.10"
const val java = 17
Expand Down
5 changes: 1 addition & 4 deletions java-sdk/radar-schemas-registration/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
description = "RADAR Schemas specification and validation tools"

repositories {
maven(url = "https://jitpack.io")
}

dependencies {
api(project(":radar-schemas-commons"))
api(project(":radar-schemas-core"))
Expand All @@ -17,4 +13,5 @@ dependencies {

implementation("org.apache.kafka:connect-json:${Versions.kafka}")
implementation("io.ktor:ktor-client-auth:${Versions.ktor}")
testImplementation("com.squareup.okhttp3:mockwebserver:${Versions.okHttp}")
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.radarbase.schema.registration

import io.ktor.client.HttpClient
import io.ktor.client.engine.cio.CIO
import io.ktor.client.plugins.auth.Auth
import io.ktor.client.plugins.auth.providers.BasicAuthCredentials
import io.ktor.client.plugins.auth.providers.basic
Expand Down Expand Up @@ -62,7 +64,7 @@ class SchemaRegistry(
private val topicConfiguration: Map<String, TopicConfig> = emptyMap(),
) {
private val schemaClient: SchemaRetriever = schemaRetriever(baseUrl) {
httpClient {
httpClient = HttpClient(CIO) {
timeout(10.seconds)
if (apiKey != null && apiSecret != null) {
install(Auth) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.radarbase.schema.registration

import io.ktor.http.HttpHeaders
import kotlinx.coroutines.runBlocking
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.radarbase.schema.registration.SchemaRegistry.Compatibility.FORWARD
import org.radarbase.topic.AvroTopic
import org.radarcns.kafka.ObservationKey
import org.radarcns.passive.phone.PhoneAcceleration

class SchemaRegistryTest {
private var server = MockWebServer()
private val expectedAuthHeader = "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
lateinit var schemaRegistry: SchemaRegistry

@BeforeEach
fun setUpClass() {
schemaRegistry = SchemaRegistry(
server.url("/").toString(),
"username",
"password",
)

val mockresponse =
MockResponse()
.setHeader(HttpHeaders.ContentType, "application/json")
.setBody(
"""
{
"id": 1
}
""".trimIndent(),
)

server.enqueue(mockresponse)
server.enqueue(mockresponse)
}

@AfterEach
fun tearDown() {
server.shutdown()
}

@Test
fun registerSchema() {
// Create an instance of AvroTopic
val avroTopic = AvroTopic(
"test",
ObservationKey.getClassSchema(),
PhoneAcceleration.getClassSchema(),
ObservationKey::class.java,
PhoneAcceleration::class.java,
)

runBlocking {
// Register the schema
schemaRegistry.registerSchema(avroTopic)

// Get the request that was received by the MockWebServer
val request = server.takeRequest()

// Verify the Basic Auth credentials
val authHeader = request.getHeader("Authorization")
assertEquals(expectedAuthHeader, authHeader)
}
}

@Test
fun putCompatibility() {
runBlocking {
// Register the schema
schemaRegistry.putCompatibility(compatibility = FORWARD)

// Get the request that was received by the MockWebServer
val request = server.takeRequest()

// Verify the Basic Auth credentials
val authHeader = request.getHeader("Authorization")
assertEquals(expectedAuthHeader, authHeader)
}
}
}
4 changes: 0 additions & 4 deletions java-sdk/radar-schemas-tools/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
description = "RADAR Schemas specification and validation tools."

repositories {
maven(url = "https://jitpack.io")
}

dependencies {
implementation(project(":radar-schemas-registration"))
implementation(platform("com.fasterxml.jackson:jackson-bom:${Versions.jackson}"))
Expand Down

0 comments on commit fc2972e

Please sign in to comment.