From ef208a96e632ece901648702cad4016f56879af2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 11 Nov 2022 09:50:15 +0100 Subject: [PATCH] remove unused code --- .../serialisation/ValueWithUnitSerializer.kt | 19 ---------- .../ValueWithUnitSerializerTest.kt | 36 ------------------- 2 files changed, 55 deletions(-) delete mode 100644 core/core-main/src/main/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializer.kt delete mode 100644 core/core-main/src/test/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializerTest.kt diff --git a/core/core-main/src/main/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializer.kt b/core/core-main/src/main/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializer.kt deleted file mode 100644 index f2167eb2a3..0000000000 --- a/core/core-main/src/main/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializer.kt +++ /dev/null @@ -1,19 +0,0 @@ -package info.nightscout.androidaps.utils.serialisation - -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken -import info.nightscout.database.entities.ValueWithUnit -import info.nightscout.database.impl.serialisation.SealedClassHelper - -object ValueWithUnitSerializer { - - fun toSealedClassJson(list: List): String = list.map(::ValueWithUnitWrapper) - .let(SealedClassHelper.gson::toJson) - - fun fromJson(string: String): List = SealedClassHelper.gson - .fromJson>(string).map { it.wrapped } - - private class ValueWithUnitWrapper(val wrapped: ValueWithUnit) -} - -inline fun Gson.fromJson(json: String): T = fromJson(json, object : TypeToken() {}.type) diff --git a/core/core-main/src/test/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializerTest.kt b/core/core-main/src/test/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializerTest.kt deleted file mode 100644 index 7fdbaada58..0000000000 --- a/core/core-main/src/test/java/info/nightscout/androidaps/utils/serialisation/ValueWithUnitSerializerTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package info.nightscout.androidaps.utils.serialisation - -import info.nightscout.database.entities.ValueWithUnit -import org.junit.Assert -import org.junit.Test - -internal class ValueWithUnitSerializerTest { - - @Test - fun testSerialisationDeserization() { - - val list = listOf( - ValueWithUnit.SimpleString("hello"), - ValueWithUnit.SimpleInt(5), - ValueWithUnit.UNKNOWN - ) - - val serialized = ValueWithUnitSerializer.toSealedClassJson(list) - val deserialized = ValueWithUnitSerializer.fromJson(serialized) - - Assert.assertEquals(3, list.size) - Assert.assertEquals(list, deserialized) - } - - @Test - fun testEmptyList() { - - val list = listOf() - - val serialized = ValueWithUnitSerializer.toSealedClassJson(list) - val deserialized = ValueWithUnitSerializer.fromJson(serialized) - - Assert.assertEquals(0, list.size) - Assert.assertEquals(list, deserialized) - } -} \ No newline at end of file