Skip to content

Commit

Permalink
Consolidate csv weather test files in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
ckittl committed Apr 9, 2021
1 parent 27cde50 commit 41ce1b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ trait CsvTestDataMeta {
static String gridFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("grid")
static String participantsFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("participants")
static String timeSeriesFolderPath = testTimeSeriesBaseFolderPath
static String weatherFolderPath = new File(getClass().getResource('/weather').toURI()).absolutePath
static String cosmoWeatherFolderPath = weatherFolderPath.concat(File.separator).concat("cosmo")
static String iconWeatherFolderPath = weatherFolderPath.concat(File.separator).concat("icon")
static String thermalFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("thermal")
static String coordinatesFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("coordinates")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
def setupSpec() {
coordinateSource = CosmoWeatherTestData.coordinateSource
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
}

def "A CsvWeatherSource can read and correctly parse a single value for a specific date and coordinate"() {
Expand Down Expand Up @@ -105,7 +105,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
def coordinateSource = Mock(IdCoordinateSource)
coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() }
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = [
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
"time" : "2020-10-16T12:40:42Z",
Expand Down Expand Up @@ -149,7 +149,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
def coordinateSource = Mock(IdCoordinateSource)
coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() }
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = [
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
"time" : "2020-10-16T12:40:42Z",
Expand All @@ -174,7 +174,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
def coordinateSource = Mock(IdCoordinateSource)
coordinateSource.getCoordinate(_) >> { args -> args[0] == 5 ? Optional.of(defaultCoordinate) : Optional.empty() }
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = [
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
"time" : "2020-10-16T12:40:42Z",
Expand All @@ -197,7 +197,7 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta
def coordinateSource = Mock(IdCoordinateSource)
coordinateSource.getCoordinate(_) >> Optional.empty()
def weatherFactory = new CosmoTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(";", timeSeriesFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(";", cosmoWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = [
"uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57",
"time" : "2020-10-16T12:40:42Z",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,10 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
@Shared
IdCoordinateSource coordinateSource

@Shared
String folderPath

def setupSpec() {
coordinateSource = WeatherTestData.coordinateSource
def weatherFactory = new IconTimeBasedWeatherValueFactory()
folderPath = new File(getClass().getResource('/weather/icon').toURI()).absolutePath
source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
}

def "A CsvWeatherSource can read and correctly parse a single value for a specific date and coordinate"() {
Expand Down Expand Up @@ -106,7 +102,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
def coordinateSource = Mock(IdCoordinateSource)
coordinateSource.getCoordinate(_) >> { args -> args[0] == 67775 ? Optional.of(expectedCoordinate) : Optional.empty() }
def weatherFactory = new IconTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = new TreeMap<>(String.CASE_INSENSITIVE_ORDER)
fieldToValues.putAll(
[
Expand Down Expand Up @@ -153,7 +149,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
given:
def coordinateSource = new WeatherTestData.DummyIdCoordinateSource()
def weatherFactory = new IconTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = [
"datum" : "2019-08-01 01:00:00",
"albRad" : "13.015240669",
Expand Down Expand Up @@ -197,7 +193,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
given:
def coordinateSource = new WeatherTestData.DummyIdCoordinateSource()
def weatherFactory = new IconTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = [
"datum" : "2019-08-01 01:00:00",
"albRad" : "13.015240669",
Expand Down Expand Up @@ -240,7 +236,7 @@ class CsvWeatherSourceIconTest extends Specification implements CsvTestDataMeta,
given:
def coordinateSource = new WeatherTestData.DummyIdCoordinateSource()
def weatherFactory = new IconTimeBasedWeatherValueFactory()
def source = new CsvWeatherSource(",", folderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def source = new CsvWeatherSource(",", iconWeatherFolderPath, new EntityPersistenceNamingStrategy(), coordinateSource, weatherFactory)
def fieldToValues = [
"datum" : "2019-08-01 01:00:00",
"albrad" : "13.015240669",
Expand Down

0 comments on commit 41ce1b6

Please sign in to comment.