diff --git a/core/main/src/test/java/info/nightscout/core/data/DetailedBolusInfoTest.kt b/core/main/src/test/java/info/nightscout/core/data/DetailedBolusInfoTest.kt index 1f08b86191..dfb995168b 100644 --- a/core/main/src/test/java/info/nightscout/core/data/DetailedBolusInfoTest.kt +++ b/core/main/src/test/java/info/nightscout/core/data/DetailedBolusInfoTest.kt @@ -1,5 +1,6 @@ package info.nightscout.core.data +import com.google.common.truth.Truth.assertThat import android.content.Context import com.google.gson.Gson import info.nightscout.database.entities.Bolus @@ -8,7 +9,6 @@ import info.nightscout.database.entities.TherapyEvent import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.sharedtests.TestBase import org.apache.commons.lang3.builder.EqualsBuilder -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mock @@ -18,14 +18,14 @@ class DetailedBolusInfoTest : TestBase() { @Test fun toStringShouldBeOverloaded() { val detailedBolusInfo = DetailedBolusInfo() - Assertions.assertEquals(true, detailedBolusInfo.toJsonString().contains("insulin")) + assertThat(detailedBolusInfo.toJsonString()).contains("insulin") } @Test fun copyShouldCopyAllProperties() { val d1 = DetailedBolusInfo() d1.deliverAtTheLatest = 123 val d2 = d1.copy() - Assertions.assertTrue(EqualsBuilder.reflectionEquals(d2, d1, arrayListOf("id"))) + assertThat(EqualsBuilder.reflectionEquals(d2, d1, arrayListOf("id"))).isTrue() } private fun fromJsonString(json: String): DetailedBolusInfo = @@ -41,10 +41,10 @@ class DetailedBolusInfoTest : TestBase() { detailedBolusInfo.eventType = DetailedBolusInfo.EventType.BOLUS_WIZARD val serialized = detailedBolusInfo.toJsonString() val deserialized = fromJsonString(serialized) - Assertions.assertEquals(1L, deserialized.bolusCalculatorResult?.timestamp) - Assertions.assertEquals(DetailedBolusInfo.EventType.BOLUS_WIZARD, deserialized.eventType) + assertThat(deserialized.bolusCalculatorResult?.timestamp).isEqualTo(1L) + assertThat(deserialized.eventType).isEqualTo(DetailedBolusInfo.EventType.BOLUS_WIZARD) // Context should be excluded - Assertions.assertNull(deserialized.context) + assertThat(deserialized.context).isNull() } @Test @@ -56,12 +56,12 @@ class DetailedBolusInfoTest : TestBase() { detailedBolusInfo.glucoseType = DetailedBolusInfo.MeterType.FINGER val therapyEvent = detailedBolusInfo.createTherapyEvent() - Assertions.assertEquals(1000L, therapyEvent.timestamp) - Assertions.assertEquals(TherapyEvent.Type.MEAL_BOLUS, therapyEvent.type) - Assertions.assertEquals(TherapyEvent.GlucoseUnit.MGDL, therapyEvent.glucoseUnit) - Assertions.assertEquals("note", therapyEvent.note) - Assertions.assertEquals(180.0, therapyEvent.glucose) - Assertions.assertEquals(TherapyEvent.MeterType.FINGER, therapyEvent.glucoseType) + assertThat(therapyEvent.timestamp).isEqualTo(1000L) + assertThat(therapyEvent.type).isEqualTo(TherapyEvent.Type.MEAL_BOLUS) + assertThat(therapyEvent.glucoseUnit).isEqualTo(TherapyEvent.GlucoseUnit.MGDL) + assertThat(therapyEvent.note).isEqualTo("note") + assertThat(therapyEvent.glucose).isEqualTo(180.0) + assertThat(therapyEvent.glucoseType).isEqualTo(TherapyEvent.MeterType.FINGER) } @Test @@ -72,9 +72,9 @@ class DetailedBolusInfoTest : TestBase() { detailedBolusInfo.insulin = 7.0 val bolus = detailedBolusInfo.createBolus() - Assertions.assertEquals(1000L, bolus.timestamp) - Assertions.assertEquals(Bolus.Type.SMB, bolus.type) - Assertions.assertEquals(7.0, bolus.amount, 0.01) + assertThat(bolus.timestamp).isEqualTo(1000L) + assertThat(bolus.type).isEqualTo(Bolus.Type.SMB) + assertThat(bolus.amount).isWithin(0.01).of(7.0) } @Test @@ -84,8 +84,8 @@ class DetailedBolusInfoTest : TestBase() { detailedBolusInfo.carbs = 6.0 val carbs = detailedBolusInfo.createCarbs() - Assertions.assertEquals(1000L, carbs.timestamp) - Assertions.assertEquals(6.0, carbs.amount, 0.01) + assertThat(carbs.timestamp).isEqualTo(1000L) + assertThat(carbs.amount).isWithin(0.01).of(6.0) } private fun createBolusCalculatorResult(): BolusCalculatorResult = @@ -121,4 +121,4 @@ class DetailedBolusInfoTest : TestBase() { profileName = "profile", note = "" ) -} \ No newline at end of file +}