diff --git a/flipt-client-kotlin-android/build.gradle b/flipt-client-kotlin-android/build.gradle index 15f9562d..bfc877d2 100644 --- a/flipt-client-kotlin-android/build.gradle +++ b/flipt-client-kotlin-android/build.gradle @@ -17,18 +17,16 @@ android { ndk { abiFilters "x86_64", "arm64-v8a" } + def fliptUrl = System.getenv("FLIPT_URL") ?: "" + def fliptAuthToken = System.getenv("FLIPT_AUTH_TOKEN") ?: "" + buildConfigField("String", "FLIPT_URL", "\"$fliptUrl\"") + buildConfigField("String", "FLIPT_AUTH_TOKEN", "\"$fliptAuthToken\"") } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - buildConfigField("String", "FLIPT_URL", "\"${System.getenv("FLIPT_URL") ?: ""}\"") - buildConfigField("String", "FLIPT_AUTH_TOKEN", "\"${System.getenv("FLIPT_AUTH_TOKEN") ?: ""}\"") - } - debug { - buildConfigField("String", "FLIPT_URL", "\"${System.getenv("FLIPT_URL") ?: ""}\"") - buildConfigField("String", "FLIPT_AUTH_TOKEN", "\"${System.getenv("FLIPT_AUTH_TOKEN") ?: ""}\"") } } compileOptions { @@ -53,4 +51,4 @@ dependencies { androidTestImplementation libs.androidx.junit androidTestImplementation libs.androidx.espresso.core implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20" -} \ No newline at end of file +} diff --git a/flipt-client-kotlin-android/src/androidTest/java/io/flipt/client/TestFliptEvaluationClient.kt b/flipt-client-kotlin-android/src/androidTest/java/io/flipt/client/TestFliptEvaluationClient.kt index e0fd0015..5850d731 100644 --- a/flipt-client-kotlin-android/src/androidTest/java/io/flipt/client/TestFliptEvaluationClient.kt +++ b/flipt-client-kotlin-android/src/androidTest/java/io/flipt/client/TestFliptEvaluationClient.kt @@ -6,7 +6,6 @@ import org.junit.After import org.junit.Before import org.junit.Test - class TestFliptEvaluationClient { private var fliptClient: FliptEvaluationClient? = null @@ -16,13 +15,16 @@ class TestFliptEvaluationClient { val fliptURL = BuildConfig.FLIPT_URL val clientToken = BuildConfig.FLIPT_AUTH_TOKEN + println("Using Flipt at: $fliptURL") assert(!fliptURL.isEmpty()) assert(!clientToken.isEmpty()) - fliptClient = FliptEvaluationClient.builder() - .url(url = fliptURL) - .namespace("default") - .authentication(ClientTokenAuthentication(clientToken)) - .build() + fliptClient = + FliptEvaluationClient + .builder() + .url(url = fliptURL) + .namespace("default") + .authentication(ClientTokenAuthentication(clientToken)) + .build() } @Test @@ -31,7 +33,7 @@ class TestFliptEvaluationClient { val context: MutableMap = HashMap() context["fizz"] = "buzz" - val response = fliptClient?.evaluateVariant("flag1", "entity", context) + val response = fliptClient?.evaluateVariant("flag1", "entity", context) assert("flag1" == response?.flagKey) assert(response?.match ?: false) @@ -59,11 +61,12 @@ class TestFliptEvaluationClient { val context: MutableMap = HashMap() context["fizz"] = "buzz" - val evalRequests: Array = arrayOf( - EvaluationRequest("flag1", "entity", context), - EvaluationRequest("flag_boolean", "entity", context), - EvaluationRequest("notfound", "entity", context) - ) + val evalRequests: Array = + arrayOf( + EvaluationRequest("flag1", "entity", context), + EvaluationRequest("flag_boolean", "entity", context), + EvaluationRequest("notfound", "entity", context), + ) val response = fliptClient?.evaluateBatch(evalRequests) @@ -71,7 +74,7 @@ class TestFliptEvaluationClient { val responses = response?.responses assert(responses?.get(0)?.variantEvaluationResponse != null) - val variantResponse = responses?.get(0)?.variantEvaluationResponse + val variantResponse = responses?.get(0)?.variantEvaluationResponse assert("flag1" == variantResponse?.flagKey) assert(variantResponse?.match ?: false) assert("MATCH_EVALUATION_REASON" == variantResponse?.reason) @@ -103,5 +106,4 @@ class TestFliptEvaluationClient { fun tearDownAll() { fliptClient?.close() } - }