remove unused code
This commit is contained in:
parent
3305672ade
commit
ef208a96e6
|
@ -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<ValueWithUnit>): String = list.map(::ValueWithUnitWrapper)
|
||||
.let(SealedClassHelper.gson::toJson)
|
||||
|
||||
fun fromJson(string: String): List<ValueWithUnit> = SealedClassHelper.gson
|
||||
.fromJson<List<ValueWithUnitWrapper>>(string).map { it.wrapped }
|
||||
|
||||
private class ValueWithUnitWrapper(val wrapped: ValueWithUnit)
|
||||
}
|
||||
|
||||
inline fun <reified T> Gson.fromJson(json: String): T = fromJson(json, object : TypeToken<T>() {}.type)
|
|
@ -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>(
|
||||
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<ValueWithUnit>()
|
||||
|
||||
val serialized = ValueWithUnitSerializer.toSealedClassJson(list)
|
||||
val deserialized = ValueWithUnitSerializer.fromJson(serialized)
|
||||
|
||||
Assert.assertEquals(0, list.size)
|
||||
Assert.assertEquals(list, deserialized)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue