diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2a24f0d..e31617cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,24 +10,24 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout the code to specific branch - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'zulu' java-version: '17' - name: Setup Android SDK - uses: android-actions/setup-android@v2 + uses: android-actions/setup-android@v3 - name: Cache Gradle packages - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: ${{ runner.os }}-gradle - name: Cache SonarQube packages - uses: actions/cache@v3 + uses: actions/cache@v4 if: github.ref_name == 'main' && github.event_name == 'push' with: path: ~/.sonar/cache @@ -42,7 +42,7 @@ jobs: run: ./gradlew build jacocoTestReport sonar - name: Upload build artifacts if: github.ref_name == 'main' && github.event_name == 'push' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: build path: app/build/outputs diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 3ef2a655..00000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: android -jdk: openjdk11 -android: - components: - # Uncomment the lines below if you want to - # use the latest revision of Android SDK Tools - # - platform-tools - # - tools - - # The BuildTools version used by your project - # - build-tools-30.0.3 - - # The SDK version used to compile your project - # - android-30 - - # Additional components - - extra-android-m2repository - - # Specify at least one system image, - # if you need to run emulator(s) during your tests - - sys-img-armeabi-v7a-android-31 - - sys-img-x86-android-31 -env: - global: - - TARGET_VERSION=33 - - ANDROID_BUILD_TOOLS_VERSION=33.0.2 - - ANDROID_HOME=~/android-sdk -before_install: - - touch $HOME/.android/repositories.cfg - - wget "https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip" -O commandlinetools.zip - - unzip commandlinetools.zip -d $ANDROID_HOME/ - - yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager "platforms;android-${TARGET_VERSION}" --sdk_root=$ANDROID_HOME - - yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager "build-tools;${ANDROID_BUILD_TOOLS_VERSION}" --sdk_root=$ANDROID_HOME -after_success: - - ./gradlew createDebugCoverageReport coveralls diff --git a/app/build.gradle b/app/build.gradle index 530ed750..b16f436e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,10 +10,10 @@ android { defaultConfig { applicationId "org.blitzortung.android.app" - minSdkVersion 19 + minSdkVersion 21 targetSdkVersion 34 - versionCode 318 - versionName '2.2.3' + versionCode 319 + versionName '2.2.4' multiDexEnabled false testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -26,8 +26,8 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { - // See bug https://github.com/vanniktech/gradle-android-junit-jacoco-plugin/issues/183 - testCoverageEnabled false + enableUnitTestCoverage true + enableAndroidTestCoverage false } } compileOptions { @@ -47,7 +47,6 @@ android { } } - buildToolsVersion = '33.0.2' useLibrary 'android.test.base' lint { abortOnError false @@ -59,12 +58,12 @@ android { namespace 'org.blitzortung.android.app' } -def dagger_version = '2.51' +def dagger_version = '2.51.1' dependencies { - implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'androidx.media:media:1.7.0' - implementation 'androidx.core:core-ktx:1.12.0' + implementation 'androidx.core:core-ktx:1.13.1' implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'androidx.work:work-runtime-ktx:2.9.0' implementation 'org.osmdroid:osmdroid-android:6.1.18' @@ -80,9 +79,9 @@ dependencies { testImplementation 'org.assertj:assertj-core:3.25.3' testImplementation 'io.mockk:mockk:1.13.10' testImplementation 'org.robolectric:robolectric:4.11.1' - testImplementation 'androidx.test:core:1.5.0' - androidTestImplementation 'androidx.test:runner:1.5.2' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + testImplementation 'androidx.test:core:1.6.1' + androidTestImplementation 'androidx.test:runner:1.6.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' } kapt.includeCompileClasspath = false diff --git a/app/src/main/java/org/blitzortung/android/app/Main.kt b/app/src/main/java/org/blitzortung/android/app/Main.kt index 5cf820b0..78d73276 100644 --- a/app/src/main/java/org/blitzortung/android/app/Main.kt +++ b/app/src/main/java/org/blitzortung/android/app/Main.kt @@ -83,6 +83,7 @@ import org.blitzortung.android.util.isAtLeast import org.osmdroid.config.Configuration import org.osmdroid.tileprovider.util.StorageUtils import org.osmdroid.util.GeoPoint +import java.util.concurrent.atomic.AtomicLong import javax.inject.Inject import kotlin.math.roundToInt @@ -94,6 +95,7 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener { private lateinit var strikeListOverlay: StrikeListOverlay private lateinit var ownLocationOverlay: OwnLocationOverlay private lateinit var fadeOverlay: FadeOverlay + private var currentSequenceNumber = AtomicLong() private var clearData: Boolean = false @@ -137,48 +139,57 @@ class Main : FragmentActivity(), OnSharedPreferenceChangeListener { is ResultEvent -> { statusComponent.indicateError(event.failed) - if (!event.failed) { - currentResult = event - - Log.d(LOG_TAG, "Main.onDataUpdate() $event") + if (!event.failed && event.sequenceNumber != null) { + val updatedSequenceNumber = + currentSequenceNumber.updateAndGet { previousSequenceNumber -> + if (previousSequenceNumber < event.sequenceNumber) event.sequenceNumber else previousSequenceNumber + } + if (updatedSequenceNumber == event.sequenceNumber) { + currentResult = event - val resultParameters = event.parameters + Log.d(LOG_TAG, "Main.onDataUpdate() $event") - clearDataIfRequested() + val resultParameters = event.parameters - val initializeOverlay = strikeListOverlay.parameters != resultParameters - with(strikeListOverlay) { - parameters = resultParameters - rasterParameters = event.rasterParameters - referenceTime = event.referenceTime - } + clearDataIfRequested() - if (event.updated >= 0 && !initializeOverlay) { - strikeListOverlay.expireStrikes() - } else { - strikeListOverlay.clear() - } + val initializeOverlay = strikeListOverlay.parameters != resultParameters + with(strikeListOverlay) { + parameters = resultParameters + rasterParameters = event.rasterParameters + referenceTime = event.referenceTime + } - if (event.strikes != null) { - val strikes = if (event.updated > 0 && !initializeOverlay) { - val size = event.strikes.size - event.strikes.subList(size - event.updated, size) + if (event.updated >= 0 && !initializeOverlay) { + strikeListOverlay.expireStrikes() } else { - event.strikes + strikeListOverlay.clear() + } + + if (event.strikes != null) { + val strikes = if (event.updated > 0 && !initializeOverlay) { + val size = event.strikes.size + event.strikes.subList(size - event.updated, size) + } else { + event.strikes + } + strikeListOverlay.addStrikes(strikes) } - strikeListOverlay.addStrikes(strikes) - } - binding.alertView.setColorHandler(strikeColorHandler, strikeListOverlay.parameters.intervalDuration) + binding.alertView.setColorHandler( + strikeColorHandler, + strikeListOverlay.parameters.intervalDuration + ) - strikeListOverlay.refresh() - mapFragment.mapView.invalidate() + strikeListOverlay.refresh() + mapFragment.mapView.invalidate() - binding.legendView.requestLayout() - binding.timeSlider.update(event.parameters, event.history!!) + binding.legendView.requestLayout() + binding.timeSlider.update(event.parameters, event.history!!) - if (event.flags.mode == Mode.ANIMATION || !event.containsRealtimeData()) { - setHistoricStatusString() + if (event.flags.mode == Mode.ANIMATION || !event.containsRealtimeData()) { + setHistoricStatusString() + } } } diff --git a/app/src/main/java/org/blitzortung/android/data/MainDataHandler.kt b/app/src/main/java/org/blitzortung/android/data/MainDataHandler.kt index b568c700..e6599b4f 100644 --- a/app/src/main/java/org/blitzortung/android/data/MainDataHandler.kt +++ b/app/src/main/java/org/blitzortung/android/data/MainDataHandler.kt @@ -49,6 +49,7 @@ import org.osmdroid.events.MapListener import org.osmdroid.events.ScrollEvent import org.osmdroid.events.ZoomEvent import java.util.Locale +import java.util.concurrent.atomic.AtomicLong import javax.inject.Inject import javax.inject.Singleton import kotlin.properties.Delegates @@ -76,6 +77,7 @@ class MainDataHandler @Inject constructor( private set private var period: Int = 0 + private var sequenceNumber = AtomicLong() private var dataProvider: DataProvider? = null @@ -155,12 +157,13 @@ class MainDataHandler @Inject constructor( private fun updateUsingCache() { var flags = Flags(mode = mode) + val sequenceNumber = sequenceNumber.incrementAndGet() val parameters = activeParameters val cachedResult = cache.get(parameters) if (cachedResult != null) { Log.d(LOG_TAG, "MainDataHandler.updateData() cached $parameters") - sendEvent(cachedResult) + sendEvent(cachedResult.copy(sequenceNumber = sequenceNumber)) } else { Log.d(LOG_TAG, "MainDataHandler.updateData() fetch $parameters") FetchDataTask(dataMode, dataProvider!!, { @@ -174,7 +177,7 @@ class MainDataHandler @Inject constructor( if (!it.containsRealtimeData()) { cache.put(event.parameters, event) } - sendEvent(event) + sendEvent(event.copy(sequenceNumber = sequenceNumber)) }, ::toast).execute(parameters = parameters, history = history) } } diff --git a/app/src/main/java/org/blitzortung/android/data/cache/DataCache.kt b/app/src/main/java/org/blitzortung/android/data/cache/DataCache.kt index 3a55d28e..4cd00a6a 100644 --- a/app/src/main/java/org/blitzortung/android/data/cache/DataCache.kt +++ b/app/src/main/java/org/blitzortung/android/data/cache/DataCache.kt @@ -23,7 +23,7 @@ class DataCache @Inject constructor() { } fun put(parameters: Parameters, dataEvent: ResultEvent) { - cache[parameters] = Timestamped(dataEvent) + cache[parameters] = Timestamped(dataEvent.copy(sequenceNumber = null)) } fun calculateTotalSize(): CacheSize = cache.entries.fold(CacheSize(0, 0)) { acc, entry -> diff --git a/app/src/main/java/org/blitzortung/android/data/provider/result/ResultEvent.kt b/app/src/main/java/org/blitzortung/android/data/provider/result/ResultEvent.kt index a855a407..2f0af790 100644 --- a/app/src/main/java/org/blitzortung/android/data/provider/result/ResultEvent.kt +++ b/app/src/main/java/org/blitzortung/android/data/provider/result/ResultEvent.kt @@ -36,7 +36,8 @@ data class ResultEvent( val referenceTime: Long = 0, val parameters: Parameters, val history: History? = null, - val flags: Flags + val flags: Flags, + val sequenceNumber: Long? = null, ) : DataEvent, Serializable { fun containsRealtimeData(): Boolean { diff --git a/app/src/main/java/org/blitzortung/android/data/provider/standard/DataBuilder.kt b/app/src/main/java/org/blitzortung/android/data/provider/standard/DataBuilder.kt index 26206d98..6a40873c 100644 --- a/app/src/main/java/org/blitzortung/android/data/provider/standard/DataBuilder.kt +++ b/app/src/main/java/org/blitzortung/android/data/provider/standard/DataBuilder.kt @@ -35,7 +35,6 @@ internal class DataBuilder { lateralError = jsonArray.getDouble(3), altitude = 0, amplitude = jsonArray.getDouble(4).toFloat(), - stationCount = jsonArray.getInt(5).toShort() ) } catch (e: JSONException) { throw IllegalStateException("error with JSON format while parsing strike data", e) diff --git a/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcData.kt b/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcData.kt index 198211af..ee02bfe8 100644 --- a/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcData.kt +++ b/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcData.kt @@ -4,6 +4,7 @@ import org.blitzortung.android.data.Parameters import org.blitzortung.android.data.provider.GLOBAL_REGION import org.blitzortung.android.data.provider.LOCAL_REGION import org.blitzortung.android.jsonrpc.JsonRpcClient +import org.blitzortung.android.jsonrpc.JsonRpcResponse import org.json.JSONObject import java.net.URL @@ -12,7 +13,7 @@ class JsonRpcData( private val serviceUrl: URL, ) { - fun requestData(parameters: Parameters) : JSONObject { + fun requestData(parameters: Parameters) : JsonRpcResponse { val intervalDuration = parameters.intervalDuration val intervalOffset = parameters.intervalOffset val rasterBaselength = parameters.rasterBaselength @@ -22,19 +23,21 @@ class JsonRpcData( return when (region) { GLOBAL_REGION -> { + val jsonRpcResponse: JsonRpcResponse = client.call( + serviceUrl, + "get_global_strikes_grid", + intervalDuration, + rasterBaselength, + intervalOffset, + countThreshold + ) with( - client.call( - serviceUrl, - "get_global_strikes_grid", - intervalDuration, - rasterBaselength, - intervalOffset, - countThreshold - ) + jsonRpcResponse ) { - put("y1", 0.0) - put("x0", 0.0) + data.put("y1", 0.0) + data.put("x0", 0.0) } + jsonRpcResponse } LOCAL_REGION -> { client.call( diff --git a/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProvider.kt b/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProvider.kt index ed8e4bda..82d343ce 100644 --- a/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProvider.kt +++ b/app/src/main/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProvider.kt @@ -35,6 +35,7 @@ import org.blitzortung.android.data.provider.data.DataProvider.DataRetriever import org.blitzortung.android.data.provider.data.initializeResult import org.blitzortung.android.data.provider.result.ResultEvent import org.blitzortung.android.jsonrpc.JsonRpcClient +import org.blitzortung.android.jsonrpc.JsonRpcResponse import org.blitzortung.android.util.TimeFormat import org.json.JSONArray import org.json.JSONException @@ -70,25 +71,25 @@ class JsonRpcDataProvider @Inject constructor( } @Throws(JSONException::class) - private fun addStrikes(response: JSONObject, result: ResultEvent): ResultEvent { + private fun addStrikes(response: JsonRpcResponse, result: ResultEvent): ResultEvent { val isIncremental = nextId != 0 val strikes = ArrayList() - val referenceTimestamp = getReferenceTimestamp(response) - val strikesArray = response.get("s") as JSONArray + val referenceTimestamp = getReferenceTimestamp(response.data) + val strikesArray = response.data.get("s") as JSONArray for (i in 0 until strikesArray.length()) { strikes.add(dataBuilder.createDefaultStrike(referenceTimestamp, strikesArray.getJSONArray(i))) } - if (response.has("next")) { - nextId = response.get("next") as Int + if (response.data.has("next")) { + nextId = response.data.get("next") as Int } return result.copy(strikes = strikes, updated = if (isIncremental) strikes.size else -1) } - private fun addRasterData(response: JSONObject, result: ResultEvent, baselength: Int): ResultEvent { - val rasterParameters = dataBuilder.createRasterParameters(response, baselength) - val referenceTimestamp = getReferenceTimestamp(response) + private fun addRasterData(response: JsonRpcResponse, result: ResultEvent, baselength: Int): ResultEvent { + val rasterParameters = dataBuilder.createRasterParameters(response.data, baselength) + val referenceTimestamp = getReferenceTimestamp(response.data) - val strikesArray = response.get("r") as JSONArray + val strikesArray = response.data.get("r") as JSONArray val strikes = ArrayList() for (i in 0 until strikesArray.length()) { strikes.add( @@ -135,7 +136,7 @@ class JsonRpcDataProvider @Inject constructor( try { val response = client.call(serviceUrl, "get_stations") - val stationsArray = response.get("stations") as JSONArray + val stationsArray = response.data.get("stations") as JSONArray for (i in 0 until stationsArray.length()) { stations.add(dataBuilder.createStation(stationsArray.getJSONArray(i))) @@ -155,7 +156,7 @@ class JsonRpcDataProvider @Inject constructor( try { val response = JsonRpcData(client, serviceUrl).requestData(parameters) result = addRasterData(response, result, parameters.rasterBaselength) - result = addStrikesHistogram(response, result) + result = addStrikesHistogram(response.data, result) } catch (e: Exception) { throw RuntimeException(e) } @@ -189,7 +190,7 @@ class JsonRpcDataProvider @Inject constructor( ) result = addStrikes(response, result) - result = addStrikesHistogram(response, result) + result = addStrikesHistogram(response.data, result) } catch (e: Exception) { throw RuntimeException(e) } diff --git a/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClient.kt b/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClient.kt index 489b9a5f..3be15cfe 100644 --- a/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClient.kt +++ b/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClient.kt @@ -20,8 +20,12 @@ package org.blitzortung.android.jsonrpc import java.net.URL +data class HttpServiceClientResult( + val body: String, +) + interface HttpServiceClient { - fun doRequest(baseUrl: URL, data: String): String + fun doRequest(baseUrl: URL, data: String): HttpServiceClientResult var socketTimeout: Int var connectionTimeout: Int } diff --git a/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefault.kt b/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefault.kt index 9886f518..8a8862d2 100644 --- a/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefault.kt +++ b/app/src/main/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefault.kt @@ -18,6 +18,8 @@ package org.blitzortung.android.jsonrpc +import android.util.Log +import org.blitzortung.android.app.Main import java.io.InputStreamReader import java.net.HttpURLConnection import java.net.URL @@ -34,7 +36,7 @@ class HttpServiceClientDefault @Inject constructor( override var socketTimeout = 0 override var connectionTimeout = 0 - override fun doRequest(baseUrl: URL, data: String): String { + override fun doRequest(baseUrl: URL, data: String): HttpServiceClientResult { val connection = baseUrl.openConnection() as HttpURLConnection connection.requestMethod = "POST" @@ -61,6 +63,8 @@ class HttpServiceClientDefault @Inject constructor( // Do not disconnect the connection here as it will be potentially reused - return InputStreamReader(inputStream, "UTF-8").use { it.readText() } + return HttpServiceClientResult( + body = InputStreamReader(inputStream, "UTF-8").use { it.readText() }, + ) } } diff --git a/app/src/main/java/org/blitzortung/android/jsonrpc/JsonRpcClient.kt b/app/src/main/java/org/blitzortung/android/jsonrpc/JsonRpcClient.kt index f59e6b8c..9d4d27b9 100644 --- a/app/src/main/java/org/blitzortung/android/jsonrpc/JsonRpcClient.kt +++ b/app/src/main/java/org/blitzortung/android/jsonrpc/JsonRpcClient.kt @@ -24,6 +24,10 @@ import java.net.URL import javax.inject.Inject import javax.inject.Singleton +data class JsonRpcResponse( + val data: JSONObject, +) + @Singleton class JsonRpcClient @Inject constructor(client: HttpServiceClientDefault) : HttpServiceClient by client { @@ -53,15 +57,17 @@ class JsonRpcClient @Inject constructor(client: HttpServiceClientDefault) : Http return requestObject.toString() } - fun call(baseUrl: URL, methodName: String, vararg parameters: Any): JSONObject { + fun call(baseUrl: URL, methodName: String, vararg parameters: Any): JsonRpcResponse { val response = doRequest(baseUrl, buildRequest(methodName, parameters)) - lastNumberOfTransferredBytes = response.length + lastNumberOfTransferredBytes = response.body.length - return if (response.startsWith("[")) { - JSONArray(response).getJSONObject(0) + return if (response.body.startsWith("[")) { + JsonRpcResponse( + data= JSONArray(response.body).getJSONObject(0), + ) } else { - val responseObject = JSONObject(response) + val responseObject = JSONObject(response.body) if (responseObject.has("fault")) { throw JsonRpcException( @@ -71,7 +77,9 @@ class JsonRpcClient @Inject constructor(client: HttpServiceClientDefault) : Http ) ) } - responseObject + JsonRpcResponse( + data= responseObject, + ) } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 46173c4c..e3c2b028 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,7 +28,7 @@ Polish by Jakub Świątkiewicz (kuba.dex@gmail.com), Agnieszka Cieślak (aga_04@ Italian by Michele Locati (michele@locati.it)\n Russian by Ivan Karev (karev.ivan@gmail.com)\n - © 2011–2023, Andreas Würl + © 2011–2024, Andreas Würl blitzortung@tryb.de Legend Grid diff --git a/app/src/test/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProviderTest.kt b/app/src/test/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProviderTest.kt index 5d696121..0f72bd41 100644 --- a/app/src/test/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProviderTest.kt +++ b/app/src/test/java/org/blitzortung/android/data/provider/standard/JsonRpcDataProviderTest.kt @@ -17,6 +17,7 @@ import org.blitzortung.android.data.provider.GLOBAL_REGION import org.blitzortung.android.data.provider.LOCAL_REGION import org.blitzortung.android.data.provider.result.ResultEvent import org.blitzortung.android.jsonrpc.JsonRpcClient +import org.blitzortung.android.jsonrpc.JsonRpcResponse import org.json.JSONArray import org.json.JSONObject import org.junit.Before @@ -76,7 +77,7 @@ class JsonRpcDataProviderTest { parameters.intervalOffset, parameters.countThreshold ) - } returns response + } returns JsonRpcResponse(response) val result: ResultEvent = uut.retrieveData { getStrikesGrid(parameters, history, flags) } @@ -125,7 +126,7 @@ class JsonRpcDataProviderTest { parameters.intervalOffset, parameters.countThreshold ) - } returns response + } returns JsonRpcResponse(response) val result: ResultEvent = uut.retrieveData { getStrikesGrid(parameters, history, flags) } @@ -173,7 +174,7 @@ class JsonRpcDataProviderTest { parameters.region, parameters.countThreshold ) - } returns response + } returns JsonRpcResponse(response) val result: ResultEvent = uut.retrieveData { getStrikesGrid(parameters, history, flags) } diff --git a/app/src/test/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefaultTest.kt b/app/src/test/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefaultTest.kt index bc1f0e4f..cd866d6c 100644 --- a/app/src/test/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefaultTest.kt +++ b/app/src/test/java/org/blitzortung/android/jsonrpc/HttpServiceClientDefaultTest.kt @@ -51,7 +51,7 @@ class HttpServiceClientDefaultTest { ) assertThat(handler.connection.outputStream.toString("UTF-8")).isEqualTo(data) - assertThat(response).isEqualTo(responseValue) + assertThat(response.body).isEqualTo(responseValue) } @Test @@ -69,7 +69,7 @@ class HttpServiceClientDefaultTest { val response = uut.doRequest(URL("http://base.url"), data) assertThat(handler.connection.outputStream.toString("UTF-8")).isEqualTo(data) - assertThat(response).isEqualTo(responseValue) + assertThat(response.body).isEqualTo(responseValue) } } diff --git a/app/src/test/java/org/blitzortung/android/jsonrpc/JsonRpcClientTest.kt b/app/src/test/java/org/blitzortung/android/jsonrpc/JsonRpcClientTest.kt index 4285fb65..61305fa6 100644 --- a/app/src/test/java/org/blitzortung/android/jsonrpc/JsonRpcClientTest.kt +++ b/app/src/test/java/org/blitzortung/android/jsonrpc/JsonRpcClientTest.kt @@ -31,14 +31,14 @@ class JsonRpcClientTest { @Test fun callReturnsArray() { val response = "[{\"foo\": \"bar\"}]" - every { httpClient.doRequest(any(), any()) } answers { response } + every { httpClient.doRequest(any(), any()) } answers { HttpServiceClientResult(response) } val baseUrl = URL("http://base.url/") val methodName = "" - val result: JSONObject = uut.call(baseUrl, methodName) + val result: JsonRpcResponse = uut.call(baseUrl, methodName) - assertThat(result.length()).isEqualTo(1) - assertThat(result.get("foo")).isEqualTo("bar") + assertThat(result.data.length()).isEqualTo(1) + assertThat(result.data.get("foo")).isEqualTo("bar") val params = JSONObject(mapOf(Pair("id", 0), Pair("method", methodName), Pair("params", JSONArray()))) verify { httpClient.doRequest(baseUrl, params.toString()) } @@ -49,14 +49,14 @@ class JsonRpcClientTest { @Test fun callReturnsObject() { val response = "{\"foo\": \"bar\"}" - every { httpClient.doRequest(any(), any()) } answers { response } + every { httpClient.doRequest(any(), any()) } answers { HttpServiceClientResult(response) } val baseUrl = URL("http://base.url/") val methodName = "" - val result: JSONObject = uut.call(baseUrl, methodName) + val result: JsonRpcResponse = uut.call(baseUrl, methodName) - assertThat(result.length()).isEqualTo(1) - assertThat(result.get("foo")).isEqualTo("bar") + assertThat(result.data.length()).isEqualTo(1) + assertThat(result.data.get("foo")).isEqualTo("bar") val params = JSONObject(mapOf(Pair("id", 0), Pair("method", methodName), Pair("params", JSONArray()))) verify { httpClient.doRequest(baseUrl, params.toString()) } @@ -71,7 +71,7 @@ class JsonRpcClientTest { any(), any() ) - } answers { "{\"fault\":true,\"faultString\": \"foo\",\"faultCode\":\"1234\"}" } + } answers { HttpServiceClientResult("{\"fault\":true,\"faultString\": \"foo\",\"faultCode\":\"1234\"}") } val baseUrl = URL("http://base.url/") val methodName = "" diff --git a/build.gradle b/build.gradle index 77210250..1a54d3b3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.3.1' apply false - id 'com.android.library' version '8.3.1' apply false + id 'com.android.application' version '8.5.0' apply false + id 'com.android.library' version '8.5.0' apply false id 'org.jetbrains.kotlin.android' version '1.9.23' apply false id "org.sonarqube" version "3.5.0.2730" } @@ -12,6 +12,6 @@ task clean(type: Delete) { sonar { properties { - property "sonar.projectKey", "wuan_bo-android_AYcZZuyTg4e1BA2WvQjK" + property "sonar.projectKey", "bo-android" } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4d6272d9..45181329 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip