File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
main/java/edu/ie3/datamodel/io/source/sql Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -306,7 +306,8 @@ private String createQueryForValueBefore(
306306 + timeSeriesUuid .toString ()
307307 + "' AND "
308308 + timeColumnName
309- + " < ?;" ;
309+ + " < ?"
310+ + "ORDER BY time DESC LIMIT 1;" ;
310311 }
311312 /**
312313 * Creates a base query to retrieve all time keys before a given time for given time series with
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import edu.ie3.datamodel.io.connectors.SqlConnector
1212import edu.ie3.datamodel.io.naming.DatabaseNamingStrategy
1313import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme
1414import edu.ie3.datamodel.io.naming.timeseries.IndividualTimeSeriesMetaInformation
15+ import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue
1516import edu.ie3.datamodel.models.value.*
1617import edu.ie3.test.helper.TestContainerHelper
1718import edu.ie3.util.TimeUtil
@@ -125,12 +126,17 @@ class SqlTimeSeriesSourceIT extends Specification implements TestContainerHelper
125126
126127 def " A SqlTimeSeriesSource is able to return the previous value for a given time" () {
127128 when :
128- def actual = pSource. getPreviousTimeBasedValue(TIME_15MIN )
129+ def actual = pSource. getPreviousTimeBasedValue(time )
129130
130131 then :
131- actual. isPresent()
132- actual. get(). time == TIME_00MIN
133- actual. get(). value == P_VALUE_00MIN
132+ actual. isPresent() == expectedResult. isPresent()
133+ actual == expectedResult
134+
135+ where :
136+ time | expectedResult
137+ TIME_00MIN | Optional . empty()
138+ TIME_15MIN | Optional . of(new TimeBasedValue<> (TIME_00MIN , P_VALUE_00MIN ))
139+ TIME_30MIN | Optional . of(new TimeBasedValue<> (TIME_15MIN , P_VALUE_15MIN ))
134140 }
135141
136142 def " A SqlTimeSeriesSource can read multiple time series values for a time interval" () {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ final class TimeSeriesSourceTestData {
2020
2121 public static final ZonedDateTime TIME_00MIN = ZonedDateTime . parse(" 2020-01-01T00:00:00Z" )
2222 public static final ZonedDateTime TIME_15MIN = ZonedDateTime . parse(" 2020-01-01T00:15:00Z" )
23+ public static final ZonedDateTime TIME_30MIN = ZonedDateTime . parse(" 2020-01-01T00:30:00Z" )
2324
2425 public static final PValue P_VALUE_00MIN = new PValue (
2526 Quantities . getQuantity(1000.0d , StandardUnits . ACTIVE_POWER_IN )
You can’t perform that action at this time.
0 commit comments