Rewrites ProfileStoreTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-19 22:28:55 -07:00
parent 7f1ba7e763
commit d90db860f0

View file

@ -1,47 +1,47 @@
package info.nightscout.implementation.profile
import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
internal class ProfileStoreTest : TestBaseWithProfile() {
@Test
fun getStartDateTest() {
Assertions.assertEquals(0, getValidProfileStore().getStartDate())
assertThat(getValidProfileStore().getStartDate()).isEqualTo(0)
}
@Test
fun getDefaultProfileTest() {
Assertions.assertTrue(getValidProfileStore().getDefaultProfile() is PureProfile)
assertThat(getValidProfileStore().getDefaultProfile()).isInstanceOf(PureProfile::class.java)
}
@Test
fun getDefaultProfileJsonTest() {
Assertions.assertTrue(getValidProfileStore().getDefaultProfileJson()?.has("dia") ?: false)
Assertions.assertEquals(null, getInvalidProfileStore2().getDefaultProfileJson())
assertThat(getValidProfileStore().getDefaultProfileJson()?.has("dia")).isTrue()
assertThat(getInvalidProfileStore2().getDefaultProfileJson()).isNull()
}
@Test
fun getDefaultProfileNameTest() {
Assertions.assertEquals(TESTPROFILENAME, getValidProfileStore().getDefaultProfileName())
assertThat(getValidProfileStore().getDefaultProfileName()).isEqualTo(TESTPROFILENAME)
}
@Test
fun getProfileListTest() {
Assertions.assertEquals(1, getValidProfileStore().getProfileList().size)
assertThat(getValidProfileStore().getProfileList()).hasSize(1)
}
@Test
fun getSpecificProfileTest() {
Assertions.assertTrue(getValidProfileStore().getSpecificProfile(TESTPROFILENAME) is PureProfile)
assertThat(getValidProfileStore().getSpecificProfile(TESTPROFILENAME)).isInstanceOf(PureProfile::class.java)
}
@Test
fun allProfilesValidTest() {
Assertions.assertTrue(getValidProfileStore().allProfilesValid)
Assertions.assertFalse(getInvalidProfileStore1().allProfilesValid)
Assertions.assertFalse(getInvalidProfileStore2().allProfilesValid)
assertThat(getValidProfileStore().allProfilesValid).isTrue()
assertThat(getInvalidProfileStore1().allProfilesValid).isFalse()
assertThat(getInvalidProfileStore2().allProfilesValid).isFalse()
}
}
}