From 88c38b8049bb1a8f34321cb60917ad9bfce50bf2 Mon Sep 17 00:00:00 2001 From: Ryan Haining Date: Sat, 23 Sep 2023 16:33:17 -0700 Subject: [PATCH] Replaces FunctionsTest assertThrows with assertFailsWith Related to #2745 --- .../pump/omnipod/dash/util/FunctionsTest.kt | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt index e6770f049c..5f4e57f9c3 100644 --- a/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt +++ b/pump/omnipod-dash/src/test/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/util/FunctionsTest.kt @@ -1,9 +1,10 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.util +import com.google.common.truth.Truth.assertThat import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.BasalProgram import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile.ProfileValue -import org.junit.Assert +import kotlin.test.assertFailsWith import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import org.mockito.Mockito @@ -44,12 +45,10 @@ class FunctionsTest { `when`(profile.getBasalValues()).thenReturn(emptyArray()) - Assert.assertThrows( - "Basal values should contain values", - java.lang.IllegalArgumentException::class.java - ) { + val exception = assertFailsWith { mapProfileToBasalProgram(profile) } + assertThat(exception.message).isEqualTo("Basal values should contain values") } @Test fun invalidProfileNonZeroOffset() { @@ -59,12 +58,10 @@ class FunctionsTest { arrayOf(ProfileValue(1800, 0.5)) ) - Assert.assertThrows( - "First basal segment start time should be 0", - java.lang.IllegalArgumentException::class.java - ) { + val exception = assertFailsWith { mapProfileToBasalProgram(profile) } + assertThat(exception.message).isEqualTo("First basal segment start time should be 0") } @Test fun invalidProfileMoreThan24Hours() { @@ -77,12 +74,10 @@ class FunctionsTest { ) ) - Assert.assertThrows( - "Basal segment start time can not be greater than 86400", - java.lang.IllegalArgumentException::class.java - ) { + val exception = assertFailsWith { mapProfileToBasalProgram(profile) } + assertThat(exception.message).isEqualTo("Basal segment start time can not be greater than 86400") } @Test fun invalidProfileNegativeOffset() { @@ -92,9 +87,10 @@ class FunctionsTest { arrayOf(ProfileValue(-1, 0.5)) ) - Assert.assertThrows("Basal segment start time can not be less than 0", IllegalArgumentException::class.java) { + val exception = assertFailsWith { mapProfileToBasalProgram(profile) } + assertThat(exception.message).isEqualTo("Basal segment start time can not be less than 0") } @Test fun roundsToSupportedPrecision() {