Skip to content

Commit

Permalink
Set up proper toString() values where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbrooks12 committed Aug 23, 2023
1 parent 1c44b3a commit eb6461c
Show file tree
Hide file tree
Showing 55 changed files with 1,391 additions and 40 deletions.
1 change: 1 addition & 0 deletions ballast-analytics/api/android/ballast-analytics.api
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public final class com/copperleaf/ballast/analytics/AnalyticsInterceptor : com/c
public fun <init> (Lcom/copperleaf/ballast/analytics/AnalyticsTracker;Lkotlin/jvm/functions/Function1;)V
public fun getKey ()Lcom/copperleaf/ballast/BallastInterceptor$Key;
public fun start (Lcom/copperleaf/ballast/BallastInterceptorScope;Lkotlinx/coroutines/flow/Flow;)V
public fun toString ()Ljava/lang/String;
}

public abstract interface class com/copperleaf/ballast/analytics/AnalyticsTracker {
Expand Down
1 change: 1 addition & 0 deletions ballast-analytics/api/jvm/ballast-analytics.api
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public final class com/copperleaf/ballast/analytics/AnalyticsInterceptor : com/c
public fun <init> (Lcom/copperleaf/ballast/analytics/AnalyticsTracker;Lkotlin/jvm/functions/Function1;)V
public fun getKey ()Lcom/copperleaf/ballast/BallastInterceptor$Key;
public fun start (Lcom/copperleaf/ballast/BallastInterceptorScope;Lkotlinx/coroutines/flow/Flow;)V
public fun toString ()Ljava/lang/String;
}

public abstract interface class com/copperleaf/ballast/analytics/AnalyticsTracker {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,8 @@ public class AnalyticsInterceptor<Inputs : Any, Events : Any, State : Any>(
.collect()
}
}

