Rewrites DeviceStatusExtensionKtTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-23 20:47:02 -07:00
parent 4543988be9
commit c691884759

View file

@ -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())
} }
} }