Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejwalkowiak committed Jun 24, 2021
1 parent 6ad3559 commit 0fc2338
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions sentry/src/test/java/io/sentry/GsonSerializerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,8 @@ class GsonSerializerTest {
fixture = Fixture()
}

private fun serializeToString(ev: SentryEvent): String {
return this.serializeToString { wrt -> fixture.serializer.serialize(ev, wrt) }
}

private fun serializeToString(session: Session): String {
return this.serializeToString { wrt -> fixture.serializer.serialize(session, wrt) }
}

private fun serializeToString(userFeedback: UserFeedback): String {
return this.serializeToString { wrt -> fixture.serializer.serialize(userFeedback, wrt) }
private fun <T> serializeToString(ev: T): String {
return this.serializeToString { wrt -> fixture.serializer.serialize(ev!!, wrt) }
}

private fun serializeToString(serialize: (StringWriter) -> Unit): String {
Expand Down Expand Up @@ -567,10 +559,7 @@ class GsonSerializerTest {
fun `serializes span data`() {
val sentrySpan = SentrySpan(createSpan() as Span, mapOf("data1" to "value1"))

val stringWriter = StringWriter()
fixture.serializer.serialize(sentrySpan, stringWriter)

val element = JsonParser().parse(stringWriter.toString()).asJsonObject
val element = JsonParser().parse(serializeToString(sentrySpan)).asJsonObject
assertNotNull(element["data"]) {
assertNotNull(it.asJsonObject["data1"]) {
assertEquals("value1", it.asString)
Expand Down

0 comments on commit 0fc2338

Please sign in to comment.