mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-12-05 04:41:09 +01:00
Fix spotless complaints
This commit is contained in:
parent
b28e234f21
commit
36dd4ddc0a
3 changed files with 19 additions and 25 deletions
|
|
@ -9,13 +9,11 @@ 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<Verification.JSON>(){}.type)
|
||||
return gson.fromJson(string, object : TypeToken<Verification.JSON>() {}.type)
|
||||
} catch (e: JsonSyntaxException) {
|
||||
throw ParseException(e.message, 0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ 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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue