diff --git a/sop-java-json-gson/src/main/kotlin/sop/GsonParser.kt b/sop-java-json-gson/src/main/kotlin/sop/GsonParser.kt index 06adecb..37ec9d3 100644 --- a/sop-java-json-gson/src/main/kotlin/sop/GsonParser.kt +++ b/sop-java-json-gson/src/main/kotlin/sop/GsonParser.kt @@ -9,15 +9,13 @@ import com.google.gson.JsonSyntaxException import com.google.gson.reflect.TypeToken import java.text.ParseException -class GsonParser( - private val gson: Gson = Gson() -) : Verification.JSONParser { +class GsonParser(private val gson: Gson = Gson()) : Verification.JSONParser { override fun parse(string: String): Verification.JSON { try { - return gson.fromJson(string, object : TypeToken(){}.type) + return gson.fromJson(string, object : TypeToken() {}.type) } catch (e: JsonSyntaxException) { throw ParseException(e.message, 0) } } -} \ No newline at end of file +} diff --git a/sop-java-json-gson/src/main/kotlin/sop/GsonSerializer.kt b/sop-java-json-gson/src/main/kotlin/sop/GsonSerializer.kt index 410fe49..d4c71cb 100644 --- a/sop-java-json-gson/src/main/kotlin/sop/GsonSerializer.kt +++ b/sop-java-json-gson/src/main/kotlin/sop/GsonSerializer.kt @@ -6,11 +6,9 @@ package sop import com.google.gson.Gson -class GsonSerializer( - private val gson: Gson = Gson() -) : Verification.JSONSerializer { +class GsonSerializer(private val gson: Gson = Gson()) : Verification.JSONSerializer { override fun serialize(json: Verification.JSON): String { return gson.toJson(json) } -} \ No newline at end of file +} diff --git a/sop-java-json-gson/src/test/kotlin/sop/GsonSerializerAndParserTest.kt b/sop-java-json-gson/src/test/kotlin/sop/GsonSerializerAndParserTest.kt index 9bbef14..8e11563 100644 --- a/sop-java-json-gson/src/test/kotlin/sop/GsonSerializerAndParserTest.kt +++ b/sop-java-json-gson/src/test/kotlin/sop/GsonSerializerAndParserTest.kt @@ -4,10 +4,10 @@ package sop +import java.text.ParseException import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import java.text.ParseException class GsonSerializerAndParserTest { @@ -40,10 +40,7 @@ class GsonSerializerAndParserTest { @Test fun withCommentTest() { - val before = Verification.JSON( - listOf("/tmp/alice.pgp"), - "This is a comment.", - null) + val before = Verification.JSON(listOf("/tmp/alice.pgp"), "This is a comment.", null) val json = serializer.serialize(before) assertEquals("{\"signers\":[\"/tmp/alice.pgp\"],\"comment\":\"This is a comment.\"}", json) @@ -55,13 +52,14 @@ class GsonSerializerAndParserTest { @Test fun withExtStringTest() { - val before = Verification.JSON( - listOf("/tmp/alice.pgp"), - "This is a comment.", - "This is an ext object string.") + val before = + Verification.JSON( + listOf("/tmp/alice.pgp"), "This is a comment.", "This is an ext object string.") val json = serializer.serialize(before) - assertEquals("{\"signers\":[\"/tmp/alice.pgp\"],\"comment\":\"This is a comment.\",\"ext\":\"This is an ext object string.\"}", json) + assertEquals( + "{\"signers\":[\"/tmp/alice.pgp\"],\"comment\":\"This is a comment.\",\"ext\":\"This is an ext object string.\"}", + json) val after = parser.parse(json) @@ -70,13 +68,13 @@ class GsonSerializerAndParserTest { @Test fun withExtListTest() { - val before = Verification.JSON( - listOf("/tmp/alice.pgp"), - "This is a comment.", - listOf(1.0,2.0,3.0)) + val before = + Verification.JSON(listOf("/tmp/alice.pgp"), "This is a comment.", listOf(1.0, 2.0, 3.0)) val json = serializer.serialize(before) - assertEquals("{\"signers\":[\"/tmp/alice.pgp\"],\"comment\":\"This is a comment.\",\"ext\":[1.0,2.0,3.0]}", json) + assertEquals( + "{\"signers\":[\"/tmp/alice.pgp\"],\"comment\":\"This is a comment.\",\"ext\":[1.0,2.0,3.0]}", + json) val after = parser.parse(json) @@ -93,4 +91,4 @@ class GsonSerializerAndParserTest { // Missing '}' assertThrows { parser.parse("{\"signers\":[\"Alice\"]") } } -} \ No newline at end of file +}