parent
ff63b72707
commit
7f1ba7e763
1 changed files with 14 additions and 14 deletions
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.implementation.overview
|
package info.nightscout.implementation.overview
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.database.ValueWrapper
|
import info.nightscout.database.ValueWrapper
|
||||||
import info.nightscout.database.entities.GlucoseValue
|
import info.nightscout.database.entities.GlucoseValue
|
||||||
import info.nightscout.database.impl.AppRepository
|
import info.nightscout.database.impl.AppRepository
|
||||||
|
@ -10,7 +11,6 @@ import info.nightscout.interfaces.profile.DefaultValueHelper
|
||||||
import info.nightscout.shared.utils.T
|
import info.nightscout.shared.utils.T
|
||||||
import info.nightscout.sharedtests.TestBaseWithProfile
|
import info.nightscout.sharedtests.TestBaseWithProfile
|
||||||
import io.reactivex.rxjava3.core.Single
|
import io.reactivex.rxjava3.core.Single
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
|
@ -43,23 +43,23 @@ class OverviewDataImplTest : TestBaseWithProfile() {
|
||||||
// no data
|
// no data
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
||||||
Assertions.assertNull(sut.lastBg(autosensDataStore))
|
assertThat(sut.lastBg(autosensDataStore)).isNull()
|
||||||
Assertions.assertFalse(sut.isLow(autosensDataStore))
|
assertThat(sut.isLow(autosensDataStore)).isFalse()
|
||||||
Assertions.assertFalse(sut.isHigh(autosensDataStore))
|
assertThat(sut.isHigh(autosensDataStore)).isFalse()
|
||||||
|
|
||||||
// no bucketed but in db
|
// no bucketed but in db
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
||||||
Assertions.assertEquals(200.0, sut.lastBg(autosensDataStore)?.value)
|
assertThat(sut.lastBg(autosensDataStore)?.value).isEqualTo(200.0)
|
||||||
Assertions.assertFalse(sut.isLow(autosensDataStore))
|
assertThat(sut.isLow(autosensDataStore)).isFalse()
|
||||||
Assertions.assertTrue(sut.isHigh(autosensDataStore))
|
assertThat(sut.isHigh(autosensDataStore)).isTrue()
|
||||||
|
|
||||||
// in bucketed
|
// in bucketed
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(bucketedData)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(bucketedData)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
||||||
Assertions.assertEquals(70.0, sut.lastBg(autosensDataStore)?.value)
|
assertThat(sut.lastBg(autosensDataStore)?.value).isEqualTo(70.0)
|
||||||
Assertions.assertTrue(sut.isLow(autosensDataStore))
|
assertThat(sut.isLow(autosensDataStore)).isTrue()
|
||||||
Assertions.assertFalse(sut.isHigh(autosensDataStore))
|
assertThat(sut.isHigh(autosensDataStore)).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -68,13 +68,13 @@ class OverviewDataImplTest : TestBaseWithProfile() {
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Existing(glucoseValue)))
|
||||||
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(1).msecs())
|
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(1).msecs())
|
||||||
Assertions.assertTrue(sut.isActualBg(autosensDataStore))
|
assertThat(sut.isActualBg(autosensDataStore)).isTrue()
|
||||||
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(9).msecs() + 1)
|
Mockito.`when`(dateUtil.now()).thenReturn(time + T.mins(9).msecs() + 1)
|
||||||
Assertions.assertFalse(sut.isActualBg(autosensDataStore))
|
assertThat(sut.isActualBg(autosensDataStore)).isFalse()
|
||||||
|
|
||||||
// no data
|
// no data
|
||||||
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
Mockito.`when`(autosensDataStore.bucketedData).thenReturn(null)
|
||||||
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
Mockito.`when`(repository.getLastGlucoseValueWrapped()).thenReturn(Single.just(ValueWrapper.Absent()))
|
||||||
Assertions.assertFalse(sut.isActualBg(autosensDataStore))
|
assertThat(sut.isActualBg(autosensDataStore)).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue