Merge pull request #2829 from ryanhaining/assertthat_plugins_sync
Rewrites plugins/sync with matchers
This commit is contained in:
commit
550b3905e0
|
@ -2,6 +2,7 @@ package info.nightscout.plugins.sync.dataBroadcaster
|
||||||
|
|
||||||
import app.aaps.shared.tests.BundleMock
|
import app.aaps.shared.tests.BundleMock
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
|
@ -20,7 +21,6 @@ import info.nightscout.interfaces.pump.PumpEnactResult
|
||||||
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
||||||
import info.nightscout.rx.events.EventOverviewBolusProgress
|
import info.nightscout.rx.events.EventOverviewBolusProgress
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers.anyLong
|
import org.mockito.ArgumentMatchers.anyLong
|
||||||
|
@ -81,37 +81,37 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() {
|
||||||
}
|
}
|
||||||
val bundle = BundleMock.mock()
|
val bundle = BundleMock.mock()
|
||||||
sut.prepareData(event, bundle)
|
sut.prepareData(event, bundle)
|
||||||
Assertions.assertTrue(bundle.containsKey("progressPercent"))
|
assertThat(bundle.containsKey("progressPercent")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("progressStatus"))
|
assertThat(bundle.containsKey("progressStatus")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("glucoseMgdl"))
|
assertThat(bundle.containsKey("glucoseMgdl")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("glucoseTimeStamp"))
|
assertThat(bundle.containsKey("glucoseTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("units"))
|
assertThat(bundle.containsKey("units")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("slopeArrow"))
|
assertThat(bundle.containsKey("slopeArrow")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("deltaMgdl"))
|
assertThat(bundle.containsKey("deltaMgdl")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("avgDeltaMgdl"))
|
assertThat(bundle.containsKey("avgDeltaMgdl")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("high"))
|
assertThat(bundle.containsKey("high")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("low"))
|
assertThat(bundle.containsKey("low")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("bolusIob"))
|
assertThat(bundle.containsKey("bolusIob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("basalIob"))
|
assertThat(bundle.containsKey("basalIob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("iob"))
|
assertThat(bundle.containsKey("iob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("cob"))
|
assertThat(bundle.containsKey("cob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("futureCarbs"))
|
assertThat(bundle.containsKey("futureCarbs")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("phoneBattery"))
|
assertThat(bundle.containsKey("phoneBattery")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("rigBattery"))
|
assertThat(bundle.containsKey("rigBattery")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("suggestedTimeStamp"))
|
assertThat(bundle.containsKey("suggestedTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("suggested"))
|
assertThat(bundle.containsKey("suggested")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("enactedTimeStamp"))
|
assertThat(bundle.containsKey("enactedTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("enacted"))
|
assertThat(bundle.containsKey("enacted")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("basalTimeStamp"))
|
assertThat(bundle.containsKey("basalTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("baseBasal"))
|
assertThat(bundle.containsKey("baseBasal")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("profile"))
|
assertThat(bundle.containsKey("profile")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("tempBasalStart"))
|
assertThat(bundle.containsKey("tempBasalStart")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("tempBasalDurationInMinutes"))
|
assertThat(bundle.containsKey("tempBasalDurationInMinutes")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("tempBasalString"))
|
assertThat(bundle.containsKey("tempBasalString")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpTimeStamp"))
|
assertThat(bundle.containsKey("pumpTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpBattery"))
|
assertThat(bundle.containsKey("pumpBattery")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpReservoir"))
|
assertThat(bundle.containsKey("pumpReservoir")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpStatus"))
|
assertThat(bundle.containsKey("pumpStatus")).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -123,36 +123,36 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() {
|
||||||
}
|
}
|
||||||
val bundle = BundleMock.mock()
|
val bundle = BundleMock.mock()
|
||||||
sut.prepareData(event, bundle)
|
sut.prepareData(event, bundle)
|
||||||
Assertions.assertTrue(bundle.containsKey("progressPercent"))
|
assertThat(bundle.containsKey("progressPercent")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("progressStatus"))
|
assertThat(bundle.containsKey("progressStatus")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("glucoseMgdl"))
|
assertThat(bundle.containsKey("glucoseMgdl")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("glucoseTimeStamp"))
|
assertThat(bundle.containsKey("glucoseTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("units"))
|
assertThat(bundle.containsKey("units")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("slopeArrow"))
|
assertThat(bundle.containsKey("slopeArrow")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("deltaMgdl"))
|
assertThat(bundle.containsKey("deltaMgdl")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("avgDeltaMgdl"))
|
assertThat(bundle.containsKey("avgDeltaMgdl")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("high"))
|
assertThat(bundle.containsKey("high")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("low"))
|
assertThat(bundle.containsKey("low")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("bolusIob"))
|
assertThat(bundle.containsKey("bolusIob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("basalIob"))
|
assertThat(bundle.containsKey("basalIob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("iob"))
|
assertThat(bundle.containsKey("iob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("cob"))
|
assertThat(bundle.containsKey("cob")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("futureCarbs"))
|
assertThat(bundle.containsKey("futureCarbs")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("phoneBattery"))
|
assertThat(bundle.containsKey("phoneBattery")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("rigBattery"))
|
assertThat(bundle.containsKey("rigBattery")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("suggestedTimeStamp"))
|
assertThat(bundle.containsKey("suggestedTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("suggested"))
|
assertThat(bundle.containsKey("suggested")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("enactedTimeStamp"))
|
assertThat(bundle.containsKey("enactedTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("enacted"))
|
assertThat(bundle.containsKey("enacted")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("basalTimeStamp"))
|
assertThat(bundle.containsKey("basalTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("baseBasal"))
|
assertThat(bundle.containsKey("baseBasal")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("profile"))
|
assertThat(bundle.containsKey("profile")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("tempBasalStart"))
|
assertThat(bundle.containsKey("tempBasalStart")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("tempBasalDurationInMinutes"))
|
assertThat(bundle.containsKey("tempBasalDurationInMinutes")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("tempBasalString"))
|
assertThat(bundle.containsKey("tempBasalString")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpTimeStamp"))
|
assertThat(bundle.containsKey("pumpTimeStamp")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpBattery"))
|
assertThat(bundle.containsKey("pumpBattery")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpReservoir"))
|
assertThat(bundle.containsKey("pumpReservoir")).isTrue()
|
||||||
Assertions.assertTrue(bundle.containsKey("pumpStatus"))
|
assertThat(bundle.containsKey("pumpStatus")).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclient
|
package info.nightscout.plugins.sync.nsclient
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBase
|
import app.aaps.shared.tests.TestBase
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
import info.nightscout.interfaces.receivers.ReceiverStatusStore
|
||||||
import info.nightscout.plugins.sync.R
|
import info.nightscout.plugins.sync.R
|
||||||
|
@ -8,7 +9,6 @@ import info.nightscout.rx.events.EventChargingState
|
||||||
import info.nightscout.rx.events.EventNetworkChange
|
import info.nightscout.rx.events.EventNetworkChange
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -33,12 +33,12 @@ class ReceiverDelegateTest : TestBase() {
|
||||||
fun testCalculateStatusChargingState() {
|
fun testCalculateStatusChargingState() {
|
||||||
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false)
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventChargingState(false, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(false, 0))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventChargingState(true, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(true, 0))).isFalse()
|
||||||
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(false)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(true)
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventChargingState(true, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(true, 0))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventChargingState(false, 0)))
|
assertThat(sut.calculateStatus(EventChargingState(false, 0))).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -47,41 +47,41 @@ class ReceiverDelegateTest : TestBase() {
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
|
||||||
|
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test 1")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test 1")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true))).isFalse()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(false)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(wifiConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(wifiConnected = true))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
|
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true))).isFalse()
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue()
|
||||||
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))).isFalse()
|
||||||
|
|
||||||
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_cellular, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_wifi, true)).thenReturn(true)
|
||||||
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(true)
|
||||||
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue()
|
||||||
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
|
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3
|
package info.nightscout.plugins.sync.nsclientV3
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.extensions.fromConstant
|
import info.nightscout.core.extensions.fromConstant
|
||||||
|
@ -36,7 +37,6 @@ import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
|
||||||
import info.nightscout.sdk.interfaces.NSAndroidClient
|
import info.nightscout.sdk.interfaces.NSAndroidClient
|
||||||
import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse
|
import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -108,11 +108,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("devicestatus", dataPair, "1/3")
|
sut.nsAdd("devicestatus", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdDeviceStatuses.size)
|
assertThat(storeDataForDb.nsIdDeviceStatuses).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsAdd("devicestatus", dataPair, "1/3")
|
sut.nsAdd("devicestatus", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdDeviceStatuses.size) // still only 1
|
assertThat(storeDataForDb.nsIdDeviceStatuses).hasSize(2) // still only 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -134,11 +134,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createSgv(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createSgv(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("entries", dataPair, "1/3")
|
sut.nsAdd("entries", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdGlucoseValues.size)
|
assertThat(storeDataForDb.nsIdGlucoseValues).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateSvg(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateSvg(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("entries", dataPair, "1/3")
|
sut.nsUpdate("entries", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdGlucoseValues.size)
|
assertThat(storeDataForDb.nsIdGlucoseValues).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -164,11 +164,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createFood(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createFood(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("food", dataPair, "1/3")
|
sut.nsAdd("food", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdFoods.size)
|
assertThat(storeDataForDb.nsIdFoods).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateFood(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateFood(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("food", dataPair, "1/3")
|
sut.nsUpdate("food", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdFoods.size)
|
assertThat(storeDataForDb.nsIdFoods).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -192,11 +192,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdBoluses.size)
|
assertThat(storeDataForDb.nsIdBoluses).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdBoluses.size)
|
assertThat(storeDataForDb.nsIdBoluses).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -219,11 +219,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdCarbs.size)
|
assertThat(storeDataForDb.nsIdCarbs).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdCarbs.size)
|
assertThat(storeDataForDb.nsIdCarbs).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -272,11 +272,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdBolusCalculatorResults.size)
|
assertThat(storeDataForDb.nsIdBolusCalculatorResults).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdBolusCalculatorResults.size)
|
assertThat(storeDataForDb.nsIdBolusCalculatorResults).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -310,11 +310,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdEffectiveProfileSwitches.size)
|
assertThat(storeDataForDb.nsIdEffectiveProfileSwitches).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdEffectiveProfileSwitches.size)
|
assertThat(storeDataForDb.nsIdEffectiveProfileSwitches).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -346,11 +346,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdProfileSwitches.size)
|
assertThat(storeDataForDb.nsIdProfileSwitches).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdProfileSwitches.size)
|
assertThat(storeDataForDb.nsIdProfileSwitches).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -373,11 +373,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3", validProfile)
|
sut.nsAdd("treatments", dataPair, "1/3", validProfile)
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdExtendedBoluses.size)
|
assertThat(storeDataForDb.nsIdExtendedBoluses).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3", validProfile)
|
sut.nsUpdate("treatments", dataPair, "1/3", validProfile)
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdExtendedBoluses.size)
|
assertThat(storeDataForDb.nsIdExtendedBoluses).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -399,11 +399,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdOfflineEvents.size)
|
assertThat(storeDataForDb.nsIdOfflineEvents).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdOfflineEvents.size)
|
assertThat(storeDataForDb.nsIdOfflineEvents).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -427,11 +427,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3", validProfile)
|
sut.nsAdd("treatments", dataPair, "1/3", validProfile)
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdTemporaryBasals.size)
|
assertThat(storeDataForDb.nsIdTemporaryBasals).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3", validProfile)
|
sut.nsUpdate("treatments", dataPair, "1/3", validProfile)
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdTemporaryBasals.size)
|
assertThat(storeDataForDb.nsIdTemporaryBasals).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -455,11 +455,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdTemporaryTargets.size)
|
assertThat(storeDataForDb.nsIdTemporaryTargets).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdTemporaryTargets.size)
|
assertThat(storeDataForDb.nsIdTemporaryTargets).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -486,11 +486,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
|
||||||
// create
|
// create
|
||||||
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
|
||||||
sut.nsAdd("treatments", dataPair, "1/3")
|
sut.nsAdd("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(1, storeDataForDb.nsIdTherapyEvents.size)
|
assertThat(storeDataForDb.nsIdTherapyEvents).hasSize(1)
|
||||||
// update
|
// update
|
||||||
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
|
||||||
sut.nsUpdate("treatments", dataPair, "1/3")
|
sut.nsUpdate("treatments", dataPair, "1/3")
|
||||||
Assertions.assertEquals(2, storeDataForDb.nsIdTherapyEvents.size)
|
assertThat(storeDataForDb.nsIdTherapyEvents).hasSize(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.BolusCalculatorResult
|
import info.nightscout.database.entities.BolusCalculatorResult
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSBolusWizard
|
import info.nightscout.sdk.localmodel.treatment.NSBolusWizard
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -53,7 +53,7 @@ internal class BolusCalculatorResultExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
val bolus2 = (bolus.toNSBolusWizard().convertToRemoteAndBack() as NSBolusWizard).toBolusCalculatorResult()!!
|
val bolus2 = (bolus.toNSBolusWizard().convertToRemoteAndBack() as NSBolusWizard).toBolusCalculatorResult()!!
|
||||||
Assertions.assertTrue(bolus.contentEqualsTo(bolus2))
|
assertThat(bolus.contentEqualsTo(bolus2)).isTrue()
|
||||||
Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2))
|
assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.Bolus
|
import info.nightscout.database.entities.Bolus
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSBolus
|
import info.nightscout.sdk.localmodel.treatment.NSBolus
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ internal class BolusExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
var bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus()
|
var bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus()
|
||||||
Assertions.assertTrue(bolus.contentEqualsTo(bolus2))
|
assertThat(bolus.contentEqualsTo(bolus2)).isTrue()
|
||||||
Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2))
|
assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue()
|
||||||
|
|
||||||
bolus = Bolus(
|
bolus = Bolus(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -48,7 +48,7 @@ internal class BolusExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus()
|
bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus()
|
||||||
Assertions.assertTrue(bolus.contentEqualsTo(bolus2))
|
assertThat(bolus.contentEqualsTo(bolus2)).isTrue()
|
||||||
Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2))
|
assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.Carbs
|
import info.nightscout.database.entities.Carbs
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSCarbs
|
import info.nightscout.sdk.localmodel.treatment.NSCarbs
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -27,8 +27,8 @@ internal class CarbsExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
var carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs()
|
var carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs()
|
||||||
Assertions.assertTrue(carbs.contentEqualsTo(carbs2))
|
assertThat(carbs.contentEqualsTo(carbs2)).isTrue()
|
||||||
Assertions.assertTrue(carbs.interfaceIdsEqualsTo(carbs2))
|
assertThat(carbs.interfaceIdsEqualsTo(carbs2)).isTrue()
|
||||||
|
|
||||||
carbs = Carbs(
|
carbs = Carbs(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -45,7 +45,7 @@ internal class CarbsExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs()
|
carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs()
|
||||||
Assertions.assertTrue(carbs.contentEqualsTo(carbs2))
|
assertThat(carbs.contentEqualsTo(carbs2)).isTrue()
|
||||||
Assertions.assertTrue(carbs.interfaceIdsEqualsTo(carbs2))
|
assertThat(carbs.interfaceIdsEqualsTo(carbs2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBase
|
import app.aaps.shared.tests.TestBase
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.DeviceStatus
|
import info.nightscout.database.entities.DeviceStatus
|
||||||
import info.nightscout.interfaces.Config
|
import info.nightscout.interfaces.Config
|
||||||
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
|
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
|
||||||
|
@ -12,7 +13,6 @@ import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import info.nightscout.shared.interfaces.ResourceHelper
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -57,20 +57,20 @@ internal class DeviceStatusExtensionKtTest : TestBase() {
|
||||||
val nsDeviceStatus = deviceStatus.toNSDeviceStatus()
|
val nsDeviceStatus = deviceStatus.toNSDeviceStatus()
|
||||||
|
|
||||||
nsDeviceStatusHandler.handleNewData(arrayOf(nsDeviceStatus))
|
nsDeviceStatusHandler.handleNewData(arrayOf(nsDeviceStatus))
|
||||||
Assertions.assertEquals(75, processedDeviceStatusData.pumpData?.percent)
|
assertThat(processedDeviceStatusData.pumpData!!.percent).isEqualTo(75)
|
||||||
|
|
||||||
val nsDeviceStatus2 = nsDeviceStatus.convertToRemoteAndBack()
|
val nsDeviceStatus2 = nsDeviceStatus.convertToRemoteAndBack()
|
||||||
Assertions.assertTrue(nsDeviceStatus.device == nsDeviceStatus2.device)
|
assertThat(nsDeviceStatus2.device).isEqualTo(nsDeviceStatus.device)
|
||||||
Assertions.assertTrue(nsDeviceStatus.identifier == nsDeviceStatus2.identifier)
|
assertThat(nsDeviceStatus2.identifier).isEqualTo(nsDeviceStatus.identifier)
|
||||||
Assertions.assertTrue(nsDeviceStatus.srvCreated == nsDeviceStatus2.srvCreated)
|
assertThat(nsDeviceStatus2.srvCreated).isEqualTo(nsDeviceStatus.srvCreated)
|
||||||
Assertions.assertTrue(nsDeviceStatus.srvModified == nsDeviceStatus2.srvModified)
|
assertThat(nsDeviceStatus2.srvModified).isEqualTo(nsDeviceStatus.srvModified)
|
||||||
Assertions.assertTrue(nsDeviceStatus.createdAt == nsDeviceStatus2.createdAt)
|
assertThat(nsDeviceStatus2.createdAt).isEqualTo(nsDeviceStatus.createdAt)
|
||||||
Assertions.assertTrue(nsDeviceStatus.date == nsDeviceStatus2.date)
|
assertThat(nsDeviceStatus2.date).isEqualTo(nsDeviceStatus.date)
|
||||||
Assertions.assertTrue(nsDeviceStatus.uploaderBattery == nsDeviceStatus2.uploaderBattery)
|
assertThat(nsDeviceStatus2.uploaderBattery).isEqualTo(nsDeviceStatus.uploaderBattery)
|
||||||
Assertions.assertTrue(nsDeviceStatus.device == nsDeviceStatus2.device)
|
assertThat(nsDeviceStatus2.device).isEqualTo(nsDeviceStatus.device)
|
||||||
Assertions.assertTrue(nsDeviceStatus.uploader?.battery == nsDeviceStatus2.uploader?.battery)
|
assertThat(nsDeviceStatus2.uploader?.battery).isEqualTo(nsDeviceStatus.uploader?.battery)
|
||||||
Assertions.assertTrue(nsDeviceStatus.pump?.battery == nsDeviceStatus2.pump?.battery)
|
assertThat(nsDeviceStatus2.pump?.battery).isEqualTo(nsDeviceStatus.pump?.battery)
|
||||||
Assertions.assertTrue(nsDeviceStatus.openaps?.enacted?.toString() == nsDeviceStatus2.openaps?.enacted?.toString())
|
assertThat(nsDeviceStatus2.openaps?.enacted?.toString()).isEqualTo(nsDeviceStatus.openaps?.enacted?.toString())
|
||||||
Assertions.assertTrue(nsDeviceStatus.configuration?.toString() == nsDeviceStatus2.configuration?.toString())
|
assertThat(nsDeviceStatus2.configuration?.toString()).isEqualTo(nsDeviceStatus.configuration?.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.EffectiveProfileSwitch
|
import info.nightscout.database.entities.EffectiveProfileSwitch
|
||||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
|
@ -8,7 +9,6 @@ import info.nightscout.interfaces.insulin.Insulin
|
||||||
import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
|
import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSEffectiveProfileSwitch
|
import info.nightscout.sdk.localmodel.treatment.NSEffectiveProfileSwitch
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -55,7 +55,7 @@ internal class EffectiveProfileSwitchExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
val profileSwitch2 = (profileSwitch.toNSEffectiveProfileSwitch(dateUtil).convertToRemoteAndBack() as NSEffectiveProfileSwitch).toEffectiveProfileSwitch(dateUtil)!!
|
val profileSwitch2 = (profileSwitch.toNSEffectiveProfileSwitch(dateUtil).convertToRemoteAndBack() as NSEffectiveProfileSwitch).toEffectiveProfileSwitch(dateUtil)!!
|
||||||
Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2))
|
assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue()
|
||||||
Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2))
|
assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.ExtendedBolus
|
import info.nightscout.database.entities.ExtendedBolus
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSExtendedBolus
|
import info.nightscout.sdk.localmodel.treatment.NSExtendedBolus
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
|
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -29,8 +29,8 @@ internal class ExtendedBolusExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
var extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus()
|
var extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus()
|
||||||
Assertions.assertTrue(extendedBolus.contentEqualsTo(extendedBolus2))
|
assertThat(extendedBolus.contentEqualsTo(extendedBolus2)).isTrue()
|
||||||
Assertions.assertTrue(extendedBolus.interfaceIdsEqualsTo(extendedBolus2))
|
assertThat(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)).isTrue()
|
||||||
|
|
||||||
extendedBolus = ExtendedBolus(
|
extendedBolus = ExtendedBolus(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -47,13 +47,13 @@ internal class ExtendedBolusExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
val converted = extendedBolus.toNSExtendedBolus(validProfile)
|
val converted = extendedBolus.toNSExtendedBolus(validProfile)
|
||||||
Assertions.assertTrue(converted is NSTemporaryBasal)
|
assertThat(converted).isInstanceOf(NSTemporaryBasal::class.java)
|
||||||
Assertions.assertNotNull((converted as NSTemporaryBasal).extendedEmulated)
|
assertThat((converted as NSTemporaryBasal).extendedEmulated).isNotNull()
|
||||||
val convertedBack = converted.convertToRemoteAndBack()
|
val convertedBack = converted.convertToRemoteAndBack()
|
||||||
Assertions.assertTrue(convertedBack is NSExtendedBolus)
|
assertThat(convertedBack).isInstanceOf(NSExtendedBolus::class.java)
|
||||||
|
|
||||||
extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus()
|
extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus()
|
||||||
Assertions.assertTrue(extendedBolus.contentEqualsTo(extendedBolus2))
|
assertThat(extendedBolus.contentEqualsTo(extendedBolus2)).isTrue()
|
||||||
Assertions.assertTrue(extendedBolus.interfaceIdsEqualsTo(extendedBolus2))
|
assertThat(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.Food
|
import info.nightscout.database.entities.Food
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.food.NSFood
|
import info.nightscout.sdk.localmodel.food.NSFood
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -30,7 +30,7 @@ internal class FoodExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
val food2 = (food.toNSFood().convertToRemoteAndBack() as NSFood).toFood()
|
val food2 = (food.toNSFood().convertToRemoteAndBack() as NSFood).toFood()
|
||||||
Assertions.assertTrue(food.contentEqualsTo(food2))
|
assertThat(food.contentEqualsTo(food2)).isTrue()
|
||||||
Assertions.assertTrue(food.interfaceIdsEqualsTo(food2))
|
assertThat(food.interfaceIdsEqualsTo(food2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
internal class GlucoseValueExtensionKtTest : TestBaseWithProfile() {
|
internal class GlucoseValueExtensionKtTest : TestBaseWithProfile() {
|
||||||
|
@ -25,7 +25,7 @@ internal class GlucoseValueExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
val glucoseValue2 = glucoseValue.toNSSvgV3().convertToRemoteAndBack()?.toTransactionGlucoseValue()?.toGlucoseValue()
|
val glucoseValue2 = glucoseValue.toNSSvgV3().convertToRemoteAndBack()?.toTransactionGlucoseValue()?.toGlucoseValue()
|
||||||
Assertions.assertTrue(glucoseValue.contentEqualsTo(glucoseValue2!!))
|
assertThat(glucoseValue.contentEqualsTo(glucoseValue2!!)).isTrue()
|
||||||
Assertions.assertTrue(glucoseValue.interfaceIdsEqualsTo(glucoseValue2))
|
assertThat(glucoseValue.interfaceIdsEqualsTo(glucoseValue2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.OfflineEvent
|
import info.nightscout.database.entities.OfflineEvent
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSOfflineEvent
|
import info.nightscout.sdk.localmodel.treatment.NSOfflineEvent
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -26,8 +26,8 @@ internal class OfflineEventExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
var offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
|
var offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
|
||||||
Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2))
|
assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue()
|
||||||
Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2))
|
assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue()
|
||||||
|
|
||||||
offlineEvent = OfflineEvent(
|
offlineEvent = OfflineEvent(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -43,8 +43,8 @@ internal class OfflineEventExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
|
offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
|
||||||
Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2))
|
assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue()
|
||||||
Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2))
|
assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue()
|
||||||
|
|
||||||
offlineEvent = OfflineEvent(
|
offlineEvent = OfflineEvent(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -60,7 +60,7 @@ internal class OfflineEventExtensionKtTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
|
offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
|
||||||
Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2))
|
assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue()
|
||||||
Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2))
|
assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.core.extensions.fromConstant
|
import info.nightscout.core.extensions.fromConstant
|
||||||
import info.nightscout.database.entities.ProfileSwitch
|
import info.nightscout.database.entities.ProfileSwitch
|
||||||
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
import info.nightscout.database.entities.embedments.InsulinConfiguration
|
||||||
|
@ -8,7 +9,6 @@ import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.interfaces.insulin.Insulin
|
import info.nightscout.interfaces.insulin.Insulin
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSProfileSwitch
|
import info.nightscout.sdk.localmodel.treatment.NSProfileSwitch
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -53,8 +53,8 @@ internal class ProfileSwitchExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
var profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!!
|
var profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!!
|
||||||
Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2))
|
assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue()
|
||||||
Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2))
|
assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue()
|
||||||
|
|
||||||
profileSwitch = ProfileSwitch(
|
profileSwitch = ProfileSwitch(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -80,7 +80,7 @@ internal class ProfileSwitchExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!!
|
profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!!
|
||||||
Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2))
|
assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue()
|
||||||
Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2))
|
assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.TemporaryBasal
|
import info.nightscout.database.entities.TemporaryBasal
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
|
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -29,8 +29,8 @@ internal class TemporaryBasalExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
var temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal()
|
var temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal()
|
||||||
Assertions.assertTrue(temporaryBasal.contentEqualsTo(temporaryBasal2))
|
assertThat(temporaryBasal.contentEqualsTo(temporaryBasal2)).isTrue()
|
||||||
Assertions.assertTrue(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2))
|
assertThat(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)).isTrue()
|
||||||
|
|
||||||
temporaryBasal = TemporaryBasal(
|
temporaryBasal = TemporaryBasal(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -48,7 +48,7 @@ internal class TemporaryBasalExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal()
|
temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal()
|
||||||
Assertions.assertTrue(temporaryBasal.contentEqualsTo(temporaryBasal2))
|
assertThat(temporaryBasal.contentEqualsTo(temporaryBasal2)).isTrue()
|
||||||
Assertions.assertTrue(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2))
|
assertThat(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.TemporaryTarget
|
import info.nightscout.database.entities.TemporaryTarget
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSTemporaryTarget
|
import info.nightscout.sdk.localmodel.treatment.NSTemporaryTarget
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -29,8 +29,8 @@ internal class TemporaryTargetExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
var temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget()
|
var temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget()
|
||||||
Assertions.assertTrue(temporaryTarget.contentEqualsTo(temporaryTarget2))
|
assertThat(temporaryTarget.contentEqualsTo(temporaryTarget2)).isTrue()
|
||||||
Assertions.assertTrue(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2))
|
assertThat(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)).isTrue()
|
||||||
|
|
||||||
temporaryTarget = TemporaryTarget(
|
temporaryTarget = TemporaryTarget(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -48,7 +48,7 @@ internal class TemporaryTargetExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget()
|
temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget()
|
||||||
Assertions.assertTrue(temporaryTarget.contentEqualsTo(temporaryTarget2))
|
assertThat(temporaryTarget.contentEqualsTo(temporaryTarget2)).isTrue()
|
||||||
Assertions.assertTrue(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2))
|
assertThat(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.plugins.sync.nsclientV3.extensions
|
package info.nightscout.plugins.sync.nsclientV3.extensions
|
||||||
|
|
||||||
import app.aaps.shared.tests.TestBaseWithProfile
|
import app.aaps.shared.tests.TestBaseWithProfile
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.entities.TherapyEvent
|
import info.nightscout.database.entities.TherapyEvent
|
||||||
import info.nightscout.database.entities.embedments.InterfaceIDs
|
import info.nightscout.database.entities.embedments.InterfaceIDs
|
||||||
import info.nightscout.sdk.localmodel.treatment.NSTherapyEvent
|
import info.nightscout.sdk.localmodel.treatment.NSTherapyEvent
|
||||||
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
import info.nightscout.sdk.mapper.convertToRemoteAndBack
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
@Suppress("SpellCheckingInspection")
|
@Suppress("SpellCheckingInspection")
|
||||||
|
@ -32,8 +32,8 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
var therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
|
var therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
|
||||||
Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2))
|
assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue()
|
||||||
Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2))
|
assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue()
|
||||||
|
|
||||||
|
|
||||||
therapyEvent = TherapyEvent(
|
therapyEvent = TherapyEvent(
|
||||||
|
@ -55,8 +55,8 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
|
therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
|
||||||
Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2))
|
assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue()
|
||||||
Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2))
|
assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue()
|
||||||
|
|
||||||
therapyEvent = TherapyEvent(
|
therapyEvent = TherapyEvent(
|
||||||
timestamp = 10000,
|
timestamp = 10000,
|
||||||
|
@ -77,7 +77,7 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() {
|
||||||
)
|
)
|
||||||
|
|
||||||
therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
|
therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
|
||||||
Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2))
|
assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue()
|
||||||
Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2))
|
assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
||||||
import androidx.work.ListenableWorker.Result.Success
|
import androidx.work.ListenableWorker.Result.Success
|
||||||
import androidx.work.testing.TestListenableWorkerBuilder
|
import androidx.work.testing.TestListenableWorkerBuilder
|
||||||
import app.aaps.shared.tests.TestBase
|
import app.aaps.shared.tests.TestBase
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
@ -13,7 +14,6 @@ import info.nightscout.plugins.sync.nsclientV3.DataSyncSelectorV3
|
||||||
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -64,6 +64,6 @@ internal class DataSyncWorkerTest : TestBase() {
|
||||||
`when`(nsClient.hasWritePermission).thenReturn(true)
|
`when`(nsClient.hasWritePermission).thenReturn(true)
|
||||||
val result = sut.doWorkAndLog()
|
val result = sut.doWorkAndLog()
|
||||||
Mockito.verify(dataSyncSelectorV3, Mockito.times(1)).doUpload()
|
Mockito.verify(dataSyncSelectorV3, Mockito.times(1)).doUpload()
|
||||||
Assertions.assertTrue(result is Success)
|
assertThat(result).isInstanceOf(Success::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ import androidx.work.WorkContinuation
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import androidx.work.testing.TestListenableWorkerBuilder
|
import androidx.work.testing.TestListenableWorkerBuilder
|
||||||
import app.aaps.shared.tests.TestBase
|
import app.aaps.shared.tests.TestBase
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.core.utils.fabric.FabricPrivacy
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
||||||
|
@ -33,7 +34,6 @@ import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
import info.nightscout.shared.sharedPreferences.SP
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import info.nightscout.shared.utils.DateUtil
|
import info.nightscout.shared.utils.DateUtil
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.ArgumentMatchers.any
|
import org.mockito.ArgumentMatchers.any
|
||||||
|
@ -111,7 +111,7 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
sut = TestListenableWorkerBuilder<LoadBgWorker>(context).build()
|
sut = TestListenableWorkerBuilder<LoadBgWorker>(context).build()
|
||||||
|
|
||||||
val result = sut.doWorkAndLog()
|
val result = sut.doWorkAndLog()
|
||||||
Assertions.assertTrue(result is ListenableWorker.Result.Failure)
|
assertThat(result).isInstanceOf(ListenableWorker.Result.Failure::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -121,8 +121,8 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
Mockito.`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_cgm, false)).thenReturn(false)
|
Mockito.`when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_cgm, false)).thenReturn(false)
|
||||||
|
|
||||||
val result = sut.doWorkAndLog()
|
val result = sut.doWorkAndLog()
|
||||||
Assertions.assertTrue(result is ListenableWorker.Result.Success)
|
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
|
||||||
Assertions.assertTrue(result.outputData.getString("Result") == "Load not enabled")
|
assertThat(result.outputData.getString("Result")).isEqualTo("Load not enabled")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -136,8 +136,8 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList()))
|
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList()))
|
||||||
|
|
||||||
val result = sut.doWorkAndLog()
|
val result = sut.doWorkAndLog()
|
||||||
Assertions.assertEquals(now - 1000, nsClientV3Plugin.lastLoadedSrvModified.collections.entries)
|
assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000)
|
||||||
Assertions.assertTrue(result is ListenableWorker.Result.Success)
|
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -165,7 +165,7 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, listOf(glucoseValue.toNSSvgV3())))
|
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, listOf(glucoseValue.toNSSvgV3())))
|
||||||
|
|
||||||
val result = sut.doWorkAndLog()
|
val result = sut.doWorkAndLog()
|
||||||
Assertions.assertTrue(result is ListenableWorker.Result.Success)
|
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -179,7 +179,7 @@ internal class LoadBgWorkerTest : TestBase() {
|
||||||
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList()))
|
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList()))
|
||||||
|
|
||||||
val result = sut.doWorkAndLog()
|
val result = sut.doWorkAndLog()
|
||||||
Assertions.assertEquals(now - 1000, nsClientV3Plugin.lastLoadedSrvModified.collections.entries)
|
assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000)
|
||||||
Assertions.assertTrue(result is ListenableWorker.Result.Success)
|
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,32 +1,44 @@
|
||||||
package info.nightscout.plugins.sync.tidepool.comm
|
package info.nightscout.plugins.sync.tidepool.comm
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.plugins.sync.tidepool.messages.AuthReplyMessage
|
import info.nightscout.plugins.sync.tidepool.messages.AuthReplyMessage
|
||||||
import info.nightscout.plugins.sync.tidepool.messages.DatasetReplyMessage
|
import info.nightscout.plugins.sync.tidepool.messages.DatasetReplyMessage
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SessionTest {
|
class SessionTest {
|
||||||
|
|
||||||
|
private val session = Session("", "", null)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun populateBody() {
|
fun emptySession() {
|
||||||
val session = Session("", "", null)
|
assertThat(session.authReply).isNull()
|
||||||
Assertions.assertNull(session.authReply)
|
assertThat(session.datasetReply).isNull()
|
||||||
|
}
|
||||||
|
|
||||||
// test authReply
|
@Test
|
||||||
|
fun authReply() {
|
||||||
val authReplyMessage = AuthReplyMessage()
|
val authReplyMessage = AuthReplyMessage()
|
||||||
|
|
||||||
session.populateBody(authReplyMessage)
|
session.populateBody(authReplyMessage)
|
||||||
Assertions.assertEquals(authReplyMessage, session.authReply)
|
|
||||||
|
|
||||||
// test datasetReply
|
assertThat(session.authReply).isEqualTo(authReplyMessage)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun datasetReply() {
|
||||||
val datasetReplyMessage = DatasetReplyMessage()
|
val datasetReplyMessage = DatasetReplyMessage()
|
||||||
Assertions.assertNull(session.datasetReply)
|
|
||||||
session.populateBody(datasetReplyMessage)
|
|
||||||
Assertions.assertEquals(datasetReplyMessage, session.datasetReply)
|
|
||||||
|
|
||||||
// test datasetReply as array
|
session.populateBody(datasetReplyMessage)
|
||||||
val list: List<DatasetReplyMessage> = listOf(datasetReplyMessage)
|
|
||||||
session.datasetReply = null
|
assertThat(session.datasetReply).isEqualTo(datasetReplyMessage)
|
||||||
session.populateBody(list)
|
}
|
||||||
Assertions.assertEquals(datasetReplyMessage, session.datasetReply)
|
|
||||||
|
@Test
|
||||||
|
fun datasetReply_asList() {
|
||||||
|
val datasetReplyMessage = DatasetReplyMessage()
|
||||||
|
|
||||||
|
session.populateBody(listOf(datasetReplyMessage))
|
||||||
|
|
||||||
|
assertThat(session.datasetReply).isEqualTo(datasetReplyMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue