Rewrites SmsTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-23 18:54:34 -07:00
parent 2975da80c2
commit 5a3fb2442a

View file

@ -2,8 +2,8 @@ package info.nightscout.plugins.general.smsCommunicator
import android.telephony.SmsMessage import android.telephony.SmsMessage
import app.aaps.shared.tests.TestBase import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.smsCommunicator.Sms import info.nightscout.interfaces.smsCommunicator.Sms
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mockito import org.mockito.Mockito
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
@ -15,32 +15,32 @@ class SmsTest : TestBase() {
`when`(smsMessage.originatingAddress).thenReturn("aNumber") `when`(smsMessage.originatingAddress).thenReturn("aNumber")
`when`(smsMessage.messageBody).thenReturn("aBody") `when`(smsMessage.messageBody).thenReturn("aBody")
var sms = Sms(smsMessage) var sms = Sms(smsMessage)
Assertions.assertEquals(sms.phoneNumber, "aNumber") assertThat(sms.phoneNumber).isEqualTo("aNumber")
Assertions.assertEquals(sms.text, "aBody") assertThat(sms.text).isEqualTo("aBody")
Assertions.assertTrue(sms.received) assertThat(sms.received).isTrue()
sms = Sms("aNumber", "aBody") sms = Sms("aNumber", "aBody")
Assertions.assertEquals(sms.phoneNumber, "aNumber") assertThat(sms.phoneNumber).isEqualTo("aNumber")
Assertions.assertEquals(sms.text, "aBody") assertThat(sms.text).isEqualTo("aBody")
Assertions.assertTrue(sms.sent) assertThat(sms.sent).isTrue()
sms = Sms("aNumber", "U") sms = Sms("aNumber", "U")
Assertions.assertEquals(sms.phoneNumber, "aNumber") assertThat(sms.phoneNumber).isEqualTo("aNumber")
Assertions.assertEquals(sms.text, "U") assertThat(sms.text).isEqualTo("U")
Assertions.assertTrue(sms.sent) assertThat(sms.sent).isTrue()
Assertions.assertEquals(sms.toString(), "SMS from aNumber: U") assertThat(sms.toString()).isEqualTo("SMS from aNumber: U")
// copy constructor #1 // copy constructor #1
val sms2 = Sms(sms) val sms2 = Sms(sms)
Assertions.assertEquals(sms2.phoneNumber, "aNumber") assertThat(sms2.phoneNumber).isEqualTo("aNumber")
Assertions.assertEquals(sms2.text, "U") assertThat(sms2.text).isEqualTo("U")
Assertions.assertTrue(sms2.sent) assertThat(sms2.sent).isTrue()
Assertions.assertEquals(sms2.toString(), "SMS from aNumber: U") assertThat(sms2.toString()).isEqualTo("SMS from aNumber: U")
// copy constructor #2 // copy constructor #2
val sms3 = Sms(sms, "different") val sms3 = Sms(sms, "different")
Assertions.assertEquals(sms3.phoneNumber, "different") assertThat(sms3.phoneNumber).isEqualTo("different")
Assertions.assertEquals(sms3.text, "U") assertThat(sms3.text).isEqualTo("U")
Assertions.assertTrue(sms3.sent) assertThat(sms3.sent).isTrue()
Assertions.assertEquals(sms3.toString(), "SMS from different: U") assertThat(sms3.toString()).isEqualTo("SMS from different: U")
} }
} }