Added testing of adjusting to referenceTime
This commit is contained in:
parent
dfdb7857f6
commit
2559b7cce7
1 changed files with 55 additions and 0 deletions
|
@ -643,6 +643,61 @@ class AutosensDataStoreTest : TestBase() {
|
||||||
Assertions.assertEquals(90.0, autosensDataStore.bucketedData!![1].value, 1.0)
|
Assertions.assertEquals(90.0, autosensDataStore.bucketedData!![1].value, 1.0)
|
||||||
Assertions.assertEquals(50.0, autosensDataStore.bucketedData!![5].value, 1.0)
|
Assertions.assertEquals(50.0, autosensDataStore.bucketedData!![5].value, 1.0)
|
||||||
Assertions.assertEquals(40.0, autosensDataStore.bucketedData!![6].value, 1.0)
|
Assertions.assertEquals(40.0, autosensDataStore.bucketedData!![6].value, 1.0)
|
||||||
|
|
||||||
|
// non 5min data not aligned to referenceTime should be recalculated to referenceTime
|
||||||
|
autosensDataStore.referenceTime = T.mins(5).msecs()
|
||||||
|
bgReadingList.clear()
|
||||||
|
bgReadingList.add(
|
||||||
|
GlucoseValue(
|
||||||
|
raw = 0.0,
|
||||||
|
noise = 0.0,
|
||||||
|
value = 100.0,
|
||||||
|
timestamp = T.mins(48).msecs(),
|
||||||
|
sourceSensor = GlucoseValue.SourceSensor.UNKNOWN,
|
||||||
|
trendArrow = GlucoseValue.TrendArrow.FLAT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
bgReadingList.add(
|
||||||
|
GlucoseValue(
|
||||||
|
raw = 0.0,
|
||||||
|
noise = 0.0,
|
||||||
|
value = 98.0,
|
||||||
|
timestamp = T.mins(42).msecs(),
|
||||||
|
sourceSensor = GlucoseValue.SourceSensor.UNKNOWN,
|
||||||
|
trendArrow = GlucoseValue.TrendArrow.FLAT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
bgReadingList.add(
|
||||||
|
GlucoseValue(
|
||||||
|
raw = 0.0,
|
||||||
|
noise = 0.0,
|
||||||
|
value = 90.0,
|
||||||
|
timestamp = T.mins(40).msecs(),
|
||||||
|
sourceSensor = GlucoseValue.SourceSensor.UNKNOWN,
|
||||||
|
trendArrow = GlucoseValue.TrendArrow.FLAT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
bgReadingList.add(
|
||||||
|
GlucoseValue(
|
||||||
|
raw = 0.0,
|
||||||
|
noise = 0.0,
|
||||||
|
value = 40.0,
|
||||||
|
timestamp = T.mins(18).msecs(),
|
||||||
|
sourceSensor = GlucoseValue.SourceSensor.UNKNOWN,
|
||||||
|
trendArrow = GlucoseValue.TrendArrow.FLAT
|
||||||
|
)
|
||||||
|
)
|
||||||
|
autosensDataStore.bgReadings = bgReadingList
|
||||||
|
Assertions.assertEquals(false, autosensDataStore.isAbout5minData(aapsLogger))
|
||||||
|
autosensDataStore.createBucketedData(aapsLogger, dateUtil)
|
||||||
|
Assertions.assertEquals(T.mins(45).msecs(), autosensDataStore.bucketedData!![0].timestamp)
|
||||||
|
Assertions.assertEquals(T.mins(35).msecs(), autosensDataStore.bucketedData!![2].timestamp)
|
||||||
|
Assertions.assertEquals(T.mins(20).msecs(), autosensDataStore.bucketedData!![5].timestamp)
|
||||||
|
Assertions.assertEquals(6, autosensDataStore.bucketedData!!.size.toLong())
|
||||||
|
Assertions.assertEquals(99.0, autosensDataStore.bucketedData!![0].value, 1.0) // Recalculated data to 45min
|
||||||
|
Assertions.assertEquals(90.0, autosensDataStore.bucketedData!![1].value, 1.0) // Recalculated data to 40min
|
||||||
|
Assertions.assertEquals(67.0, autosensDataStore.bucketedData!![3].value, 1.0) // Recalculated data to 30min
|
||||||
|
Assertions.assertEquals(45.0, autosensDataStore.bucketedData!![5].value, 1.0) // Recalculated data to 20min
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue