Rewrites ComparatorTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-10-04 21:01:49 -07:00
parent 11fa9f6539
commit 38c01372ee

View file

@ -1,35 +1,35 @@
package app.aaps.plugins.automation.elements package app.aaps.plugins.automation.elements
import app.aaps.plugins.automation.triggers.TriggerTestBase import app.aaps.plugins.automation.triggers.TriggerTestBase
import org.junit.jupiter.api.Assertions import com.google.common.truth.Truth.assertThat
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class ComparatorTest : TriggerTestBase() { class ComparatorTest : TriggerTestBase() {
@Test @Test
fun checkTest() { fun checkTest() {
Assertions.assertTrue(Comparator.Compare.IS_EQUAL.check(1, 1)) assertThat(Comparator.Compare.IS_EQUAL.check(1, 1)).isTrue()
Assertions.assertTrue(Comparator.Compare.IS_LESSER.check(1, 2)) assertThat(Comparator.Compare.IS_LESSER.check(1, 2)).isTrue()
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2)) assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(1, 2)).isTrue()
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2)) assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 2)).isTrue()
Assertions.assertTrue(Comparator.Compare.IS_GREATER.check(2, 1)) assertThat(Comparator.Compare.IS_GREATER.check(2, 1)).isTrue()
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1)) assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 1)).isTrue()
Assertions.assertTrue(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2)) assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(2, 2)).isTrue()
Assertions.assertFalse(Comparator.Compare.IS_LESSER.check(2, 1)) assertThat(Comparator.Compare.IS_LESSER.check(2, 1)).isFalse()
Assertions.assertFalse(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1)) assertThat(Comparator.Compare.IS_EQUAL_OR_LESSER.check(2, 1)).isFalse()
Assertions.assertFalse(Comparator.Compare.IS_GREATER.check(1, 2)) assertThat(Comparator.Compare.IS_GREATER.check(1, 2)).isFalse()
Assertions.assertFalse(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2)) assertThat(Comparator.Compare.IS_EQUAL_OR_GREATER.check(1, 2)).isFalse()
// Assertions.assertTrue(Comparator.Compare.IS_NOT_AVAILABLE.check<Int?>(1, null)) // assertThat(Comparator.Compare.IS_NOT_AVAILABLE.check<Int?>(1, null)).isTrue()
} }
@Test @Test
fun labelsTest() { fun labelsTest() {
Assertions.assertEquals(6, Comparator.Compare.labels(rh).size) assertThat(Comparator.Compare.labels(rh)).hasSize(6)
} }
@Test @Test
fun setValueTest() { fun setValueTest() {
val c: Comparator = Comparator(rh).setValue(Comparator.Compare.IS_EQUAL_OR_GREATER) val c: Comparator = Comparator(rh).setValue(Comparator.Compare.IS_EQUAL_OR_GREATER)
Assertions.assertEquals(Comparator.Compare.IS_EQUAL_OR_GREATER, c.value) assertThat(c.value).isEqualTo(Comparator.Compare.IS_EQUAL_OR_GREATER)
} }
} }