Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert more tests from Java to Kotlin #8155

Merged
merged 4 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,9 @@ class HttpLoggingInterceptorTest {
return Request.Builder().url(url)
}

internal class LogRecorder : HttpLoggingInterceptor.Logger {
internal class LogRecorder(
val prefix: Regex = Regex(""),
) : HttpLoggingInterceptor.Logger {
private val logs = mutableListOf<String>()
private var index = 0

Expand All @@ -994,7 +996,7 @@ class HttpLoggingInterceptorTest {
.overridingErrorMessage("No more messages found")
.isLessThan(logs.size)
assertThat(logs[index++])
.matches(Pattern.compile("\\[\\d+ ms] ${regex.pattern}", Pattern.DOTALL))
.matches(Pattern.compile(prefix.pattern + regex.pattern, Pattern.DOTALL))
}

fun assertNoMoreLogs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ class LoggingEventListenerTest {
val clientTestRule = OkHttpClientTestRule()
private lateinit var server: MockWebServer
private val handshakeCertificates = platform.localhostHandshakeCertificates()
private val logRecorder = HttpLoggingInterceptorTest.LogRecorder()
private val logRecorder = HttpLoggingInterceptorTest.LogRecorder(
prefix = Regex("""\[\d+ ms] """)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

)
private val loggingEventListenerFactory = LoggingEventListener.Factory(logRecorder)
private lateinit var client: OkHttpClient
private lateinit var url: HttpUrl
Expand Down