Merge pull request #2829 from ryanhaining/assertthat_plugins_sync

Rewrites plugins/sync with matchers
This commit is contained in:
Milos Kozak 2023-09-24 10:34:33 +02:00 committed by GitHub
commit 550b3905e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 250 additions and 238 deletions

View file

@ -2,6 +2,7 @@ package info.nightscout.plugins.sync.dataBroadcaster
import app.aaps.shared.tests.BundleMock
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
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.rx.events.EventOverviewBolusProgress
import org.json.JSONObject
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers.anyLong
@ -81,37 +81,37 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() {
}
val bundle = BundleMock.mock()
sut.prepareData(event, bundle)
Assertions.assertTrue(bundle.containsKey("progressPercent"))
Assertions.assertTrue(bundle.containsKey("progressStatus"))
Assertions.assertTrue(bundle.containsKey("glucoseMgdl"))
Assertions.assertTrue(bundle.containsKey("glucoseTimeStamp"))
Assertions.assertTrue(bundle.containsKey("units"))
Assertions.assertTrue(bundle.containsKey("slopeArrow"))
Assertions.assertTrue(bundle.containsKey("deltaMgdl"))
Assertions.assertTrue(bundle.containsKey("avgDeltaMgdl"))
Assertions.assertTrue(bundle.containsKey("high"))
Assertions.assertTrue(bundle.containsKey("low"))
Assertions.assertTrue(bundle.containsKey("bolusIob"))
Assertions.assertTrue(bundle.containsKey("basalIob"))
Assertions.assertTrue(bundle.containsKey("iob"))
Assertions.assertTrue(bundle.containsKey("cob"))
Assertions.assertTrue(bundle.containsKey("futureCarbs"))
Assertions.assertTrue(bundle.containsKey("phoneBattery"))
Assertions.assertTrue(bundle.containsKey("rigBattery"))
Assertions.assertTrue(bundle.containsKey("suggestedTimeStamp"))
Assertions.assertTrue(bundle.containsKey("suggested"))
Assertions.assertTrue(bundle.containsKey("enactedTimeStamp"))
Assertions.assertTrue(bundle.containsKey("enacted"))
Assertions.assertTrue(bundle.containsKey("basalTimeStamp"))
Assertions.assertTrue(bundle.containsKey("baseBasal"))
Assertions.assertTrue(bundle.containsKey("profile"))
Assertions.assertTrue(bundle.containsKey("tempBasalStart"))
Assertions.assertTrue(bundle.containsKey("tempBasalDurationInMinutes"))
Assertions.assertTrue(bundle.containsKey("tempBasalString"))
Assertions.assertTrue(bundle.containsKey("pumpTimeStamp"))
Assertions.assertTrue(bundle.containsKey("pumpBattery"))
Assertions.assertTrue(bundle.containsKey("pumpReservoir"))
Assertions.assertTrue(bundle.containsKey("pumpStatus"))
assertThat(bundle.containsKey("progressPercent")).isTrue()
assertThat(bundle.containsKey("progressStatus")).isTrue()
assertThat(bundle.containsKey("glucoseMgdl")).isTrue()
assertThat(bundle.containsKey("glucoseTimeStamp")).isTrue()
assertThat(bundle.containsKey("units")).isTrue()
assertThat(bundle.containsKey("slopeArrow")).isTrue()
assertThat(bundle.containsKey("deltaMgdl")).isTrue()
assertThat(bundle.containsKey("avgDeltaMgdl")).isTrue()
assertThat(bundle.containsKey("high")).isTrue()
assertThat(bundle.containsKey("low")).isTrue()
assertThat(bundle.containsKey("bolusIob")).isTrue()
assertThat(bundle.containsKey("basalIob")).isTrue()
assertThat(bundle.containsKey("iob")).isTrue()
assertThat(bundle.containsKey("cob")).isTrue()
assertThat(bundle.containsKey("futureCarbs")).isTrue()
assertThat(bundle.containsKey("phoneBattery")).isTrue()
assertThat(bundle.containsKey("rigBattery")).isTrue()
assertThat(bundle.containsKey("suggestedTimeStamp")).isTrue()
assertThat(bundle.containsKey("suggested")).isTrue()
assertThat(bundle.containsKey("enactedTimeStamp")).isTrue()
assertThat(bundle.containsKey("enacted")).isTrue()
assertThat(bundle.containsKey("basalTimeStamp")).isTrue()
assertThat(bundle.containsKey("baseBasal")).isTrue()
assertThat(bundle.containsKey("profile")).isTrue()
assertThat(bundle.containsKey("tempBasalStart")).isTrue()
assertThat(bundle.containsKey("tempBasalDurationInMinutes")).isTrue()
assertThat(bundle.containsKey("tempBasalString")).isTrue()
assertThat(bundle.containsKey("pumpTimeStamp")).isTrue()
assertThat(bundle.containsKey("pumpBattery")).isTrue()
assertThat(bundle.containsKey("pumpReservoir")).isTrue()
assertThat(bundle.containsKey("pumpStatus")).isTrue()
}
@Test
@ -123,36 +123,36 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() {
}
val bundle = BundleMock.mock()
sut.prepareData(event, bundle)
Assertions.assertTrue(bundle.containsKey("progressPercent"))
Assertions.assertTrue(bundle.containsKey("progressStatus"))
Assertions.assertTrue(bundle.containsKey("glucoseMgdl"))
Assertions.assertTrue(bundle.containsKey("glucoseTimeStamp"))
Assertions.assertTrue(bundle.containsKey("units"))
Assertions.assertTrue(bundle.containsKey("slopeArrow"))
Assertions.assertTrue(bundle.containsKey("deltaMgdl"))
Assertions.assertTrue(bundle.containsKey("avgDeltaMgdl"))
Assertions.assertTrue(bundle.containsKey("high"))
Assertions.assertTrue(bundle.containsKey("low"))
Assertions.assertTrue(bundle.containsKey("bolusIob"))
Assertions.assertTrue(bundle.containsKey("basalIob"))
Assertions.assertTrue(bundle.containsKey("iob"))
Assertions.assertTrue(bundle.containsKey("cob"))
Assertions.assertTrue(bundle.containsKey("futureCarbs"))
Assertions.assertTrue(bundle.containsKey("phoneBattery"))
Assertions.assertTrue(bundle.containsKey("rigBattery"))
Assertions.assertTrue(bundle.containsKey("suggestedTimeStamp"))
Assertions.assertTrue(bundle.containsKey("suggested"))
Assertions.assertTrue(bundle.containsKey("enactedTimeStamp"))
Assertions.assertTrue(bundle.containsKey("enacted"))
Assertions.assertTrue(bundle.containsKey("basalTimeStamp"))
Assertions.assertTrue(bundle.containsKey("baseBasal"))
Assertions.assertTrue(bundle.containsKey("profile"))
Assertions.assertTrue(bundle.containsKey("tempBasalStart"))
Assertions.assertTrue(bundle.containsKey("tempBasalDurationInMinutes"))
Assertions.assertTrue(bundle.containsKey("tempBasalString"))
Assertions.assertTrue(bundle.containsKey("pumpTimeStamp"))
Assertions.assertTrue(bundle.containsKey("pumpBattery"))
Assertions.assertTrue(bundle.containsKey("pumpReservoir"))
Assertions.assertTrue(bundle.containsKey("pumpStatus"))
assertThat(bundle.containsKey("progressPercent")).isTrue()
assertThat(bundle.containsKey("progressStatus")).isTrue()
assertThat(bundle.containsKey("glucoseMgdl")).isTrue()
assertThat(bundle.containsKey("glucoseTimeStamp")).isTrue()
assertThat(bundle.containsKey("units")).isTrue()
assertThat(bundle.containsKey("slopeArrow")).isTrue()
assertThat(bundle.containsKey("deltaMgdl")).isTrue()
assertThat(bundle.containsKey("avgDeltaMgdl")).isTrue()
assertThat(bundle.containsKey("high")).isTrue()
assertThat(bundle.containsKey("low")).isTrue()
assertThat(bundle.containsKey("bolusIob")).isTrue()
assertThat(bundle.containsKey("basalIob")).isTrue()
assertThat(bundle.containsKey("iob")).isTrue()
assertThat(bundle.containsKey("cob")).isTrue()
assertThat(bundle.containsKey("futureCarbs")).isTrue()
assertThat(bundle.containsKey("phoneBattery")).isTrue()
assertThat(bundle.containsKey("rigBattery")).isTrue()
assertThat(bundle.containsKey("suggestedTimeStamp")).isTrue()
assertThat(bundle.containsKey("suggested")).isTrue()
assertThat(bundle.containsKey("enactedTimeStamp")).isTrue()
assertThat(bundle.containsKey("enacted")).isTrue()
assertThat(bundle.containsKey("basalTimeStamp")).isTrue()
assertThat(bundle.containsKey("baseBasal")).isTrue()
assertThat(bundle.containsKey("profile")).isTrue()
assertThat(bundle.containsKey("tempBasalStart")).isTrue()
assertThat(bundle.containsKey("tempBasalDurationInMinutes")).isTrue()
assertThat(bundle.containsKey("tempBasalString")).isTrue()
assertThat(bundle.containsKey("pumpTimeStamp")).isTrue()
assertThat(bundle.containsKey("pumpBattery")).isTrue()
assertThat(bundle.containsKey("pumpReservoir")).isTrue()
assertThat(bundle.containsKey("pumpStatus")).isTrue()
}
}

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.sync.nsclient
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.receivers.ReceiverStatusStore
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.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -33,12 +33,12 @@ class ReceiverDelegateTest : TestBase() {
fun testCalculateStatusChargingState() {
`when`(sp.getBoolean(R.string.key_ns_battery, true)).thenReturn(true)
`when`(sp.getBoolean(R.string.key_ns_charging, true)).thenReturn(false)
Assertions.assertTrue(sut.calculateStatus(EventChargingState(false, 0)))
Assertions.assertFalse(sut.calculateStatus(EventChargingState(true, 0)))
assertThat(sut.calculateStatus(EventChargingState(false, 0))).isTrue()
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_charging, true)).thenReturn(true)
Assertions.assertTrue(sut.calculateStatus(EventChargingState(true, 0)))
Assertions.assertFalse(sut.calculateStatus(EventChargingState(false, 0)))
assertThat(sut.calculateStatus(EventChargingState(true, 0))).isTrue()
assertThat(sut.calculateStatus(EventChargingState(false, 0))).isFalse()
}
@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_wifi, true)).thenReturn(true)
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("test 1")
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true)))
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true)))
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, wifiConnected = false, roaming = false))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = true, wifiConnected = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "<unknown ssid>", mobileConnected = false, wifiConnected = true))).isFalse()
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = true, wifiConnected = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(ssid = "test 1", mobileConnected = false, wifiConnected = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
`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_allow_roaming, true)).thenReturn(true)
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(wifiConnected = true)))
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange()))
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true)))
assertThat(sut.calculateStatus(EventNetworkChange(wifiConnected = true))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange())).isFalse()
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_wifi, true)).thenReturn(true)
`when`(sp.getBoolean(R.string.key_ns_allow_roaming, true)).thenReturn(false)
`when`(sp.getString(R.string.key_ns_wifi_ssids, "")).thenReturn("")
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
Assertions.assertFalse(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue()
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_wifi, 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("")
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false)))
Assertions.assertTrue(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true)))
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = false))).isTrue()
assertThat(sut.calculateStatus(EventNetworkChange(mobileConnected = true, roaming = true))).isTrue()
}
}

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.sync.nsclientV3
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
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.localmodel.treatment.CreateUpdateResponse
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -108,11 +108,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("devicestatus", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdDeviceStatuses.size)
assertThat(storeDataForDb.nsIdDeviceStatuses).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.createDeviceStatus(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsAdd("devicestatus", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdDeviceStatuses.size) // still only 1
assertThat(storeDataForDb.nsIdDeviceStatuses).hasSize(2) // still only 1
}
@Test
@ -134,11 +134,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createSgv(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("entries", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdGlucoseValues.size)
assertThat(storeDataForDb.nsIdGlucoseValues).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateSvg(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("entries", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdGlucoseValues.size)
assertThat(storeDataForDb.nsIdGlucoseValues).hasSize(2)
}
@Test
@ -164,11 +164,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createFood(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("food", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdFoods.size)
assertThat(storeDataForDb.nsIdFoods).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateFood(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("food", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdFoods.size)
assertThat(storeDataForDb.nsIdFoods).hasSize(2)
}
@Test
@ -192,11 +192,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdBoluses.size)
assertThat(storeDataForDb.nsIdBoluses).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdBoluses.size)
assertThat(storeDataForDb.nsIdBoluses).hasSize(2)
}
@Test
@ -219,11 +219,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdCarbs.size)
assertThat(storeDataForDb.nsIdCarbs).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdCarbs.size)
assertThat(storeDataForDb.nsIdCarbs).hasSize(2)
}
@Test
@ -272,11 +272,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdBolusCalculatorResults.size)
assertThat(storeDataForDb.nsIdBolusCalculatorResults).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdBolusCalculatorResults.size)
assertThat(storeDataForDb.nsIdBolusCalculatorResults).hasSize(2)
}
@Test
@ -310,11 +310,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdEffectiveProfileSwitches.size)
assertThat(storeDataForDb.nsIdEffectiveProfileSwitches).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdEffectiveProfileSwitches.size)
assertThat(storeDataForDb.nsIdEffectiveProfileSwitches).hasSize(2)
}
@Test
@ -346,11 +346,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdProfileSwitches.size)
assertThat(storeDataForDb.nsIdProfileSwitches).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdProfileSwitches.size)
assertThat(storeDataForDb.nsIdProfileSwitches).hasSize(2)
}
@Test
@ -373,11 +373,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3", validProfile)
Assertions.assertEquals(1, storeDataForDb.nsIdExtendedBoluses.size)
assertThat(storeDataForDb.nsIdExtendedBoluses).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3", validProfile)
Assertions.assertEquals(2, storeDataForDb.nsIdExtendedBoluses.size)
assertThat(storeDataForDb.nsIdExtendedBoluses).hasSize(2)
}
@Test
@ -399,11 +399,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdOfflineEvents.size)
assertThat(storeDataForDb.nsIdOfflineEvents).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdOfflineEvents.size)
assertThat(storeDataForDb.nsIdOfflineEvents).hasSize(2)
}
@Test
@ -427,11 +427,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3", validProfile)
Assertions.assertEquals(1, storeDataForDb.nsIdTemporaryBasals.size)
assertThat(storeDataForDb.nsIdTemporaryBasals).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3", validProfile)
Assertions.assertEquals(2, storeDataForDb.nsIdTemporaryBasals.size)
assertThat(storeDataForDb.nsIdTemporaryBasals).hasSize(2)
}
@Test
@ -455,11 +455,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdTemporaryTargets.size)
assertThat(storeDataForDb.nsIdTemporaryTargets).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdTemporaryTargets.size)
assertThat(storeDataForDb.nsIdTemporaryTargets).hasSize(2)
}
@Test
@ -486,11 +486,11 @@ internal class NSClientV3PluginTest : TestBaseWithProfile() {
// create
Mockito.`when`(nsAndroidClient.createTreatment(anyObject())).thenReturn(CreateUpdateResponse(201, "aaa"))
sut.nsAdd("treatments", dataPair, "1/3")
Assertions.assertEquals(1, storeDataForDb.nsIdTherapyEvents.size)
assertThat(storeDataForDb.nsIdTherapyEvents).hasSize(1)
// update
Mockito.`when`(nsAndroidClient.updateTreatment(anyObject())).thenReturn(CreateUpdateResponse(200, "aaa"))
sut.nsUpdate("treatments", dataPair, "1/3")
Assertions.assertEquals(2, storeDataForDb.nsIdTherapyEvents.size)
assertThat(storeDataForDb.nsIdTherapyEvents).hasSize(2)
}
@Test

View file

@ -1,10 +1,10 @@
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.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSBolusWizard
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -53,7 +53,7 @@ internal class BolusCalculatorResultExtensionKtTest {
)
val bolus2 = (bolus.toNSBolusWizard().convertToRemoteAndBack() as NSBolusWizard).toBolusCalculatorResult()!!
Assertions.assertTrue(bolus.contentEqualsTo(bolus2))
Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2))
assertThat(bolus.contentEqualsTo(bolus2)).isTrue()
assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue()
}
}

View file

@ -1,10 +1,10 @@
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.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSBolus
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@ -29,8 +29,8 @@ internal class BolusExtensionKtTest {
)
var bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus()
Assertions.assertTrue(bolus.contentEqualsTo(bolus2))
Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2))
assertThat(bolus.contentEqualsTo(bolus2)).isTrue()
assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue()
bolus = Bolus(
timestamp = 10000,
@ -48,7 +48,7 @@ internal class BolusExtensionKtTest {
)
bolus2 = (bolus.toNSBolus().convertToRemoteAndBack() as NSBolus).toBolus()
Assertions.assertTrue(bolus.contentEqualsTo(bolus2))
Assertions.assertTrue(bolus.interfaceIdsEqualsTo(bolus2))
assertThat(bolus.contentEqualsTo(bolus2)).isTrue()
assertThat(bolus.interfaceIdsEqualsTo(bolus2)).isTrue()
}
}

View file

@ -1,10 +1,10 @@
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.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSCarbs
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -27,8 +27,8 @@ internal class CarbsExtensionKtTest {
)
var carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs()
Assertions.assertTrue(carbs.contentEqualsTo(carbs2))
Assertions.assertTrue(carbs.interfaceIdsEqualsTo(carbs2))
assertThat(carbs.contentEqualsTo(carbs2)).isTrue()
assertThat(carbs.interfaceIdsEqualsTo(carbs2)).isTrue()
carbs = Carbs(
timestamp = 10000,
@ -45,7 +45,7 @@ internal class CarbsExtensionKtTest {
)
carbs2 = (carbs.toNSCarbs().convertToRemoteAndBack() as NSCarbs).toCarbs()
Assertions.assertTrue(carbs.contentEqualsTo(carbs2))
Assertions.assertTrue(carbs.interfaceIdsEqualsTo(carbs2))
assertThat(carbs.contentEqualsTo(carbs2)).isTrue()
assertThat(carbs.interfaceIdsEqualsTo(carbs2)).isTrue()
}
}

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.DeviceStatus
import info.nightscout.interfaces.Config
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.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -57,20 +57,20 @@ internal class DeviceStatusExtensionKtTest : TestBase() {
val nsDeviceStatus = deviceStatus.toNSDeviceStatus()
nsDeviceStatusHandler.handleNewData(arrayOf(nsDeviceStatus))
Assertions.assertEquals(75, processedDeviceStatusData.pumpData?.percent)
assertThat(processedDeviceStatusData.pumpData!!.percent).isEqualTo(75)
val nsDeviceStatus2 = nsDeviceStatus.convertToRemoteAndBack()
Assertions.assertTrue(nsDeviceStatus.device == nsDeviceStatus2.device)
Assertions.assertTrue(nsDeviceStatus.identifier == nsDeviceStatus2.identifier)
Assertions.assertTrue(nsDeviceStatus.srvCreated == nsDeviceStatus2.srvCreated)
Assertions.assertTrue(nsDeviceStatus.srvModified == nsDeviceStatus2.srvModified)
Assertions.assertTrue(nsDeviceStatus.createdAt == nsDeviceStatus2.createdAt)
Assertions.assertTrue(nsDeviceStatus.date == nsDeviceStatus2.date)
Assertions.assertTrue(nsDeviceStatus.uploaderBattery == nsDeviceStatus2.uploaderBattery)
Assertions.assertTrue(nsDeviceStatus.device == nsDeviceStatus2.device)
Assertions.assertTrue(nsDeviceStatus.uploader?.battery == nsDeviceStatus2.uploader?.battery)
Assertions.assertTrue(nsDeviceStatus.pump?.battery == nsDeviceStatus2.pump?.battery)
Assertions.assertTrue(nsDeviceStatus.openaps?.enacted?.toString() == nsDeviceStatus2.openaps?.enacted?.toString())
Assertions.assertTrue(nsDeviceStatus.configuration?.toString() == nsDeviceStatus2.configuration?.toString())
assertThat(nsDeviceStatus2.device).isEqualTo(nsDeviceStatus.device)
assertThat(nsDeviceStatus2.identifier).isEqualTo(nsDeviceStatus.identifier)
assertThat(nsDeviceStatus2.srvCreated).isEqualTo(nsDeviceStatus.srvCreated)
assertThat(nsDeviceStatus2.srvModified).isEqualTo(nsDeviceStatus.srvModified)
assertThat(nsDeviceStatus2.createdAt).isEqualTo(nsDeviceStatus.createdAt)
assertThat(nsDeviceStatus2.date).isEqualTo(nsDeviceStatus.date)
assertThat(nsDeviceStatus2.uploaderBattery).isEqualTo(nsDeviceStatus.uploaderBattery)
assertThat(nsDeviceStatus2.device).isEqualTo(nsDeviceStatus.device)
assertThat(nsDeviceStatus2.uploader?.battery).isEqualTo(nsDeviceStatus.uploader?.battery)
assertThat(nsDeviceStatus2.pump?.battery).isEqualTo(nsDeviceStatus.pump?.battery)
assertThat(nsDeviceStatus2.openaps?.enacted?.toString()).isEqualTo(nsDeviceStatus.openaps?.enacted?.toString())
assertThat(nsDeviceStatus2.configuration?.toString()).isEqualTo(nsDeviceStatus.configuration?.toString())
}
}

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.EffectiveProfileSwitch
import info.nightscout.database.entities.embedments.InsulinConfiguration
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.sdk.localmodel.treatment.NSEffectiveProfileSwitch
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -55,7 +55,7 @@ internal class EffectiveProfileSwitchExtensionKtTest : TestBaseWithProfile() {
)
val profileSwitch2 = (profileSwitch.toNSEffectiveProfileSwitch(dateUtil).convertToRemoteAndBack() as NSEffectiveProfileSwitch).toEffectiveProfileSwitch(dateUtil)!!
Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2))
Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2))
assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue()
assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue()
}
}

View file

@ -1,12 +1,12 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSExtendedBolus
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -29,8 +29,8 @@ internal class ExtendedBolusExtensionKtTest : TestBaseWithProfile() {
)
var extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus()
Assertions.assertTrue(extendedBolus.contentEqualsTo(extendedBolus2))
Assertions.assertTrue(extendedBolus.interfaceIdsEqualsTo(extendedBolus2))
assertThat(extendedBolus.contentEqualsTo(extendedBolus2)).isTrue()
assertThat(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)).isTrue()
extendedBolus = ExtendedBolus(
timestamp = 10000,
@ -47,13 +47,13 @@ internal class ExtendedBolusExtensionKtTest : TestBaseWithProfile() {
)
val converted = extendedBolus.toNSExtendedBolus(validProfile)
Assertions.assertTrue(converted is NSTemporaryBasal)
Assertions.assertNotNull((converted as NSTemporaryBasal).extendedEmulated)
assertThat(converted).isInstanceOf(NSTemporaryBasal::class.java)
assertThat((converted as NSTemporaryBasal).extendedEmulated).isNotNull()
val convertedBack = converted.convertToRemoteAndBack()
Assertions.assertTrue(convertedBack is NSExtendedBolus)
assertThat(convertedBack).isInstanceOf(NSExtendedBolus::class.java)
extendedBolus2 = (extendedBolus.toNSExtendedBolus(validProfile).convertToRemoteAndBack() as NSExtendedBolus).toExtendedBolus()
Assertions.assertTrue(extendedBolus.contentEqualsTo(extendedBolus2))
Assertions.assertTrue(extendedBolus.interfaceIdsEqualsTo(extendedBolus2))
assertThat(extendedBolus.contentEqualsTo(extendedBolus2)).isTrue()
assertThat(extendedBolus.interfaceIdsEqualsTo(extendedBolus2)).isTrue()
}
}

View file

@ -1,10 +1,10 @@
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.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.food.NSFood
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -30,7 +30,7 @@ internal class FoodExtensionKtTest {
)
val food2 = (food.toNSFood().convertToRemoteAndBack() as NSFood).toFood()
Assertions.assertTrue(food.contentEqualsTo(food2))
Assertions.assertTrue(food.interfaceIdsEqualsTo(food2))
assertThat(food.contentEqualsTo(food2)).isTrue()
assertThat(food.interfaceIdsEqualsTo(food2)).isTrue()
}
}

View file

@ -1,10 +1,10 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
internal class GlucoseValueExtensionKtTest : TestBaseWithProfile() {
@ -25,7 +25,7 @@ internal class GlucoseValueExtensionKtTest : TestBaseWithProfile() {
)
val glucoseValue2 = glucoseValue.toNSSvgV3().convertToRemoteAndBack()?.toTransactionGlucoseValue()?.toGlucoseValue()
Assertions.assertTrue(glucoseValue.contentEqualsTo(glucoseValue2!!))
Assertions.assertTrue(glucoseValue.interfaceIdsEqualsTo(glucoseValue2))
assertThat(glucoseValue.contentEqualsTo(glucoseValue2!!)).isTrue()
assertThat(glucoseValue.interfaceIdsEqualsTo(glucoseValue2)).isTrue()
}
}

View file

@ -1,10 +1,10 @@
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.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSOfflineEvent
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -26,8 +26,8 @@ internal class OfflineEventExtensionKtTest {
)
var offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2))
Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2))
assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue()
assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue()
offlineEvent = OfflineEvent(
timestamp = 10000,
@ -43,8 +43,8 @@ internal class OfflineEventExtensionKtTest {
)
offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2))
Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2))
assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue()
assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue()
offlineEvent = OfflineEvent(
timestamp = 10000,
@ -60,7 +60,7 @@ internal class OfflineEventExtensionKtTest {
)
offlineEvent2 = (offlineEvent.toNSOfflineEvent().convertToRemoteAndBack() as NSOfflineEvent).toOfflineEvent()
Assertions.assertTrue(offlineEvent.contentEqualsTo(offlineEvent2))
Assertions.assertTrue(offlineEvent.interfaceIdsEqualsTo(offlineEvent2))
assertThat(offlineEvent.contentEqualsTo(offlineEvent2)).isTrue()
assertThat(offlineEvent.interfaceIdsEqualsTo(offlineEvent2)).isTrue()
}
}

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.core.extensions.fromConstant
import info.nightscout.database.entities.ProfileSwitch
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.sdk.localmodel.treatment.NSProfileSwitch
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -53,8 +53,8 @@ internal class ProfileSwitchExtensionKtTest : TestBaseWithProfile() {
)
var profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!!
Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2))
Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2))
assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue()
assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue()
profileSwitch = ProfileSwitch(
timestamp = 10000,
@ -80,7 +80,7 @@ internal class ProfileSwitchExtensionKtTest : TestBaseWithProfile() {
)
profileSwitch2 = (profileSwitch.toNSProfileSwitch(dateUtil, decimalFormatter).convertToRemoteAndBack() as NSProfileSwitch).toProfileSwitch(activePlugin, dateUtil)!!
Assertions.assertTrue(profileSwitch.contentEqualsTo(profileSwitch2))
Assertions.assertTrue(profileSwitch.interfaceIdsEqualsTo(profileSwitch2))
assertThat(profileSwitch.contentEqualsTo(profileSwitch2)).isTrue()
assertThat(profileSwitch.interfaceIdsEqualsTo(profileSwitch2)).isTrue()
}
}

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -29,8 +29,8 @@ internal class TemporaryBasalExtensionKtTest : TestBaseWithProfile() {
)
var temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal()
Assertions.assertTrue(temporaryBasal.contentEqualsTo(temporaryBasal2))
Assertions.assertTrue(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2))
assertThat(temporaryBasal.contentEqualsTo(temporaryBasal2)).isTrue()
assertThat(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)).isTrue()
temporaryBasal = TemporaryBasal(
timestamp = 10000,
@ -48,7 +48,7 @@ internal class TemporaryBasalExtensionKtTest : TestBaseWithProfile() {
)
temporaryBasal2 = (temporaryBasal.toNSTemporaryBasal(validProfile).convertToRemoteAndBack() as NSTemporaryBasal).toTemporaryBasal()
Assertions.assertTrue(temporaryBasal.contentEqualsTo(temporaryBasal2))
Assertions.assertTrue(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2))
assertThat(temporaryBasal.contentEqualsTo(temporaryBasal2)).isTrue()
assertThat(temporaryBasal.interfaceIdsEqualsTo(temporaryBasal2)).isTrue()
}
}

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSTemporaryTarget
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -29,8 +29,8 @@ internal class TemporaryTargetExtensionKtTest : TestBaseWithProfile() {
)
var temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget()
Assertions.assertTrue(temporaryTarget.contentEqualsTo(temporaryTarget2))
Assertions.assertTrue(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2))
assertThat(temporaryTarget.contentEqualsTo(temporaryTarget2)).isTrue()
assertThat(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)).isTrue()
temporaryTarget = TemporaryTarget(
timestamp = 10000,
@ -48,7 +48,7 @@ internal class TemporaryTargetExtensionKtTest : TestBaseWithProfile() {
)
temporaryTarget2 = (temporaryTarget.toNSTemporaryTarget().convertToRemoteAndBack() as NSTemporaryTarget).toTemporaryTarget()
Assertions.assertTrue(temporaryTarget.contentEqualsTo(temporaryTarget2))
Assertions.assertTrue(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2))
assertThat(temporaryTarget.contentEqualsTo(temporaryTarget2)).isTrue()
assertThat(temporaryTarget.interfaceIdsEqualsTo(temporaryTarget2)).isTrue()
}
}

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSTherapyEvent
import info.nightscout.sdk.mapper.convertToRemoteAndBack
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
@ -32,8 +32,8 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() {
)
var therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2))
Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2))
assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue()
assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue()
therapyEvent = TherapyEvent(
@ -55,8 +55,8 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() {
)
therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2))
Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2))
assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue()
assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue()
therapyEvent = TherapyEvent(
timestamp = 10000,
@ -77,7 +77,7 @@ internal class TherapyEventExtensionKtTest : TestBaseWithProfile() {
)
therapyEvent2 = (therapyEvent.toNSTherapyEvent().convertToRemoteAndBack() as NSTherapyEvent).toTherapyEvent()
Assertions.assertTrue(therapyEvent.contentEqualsTo(therapyEvent2))
Assertions.assertTrue(therapyEvent.interfaceIdsEqualsTo(therapyEvent2))
assertThat(therapyEvent.contentEqualsTo(therapyEvent2)).isTrue()
assertThat(therapyEvent.interfaceIdsEqualsTo(therapyEvent2)).isTrue()
}
}

View file

@ -4,6 +4,7 @@ import android.content.Context
import androidx.work.ListenableWorker.Result.Success
import androidx.work.testing.TestListenableWorkerBuilder
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
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 kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@ -64,6 +64,6 @@ internal class DataSyncWorkerTest : TestBase() {
`when`(nsClient.hasWritePermission).thenReturn(true)
val result = sut.doWorkAndLog()
Mockito.verify(dataSyncSelectorV3, Mockito.times(1)).doUpload()
Assertions.assertTrue(result is Success)
assertThat(result).isInstanceOf(Success::class.java)
}
}

View file

@ -7,6 +7,7 @@ import androidx.work.WorkContinuation
import androidx.work.WorkManager
import androidx.work.testing.TestListenableWorkerBuilder
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
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.utils.DateUtil
import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers.any
@ -111,7 +111,7 @@ internal class LoadBgWorkerTest : TestBase() {
sut = TestListenableWorkerBuilder<LoadBgWorker>(context).build()
val result = sut.doWorkAndLog()
Assertions.assertTrue(result is ListenableWorker.Result.Failure)
assertThat(result).isInstanceOf(ListenableWorker.Result.Failure::class.java)
}
@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)
val result = sut.doWorkAndLog()
Assertions.assertTrue(result is ListenableWorker.Result.Success)
Assertions.assertTrue(result.outputData.getString("Result") == "Load not enabled")
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
assertThat(result.outputData.getString("Result")).isEqualTo("Load not enabled")
}
@Test
@ -136,8 +136,8 @@ internal class LoadBgWorkerTest : TestBase() {
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList()))
val result = sut.doWorkAndLog()
Assertions.assertEquals(now - 1000, nsClientV3Plugin.lastLoadedSrvModified.collections.entries)
Assertions.assertTrue(result is ListenableWorker.Result.Success)
assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000)
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
}
@Test
@ -165,7 +165,7 @@ internal class LoadBgWorkerTest : TestBase() {
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, listOf(glucoseValue.toNSSvgV3())))
val result = sut.doWorkAndLog()
Assertions.assertTrue(result is ListenableWorker.Result.Success)
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
}
@Test
@ -179,7 +179,7 @@ internal class LoadBgWorkerTest : TestBase() {
Mockito.`when`(nsAndroidClient.getSgvsNewerThan(anyLong(), anyInt())).thenReturn(NSAndroidClient.ReadResponse(200, 0, emptyList()))
val result = sut.doWorkAndLog()
Assertions.assertEquals(now - 1000, nsClientV3Plugin.lastLoadedSrvModified.collections.entries)
Assertions.assertTrue(result is ListenableWorker.Result.Success)
assertThat(nsClientV3Plugin.lastLoadedSrvModified.collections.entries).isEqualTo(now - 1000)
assertThat(result).isInstanceOf(ListenableWorker.Result.Success::class.java)
}
}

View file

@ -1,32 +1,44 @@
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.DatasetReplyMessage
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
class SessionTest {
private val session = Session("", "", null)
@Test
fun populateBody() {
val session = Session("", "", null)
Assertions.assertNull(session.authReply)
fun emptySession() {
assertThat(session.authReply).isNull()
assertThat(session.datasetReply).isNull()
}
// test authReply
@Test
fun authReply() {
val authReplyMessage = AuthReplyMessage()
session.populateBody(authReplyMessage)
Assertions.assertEquals(authReplyMessage, session.authReply)
// test datasetReply
assertThat(session.authReply).isEqualTo(authReplyMessage)
}
@Test
fun datasetReply() {
val datasetReplyMessage = DatasetReplyMessage()
Assertions.assertNull(session.datasetReply)
session.populateBody(datasetReplyMessage)
Assertions.assertEquals(datasetReplyMessage, session.datasetReply)
// test datasetReply as array
val list: List<DatasetReplyMessage> = listOf(datasetReplyMessage)
session.datasetReply = null
session.populateBody(list)
Assertions.assertEquals(datasetReplyMessage, session.datasetReply)
session.populateBody(datasetReplyMessage)
assertThat(session.datasetReply).isEqualTo(datasetReplyMessage)
}
@Test
fun datasetReply_asList() {
val datasetReplyMessage = DatasetReplyMessage()
session.populateBody(listOf(datasetReplyMessage))
assertThat(session.datasetReply).isEqualTo(datasetReplyMessage)
}
}