Issue#31 Fix codeAnalysis errors

This commit is contained in:
Gergely Hegedus 2022-01-24 17:53:34 +02:00
parent b29870c90c
commit bc19355a70
3 changed files with 12 additions and 9 deletions

View file

@ -9,12 +9,6 @@ java {
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
} }
compileKotlin {
kotlinOptions {
freeCompilerArgs += ['-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi']
}
}
kapt { kapt {
correctErrorTypes = true correctErrorTypes = true
} }

View file

@ -8,6 +8,13 @@ subprojects { module ->
showStandardStreams true showStandardStreams true
} }
} }
module.tasks.configureEach { task ->
if (task.taskIdentity.type.toString() == "class org.jetbrains.kotlin.gradle.tasks.KotlinCompile") {
task.kotlinOptions {
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
}
}
} }
plugins.withId("com.android.application") { plugins.withId("com.android.application") {

View file

@ -1,8 +1,9 @@
package org.fnives.test.showcase.network.auth package org.fnives.test.showcase.network.auth
import com.squareup.moshi.JsonDataException import com.squareup.moshi.JsonDataException
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.runBlockingTest import kotlinx.coroutines.test.runTest
import okhttp3.internal.http.RealResponseBody import okhttp3.internal.http.RealResponseBody
import okio.Buffer import okio.Buffer
import org.fnives.test.showcase.model.session.Session import org.fnives.test.showcase.model.session.Session
@ -18,6 +19,7 @@ import retrofit2.Response
import java.io.IOException import java.io.IOException
@Suppress("TestFunctionName") @Suppress("TestFunctionName")
@OptIn(ExperimentalCoroutinesApi::class)
class LoginErrorConverterTest { class LoginErrorConverterTest {
private lateinit var sut: LoginErrorConverter private lateinit var sut: LoginErrorConverter
@ -49,7 +51,7 @@ class LoginErrorConverterTest {
@DisplayName("GIVEN 400 error response WHEN parsing login error THEN invalid credentials is returned") @DisplayName("GIVEN 400 error response WHEN parsing login error THEN invalid credentials is returned")
@Test @Test
fun code400ResponseResultsInInvalidCredentials() = runBlockingTest { fun code400ResponseResultsInInvalidCredentials() = runTest {
val expected = LoginStatusResponses.InvalidCredentials val expected = LoginStatusResponses.InvalidCredentials
val actual = sut.invoke { val actual = sut.invoke {
@ -62,7 +64,7 @@ class LoginErrorConverterTest {
@DisplayName("GIVEN successful response WHEN parsing login error THEN successful response is returned") @DisplayName("GIVEN successful response WHEN parsing login error THEN successful response is returned")
@Test @Test
fun successResponseResultsInSessionResponse() = runBlockingTest { fun successResponseResultsInSessionResponse() = runTest {
val loginResponse = LoginResponse("a", "r") val loginResponse = LoginResponse("a", "r")
val expectedSession = Session(accessToken = loginResponse.accessToken, refreshToken = loginResponse.refreshToken) val expectedSession = Session(accessToken = loginResponse.accessToken, refreshToken = loginResponse.refreshToken)
val expected = LoginStatusResponses.Success(expectedSession) val expected = LoginStatusResponses.Success(expectedSession)