Rewrites DataBroadcastPluginTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-23 19:53:50 -07:00
parent 0731827b38
commit 55b90e57f2

View file

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