override fun toString(): String {
return "AnalyticsInterceptor(tracker=$tracker)"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.copperleaf.ballast.analytics

import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe

class BallastAnalyticsTests : StringSpec({
"check toString values" {
AnalyticsInterceptor<Any, Any, Any>(
tracker = TestAnalyticsTracker(),
shouldTrackInput = { true },
).toString() shouldBe "AnalyticsInterceptor(tracker=TestAnalyticsTracker)"
}
})

private class TestAnalyticsTracker : AnalyticsTracker {
override fun trackAnalyticsEvent(eventId: String, eventParameters: Map<String, String>) {
TODO("Not yet implemented")
}

override fun toString(): String {
return "TestAnalyticsTracker"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public final class com/copperleaf/ballast/crashreporting/CrashReportingIntercept
public fun <init> (Lcom/copperleaf/ballast/crashreporting/CrashReporter;Lkotlin/jvm/functions/Function1;)V
public fun getKey ()Lcom/copperleaf/ballast/BallastInterceptor$Key;
public fun start (Lcom/copperleaf/ballast/BallastInterceptorScope;Lkotlinx/coroutines/flow/Flow;)V
public fun toString ()Ljava/lang/String;
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public final class com/copperleaf/ballast/crashreporting/CrashReportingIntercept
public fun <init> (Lcom/copperleaf/ballast/crashreporting/CrashReporter;Lkotlin/jvm/functions/Function1;)V
public fun getKey ()Lcom/copperleaf/ballast/BallastInterceptor$Key;
public fun start (Lcom/copperleaf/ballast/BallastInterceptorScope;Lkotlinx/coroutines/flow/Flow;)V
public fun toString ()Ljava/lang/String;
}

Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,8 @@ public class CrashReportingInterceptor<Inputs : Any, Events : Any, State : Any>(
.collect()
}
}

override fun toString(): String {
return "CrashReportingInterceptor(crashReporter=$crashReporter)"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.copperleaf.ballast.crashreporting

import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe

class BallastCrashReportingTests : StringSpec({
"check toString values" {
CrashReportingInterceptor<Any, Any, Any>(
crashReporter = TestCrashReporter(),
shouldTrackInput = { true },
).toString() shouldBe "CrashReportingInterceptor(crashReporter=TestCrashReporter)"
}
})

private class TestCrashReporter : CrashReporter {
override fun logInput(viewModelName: String, input: Any) {
TODO("Not yet implemented")
}

override fun recordInputError(viewModelName: String, input: Any, throwable: Throwable) {
TODO("Not yet implemented")
}

override fun recordEventError(viewModelName: String, event: Any, throwable: Throwable) {
TODO("Not yet implemented")
}

override fun recordSideJobError(viewModelName: String, key: String, throwable: Throwable) {
TODO("Not yet implemented")
}

override fun recordUnhandledError(viewModelName: String, throwable: Throwable) {
TODO("Not yet implemented")
}

override fun toString(): String {
return "TestCrashReporter"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class com/copperleaf/ballast/debugger/BallastDebuggerInterceptor :
public synthetic fun <init> (Lcom/copperleaf/ballast/debugger/BallastDebuggerClientConnection;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getKey ()Lcom/copperleaf/ballast/BallastInterceptor$Key;
public fun start (Lcom/copperleaf/ballast/BallastInterceptorScope;Lkotlinx/coroutines/flow/Flow;)V
public fun toString ()Ljava/lang/String;
}

public final class com/copperleaf/ballast/debugger/BallastDebuggerInterceptor$Companion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public final class com/copperleaf/ballast/debugger/BallastDebuggerInterceptor :
public synthetic fun <init> (Lcom/copperleaf/ballast/debugger/BallastDebuggerClientConnection;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/jvm/functions/Function2;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun getKey ()Lcom/copperleaf/ballast/BallastInterceptor$Key;
public fun start (Lcom/copperleaf/ballast/BallastInterceptorScope;Lkotlinx/coroutines/flow/Flow;)V
public fun toString ()Ljava/lang/String;
}

public final class com/copperleaf/ballast/debugger/BallastDebuggerInterceptor$Companion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,14 @@ public class BallastDebuggerClientConnection<out T : HttpClientEngineConfig>(
}
}

private val client: HttpClient = HttpClient(engineFactory) {
install(WebSockets)
install(ContentNegotiation) {
json()
private val client: HttpClient by lazy {
HttpClient(engineFactory) {
install(WebSockets)
install(ContentNegotiation) {
json()
}
block()
}
block()
}

private val outgoingMessages =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class BallastDebuggerInterceptor<Inputs : Any, Events : Any, State : Any>
}
}

override fun toString(): String {
return "BallastDebuggerInterceptor"
}

public companion object {
public fun <Inputs : Any, Events : Any, State : Any> withJson(
connection: BallastDebuggerClientConnection<*>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.copperleaf.ballast.debugger

import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.HttpClientEngineConfig
import io.ktor.client.engine.HttpClientEngineFactory
import io.ktor.client.request.HttpRequestData
import io.ktor.client.request.HttpResponseData
import io.ktor.util.InternalAPI
import kotlinx.coroutines.CoroutineDispatcher
import kotlin.coroutines.CoroutineContext

class BallastDebuggerTests : StringSpec({
"check toString values" {
BallastDebuggerInterceptor<Any, Any, Any>(
connection = BallastDebuggerClientConnection(TestHttpEngine, this),
).toString() shouldBe "BallastDebuggerInterceptor"
}
})

private object TestHttpEngine : HttpClientEngineFactory<TestEngineConfig> {
override fun create(block: TestEngineConfig.() -> Unit): HttpClientEngine {
return TestHttpClientEngine()
}

override fun toString(): String = "TestHttpEngine"
}

private class TestEngineConfig : HttpClientEngineConfig()
private class TestHttpClientEngine : HttpClientEngine {
override val config: HttpClientEngineConfig
get() = TODO("Not yet implemented")
override val dispatcher: CoroutineDispatcher
get() = TODO("Not yet implemented")

@InternalAPI
override suspend fun execute(data: HttpRequestData): HttpResponseData {
TODO("Not yet implemented")
}

override fun close() {
TODO("Not yet implemented")
}

override val coroutineContext: CoroutineContext
get() = TODO("Not yet implemented")
}
Loading

0 comments on commit eb6461c

Please sign in to comment.