Skip to content

Commit bda154d

Browse files
committed
Consolidate csv weather test files in one place
1 parent 19b9fe4 commit bda154d

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTestDataMeta.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ trait CsvTestDataMeta {
1919
static String gridFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("grid")
2020
static String participantsFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("participants")
2121
static String timeSeriesFolderPath = testTimeSeriesBaseFolderPath
22+
static String weatherFolderPath = new File(getClass().getResource('/weather').toURI()).absolutePath
23+
static String cosmoWeatherFolderPath = weatherFolderPath.concat(File.separator).concat("cosmo")
24+
static String iconWeatherFolderPath = weatherFolderPath.concat(File.separator).concat("icon")
2225
static String thermalFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("thermal")
2326
static String coordinatesFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("coordinates")
2427

src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
3838
def setupSpec() {
3939
coordinateSource = CosmoWeatherTestData.coordinateSource
4040
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
41-
source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
41+
source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
4242
}
4343

4444
def "A CsvWeatherSource can read and correctly parse a single value for a specific date and coordinate"() {
@@ -105,7 +105,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
105105
def coordinateSource = Mock(IdCoordinateSource)
106106
coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() }
107107
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
108-
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
108+
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
109109
def fieldToValues = [
110110
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
111111
"time" : "2020-10-16T12:40:42Z",
@@ -149,7 +149,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
149149
def coordinateSource = Mock(IdCoordinateSource)
150150
coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() }
151151
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
152-
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
152+
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
153153
def fieldToValues = [
154154
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
155155
"time" : "2020-10-16T12:40:42Z",
@@ -174,7 +174,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
174174
def coordinateSource = Mock(IdCoordinateSource)
175175
coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() }
176176
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
177-
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
177+
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
178178
def fieldToValues = [
179179
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
180180
"time" : "2020-10-16T12:40:42Z",
@@ -197,7 +197,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
197197
def coordinateSource = Mock(IdCoordinateSource)
198198
coordinateSource.getCoordinate(_) >> Optional.empty()
199199
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
200-
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
200+
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
201201
def fieldToValues = [
202202
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
203203
"time" : "2020-10-16T12:40:42Z",

src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,10 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
2929
@Shared
3030
IdCoordinateSource coordinateSource
3131

32-
@Shared
33-
String folderPath
34-
3532
def setupSpec() {
3633
coordinateSource = WeatherTestData.coordinateSource
3734
def weatherFactory = new IconTimeBasedWeatherValueFactory()
38-
folderPath = new File(getClass().getResource('/weather/icon').toURI()).absolutePath
39-
source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
35+
source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
4036
}
4137

4238
def "A CsvWeatherSource can read and correctly parse a single value for a specific date and coordinate"() {
@@ -106,7 +102,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
106102
def coordinateSource = Mock(IdCoordinateSource)
107103
coordinateSource.getCoordinate(_) >> { args -> args[0] == 67775 ? Optional.of(expectedCoordinate) : Optional.empty() }
108104
def weatherFactory = new IconTimeBasedWeatherValueFactory()
109-
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
105+
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
110106
def fieldToValues = new TreeMap<>(String.CASE_INSENSITIVE_ORDER)
111107
fieldToValues.putAll(
112108
[
@@ -153,7 +149,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
153149
given:
154150
def coordinateSource = new WeatherTestData.DummyIdCoordinateSource()
155151
def weatherFactory = new IconTimeBasedWeatherValueFactory()
156-
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
152+
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
157153
def fieldToValues = [
158154
"datum" : "2019-08-01 01:00:00",
159155
"albRad" : "13.015240669",
@@ -197,7 +193,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
197193
given:
198194
def coordinateSource = new WeatherTestData.DummyIdCoordinateSource()
199195
def weatherFactory = new IconTimeBasedWeatherValueFactory()
200-
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
196+
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
201197
def fieldToValues = [
202198
"datum" : "2019-08-01 01:00:00",
203199
"albRad" : "13.015240669",
@@ -240,7 +236,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
240236
given:
241237
def coordinateSource = new WeatherTestData.DummyIdCoordinateSource()
242238
def weatherFactory = new IconTimeBasedWeatherValueFactory()
243-
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
239+
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
244240
def fieldToValues = [
245241
"datum" : "2019-08-01 01:00:00",
246242
"albrad" : "13.015240669",

0 commit comments

Comments
 (0)