Skip to content

Commit 0d08e31

Browse files
committed
Using time stamp pattern from factory to build Couchbase queries
1 parent 98a39c9 commit 0d08e31

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

src/main/java/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSource.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public class CouchbaseWeatherSource implements WeatherSource {
3636
private static final Logger logger = LogManager.getLogger(CouchbaseWeatherSource.class);
3737

3838
private static final NamingConvention DEFAULT_NAMING_CONVENTION = NamingConvention.FLAT;
39-
private static final String DEFAULT_TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ssxxx";
4039
/** The start of the document key, comparable to a table name in relational databases */
4140
private static final String DEFAULT_KEY_PREFIX = "weather";
4241

@@ -59,20 +58,13 @@ public class CouchbaseWeatherSource implements WeatherSource {
5958
* @param coordinateSource Source to obtain actual coordinates from
6059
* @param weatherFactory Factory to transfer field to value mapping into actual java object
6160
* instances
62-
* @param timeStampPattern Pattern of time stamps to parse
6361
*/
6462
public CouchbaseWeatherSource(
6563
CouchbaseConnector connector,
6664
IdCoordinateSource coordinateSource,
67-
TimeBasedWeatherValueFactory weatherFactory,
68-
String timeStampPattern) {
65+
TimeBasedWeatherValueFactory weatherFactory) {
6966
this(
70-
connector,
71-
coordinateSource,
72-
DEFAULT_KEY_PREFIX,
73-
DEFAULT_TIMESTAMP_PATTERN,
74-
DEFAULT_NAMING_CONVENTION,
75-
weatherFactory);
67+
connector, coordinateSource, DEFAULT_KEY_PREFIX, DEFAULT_NAMING_CONVENTION, weatherFactory);
7668
}
7769

7870
/**
@@ -85,22 +77,15 @@ public CouchbaseWeatherSource(
8577
* @param weatherFactory Factory to transfer field to value mapping into actual java object
8678
* instances
8779
* @deprecated Use {@link CouchbaseWeatherSource#CouchbaseWeatherSource(CouchbaseConnector,
88-
* IdCoordinateSource, String, String, NamingConvention, TimeBasedWeatherValueFactory)}
89-
* instead
80+
* IdCoordinateSource, String, NamingConvention, TimeBasedWeatherValueFactory)} instead
9081
*/
9182
@Deprecated
9283
public CouchbaseWeatherSource(
9384
CouchbaseConnector connector,
9485
IdCoordinateSource coordinateSource,
9586
String keyPrefix,
9687
TimeBasedWeatherValueFactory weatherFactory) {
97-
this(
98-
connector,
99-
coordinateSource,
100-
keyPrefix,
101-
DEFAULT_TIMESTAMP_PATTERN,
102-
DEFAULT_NAMING_CONVENTION,
103-
weatherFactory);
88+
this(connector, coordinateSource, keyPrefix, DEFAULT_NAMING_CONVENTION, weatherFactory);
10489
}
10590

10691
/**
@@ -110,7 +95,6 @@ public CouchbaseWeatherSource(
11095
* @param connector Connector, that establishes the connection to the couchbase instance
11196
* @param coordinateSource Source to obtain actual coordinates from
11297
* @param keyPrefix Prefix of entries, that belong to weather
113-
* @param timeStampPattern Pattern of time stamps to parse
11498
* @param namingConvention the (case) convention, how columns are named
11599
* @param weatherFactory Factory to transfer field to value mapping into actual java object
116100
* instances
@@ -119,14 +103,13 @@ public CouchbaseWeatherSource(
119103
CouchbaseConnector connector,
120104
IdCoordinateSource coordinateSource,
121105
String keyPrefix,
122-
String timeStampPattern,
123106
NamingConvention namingConvention,
124107
TimeBasedWeatherValueFactory weatherFactory) {
125108
this.connector = connector;
126109
this.coordinateSource = coordinateSource;
127110
this.keyPrefix = keyPrefix;
128111
this.weatherFactory = weatherFactory;
129-
this.timeStampPattern = timeStampPattern;
112+
this.timeStampPattern = weatherFactory.getTimeStampPattern();
130113
this.namingConvention = namingConvention;
131114
this.coordinateIdColumnName = weatherFactory.getCoordinateIdFieldString(namingConvention);
132115
}

src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceCosmoIT.groovy

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue
1313
import edu.ie3.datamodel.models.value.WeatherValue
1414
import edu.ie3.test.common.CosmoWeatherTestData
1515
import edu.ie3.test.helper.WeatherSourceTestHelper
16-
import edu.ie3.util.TimeUtil
1716
import edu.ie3.util.interval.ClosedInterval
1817
import org.locationtech.jts.geom.Point
1918
import org.testcontainers.couchbase.BucketDefinition
@@ -23,8 +22,6 @@ import org.testcontainers.utility.MountableFile
2322
import spock.lang.Shared
2423
import spock.lang.Specification
2524

26-
import java.time.ZoneId
27-
2825
@Testcontainers
2926
class CouchbaseWeatherSourceCosmoIT extends Specification implements WeatherSourceTestHelper {
3027

@@ -63,9 +60,8 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements WeatherSour
6360
"--dataset", "file:///home/weather.json")
6461

6562
def connector = new CouchbaseConnector(couchbaseContainer.connectionString, bucketDefinition.name, couchbaseContainer.username, couchbaseContainer.password)
66-
def dtfPattern = "yyyy-MM-dd'T'HH:mm:ssxxx"
67-
def weatherFactory = new CosmoTimeBasedWeatherValueFactory(dtfPattern)
68-
source = new CouchbaseWeatherSource(connector, CosmoWeatherTestData.coordinateSource, weatherFactory, dtfPattern)
63+
def weatherFactory = new CosmoTimeBasedWeatherValueFactory("yyyy-MM-dd'T'HH:mm:ssxxx")
64+
source = new CouchbaseWeatherSource(connector, CosmoWeatherTestData.coordinateSource, weatherFactory)
6965
}
7066

7167
def "The test container can establish a valid connection"() {
@@ -111,7 +107,6 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements WeatherSour
111107
}
112108

113109

114-
115110
def "A CouchbaseWeatherSource can read all weather data in a given time interval"() {
116111
given:
117112
def timeInterval = new ClosedInterval(CosmoWeatherTestData.TIME_15H, CosmoWeatherTestData.TIME_17H)

src/test/groovy/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSourceIconIT.groovy

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries
1212
import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue
1313
import edu.ie3.test.common.IconWeatherTestData
1414
import edu.ie3.test.helper.WeatherSourceTestHelper
15-
import edu.ie3.util.TimeUtil
1615
import edu.ie3.util.interval.ClosedInterval
1716
import org.testcontainers.couchbase.BucketDefinition
1817
import org.testcontainers.couchbase.CouchbaseContainer
@@ -21,8 +20,6 @@ import org.testcontainers.utility.MountableFile
2120
import spock.lang.Shared
2221
import spock.lang.Specification
2322

24-
import java.time.ZoneId
25-
2623
@Testcontainers
2724
class CouchbaseWeatherSourceIconIT extends Specification implements WeatherSourceTestHelper {
2825

@@ -61,9 +58,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements WeatherSourc
6158
"--dataset", "file:///home/weather.json")
6259

6360
def connector = new CouchbaseConnector(couchbaseContainer.connectionString, bucketDefinition.name, couchbaseContainer.username, couchbaseContainer.password)
64-
def dtfPattern = "yyyy-MM-dd'T'HH:mm:ssxxx"
65-
def weatherFactory = new IconTimeBasedWeatherValueFactory(dtfPattern)
66-
source = new CouchbaseWeatherSource(connector, IconWeatherTestData.coordinateSource, weatherFactory, dtfPattern)
61+
def weatherFactory = new IconTimeBasedWeatherValueFactory("yyyy-MM-dd'T'HH:mm:ssxxx")
62+
source = new CouchbaseWeatherSource(connector, IconWeatherTestData.coordinateSource, weatherFactory)
6763
}
6864

6965
def "The test container can establish a valid connection"() {

0 commit comments

Comments
 (0)