Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# The following file will be copied to a unix Docker image and imported to InfluxDB data base. Therefore, the line
# ending plays a crucial role. This prevents the endings from being adjusted with 'core.autocrlf=true'
src/test/resources/testContainerFiles/influxDb/cosmo/weather.txt eol=lf
src/test/resources/testContainerFiles/influxDb/icon/weather.txt eol=lf
src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/cosmo/weather.txt eol=lf
src/test/resources/edu/ie3/datamodel/io/source/influxdb/_weather/icon/weather.txt eol=lf

Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class CsvFileConnectorTest extends Specification {
"its_p_fcf0b851-a836-4bde-8090-f44c382ed226.csv",
"its_pqh_5022a70e-a58f-4bac-b8ec-1c62376c216b.csv",
"its_c_b88dee50-5484-4136-901d-050d8c1c97d1.csv",
"its_c_c7b0d9d6-5044-4f51-80b4-f221d8b1f14b.csv",
"its_weather_085d98ee-09a2-4de4-b119-83949690d7b6.csv"
"its_c_c7b0d9d6-5044-4f51-80b4-f221d8b1f14b.csv"
]
pathsToIgnore = [
"file_to_be_ignored.txt"
Expand Down Expand Up @@ -85,8 +84,7 @@ class CsvFileConnectorTest extends Specification {
(UUID.fromString("fcf0b851-a836-4bde-8090-f44c382ed226")): new CsvIndividualTimeSeriesMetaInformation(UUID.fromString("fcf0b851-a836-4bde-8090-f44c382ed226"), ColumnScheme.ACTIVE_POWER, "its_p_fcf0b851-a836-4bde-8090-f44c382ed226"),
(UUID.fromString("5022a70e-a58f-4bac-b8ec-1c62376c216b")): new CsvIndividualTimeSeriesMetaInformation(UUID.fromString("5022a70e-a58f-4bac-b8ec-1c62376c216b"), ColumnScheme.APPARENT_POWER_AND_HEAT_DEMAND, "its_pqh_5022a70e-a58f-4bac-b8ec-1c62376c216b"),
(UUID.fromString("b88dee50-5484-4136-901d-050d8c1c97d1")): new CsvIndividualTimeSeriesMetaInformation(UUID.fromString("b88dee50-5484-4136-901d-050d8c1c97d1"), ColumnScheme.ENERGY_PRICE, "its_c_b88dee50-5484-4136-901d-050d8c1c97d1"),
(UUID.fromString("c7b0d9d6-5044-4f51-80b4-f221d8b1f14b")): new CsvIndividualTimeSeriesMetaInformation(UUID.fromString("c7b0d9d6-5044-4f51-80b4-f221d8b1f14b"), ColumnScheme.ENERGY_PRICE, "its_c_c7b0d9d6-5044-4f51-80b4-f221d8b1f14b"),
(UUID.fromString("085d98ee-09a2-4de4-b119-83949690d7b6")): new CsvIndividualTimeSeriesMetaInformation(UUID.fromString("085d98ee-09a2-4de4-b119-83949690d7b6"), ColumnScheme.WEATHER, "its_weather_085d98ee-09a2-4de4-b119-83949690d7b6")
(UUID.fromString("c7b0d9d6-5044-4f51-80b4-f221d8b1f14b")): new CsvIndividualTimeSeriesMetaInformation(UUID.fromString("c7b0d9d6-5044-4f51-80b4-f221d8b1f14b"), ColumnScheme.ENERGY_PRICE, "its_c_c7b0d9d6-5044-4f51-80b4-f221d8b1f14b")
]

when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package edu.ie3.datamodel.io.connectors

import edu.ie3.test.helper.TestContainerHelper
import org.testcontainers.containers.PostgreSQLContainer
import org.testcontainers.spock.Testcontainers
import org.testcontainers.utility.MountableFile
Expand All @@ -14,7 +15,7 @@ import spock.lang.Specification
import java.sql.SQLException

@Testcontainers
class SqlConnectorIT extends Specification {
class SqlConnectorIT extends Specification implements TestContainerHelper {
@Shared
PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:14.2")

Expand All @@ -23,7 +24,7 @@ class SqlConnectorIT extends Specification {

def setupSpec() {
// Copy sql import script into docker
MountableFile sqlImportFile = MountableFile.forClasspathResource("/testcontainersFiles/sql/connector/connectorTest.sql")
MountableFile sqlImportFile = getMountableFile("_sql/connectorTest.sql")
postgreSQLContainer.copyFileToContainer(sqlImportFile, "/home/connectorTest.sql")
// Execute import script
postgreSQLContainer.execInContainer("psql", "-Utest", "-f/home/connectorTest.sql")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries
import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue
import edu.ie3.datamodel.models.value.WeatherValue
import edu.ie3.test.common.CosmoWeatherTestData
import edu.ie3.test.helper.TestContainerHelper
import edu.ie3.test.helper.WeatherSourceTestHelper
import edu.ie3.util.TimeUtil
import edu.ie3.util.interval.ClosedInterval
Expand All @@ -25,13 +26,14 @@ import spock.lang.Specification
import java.time.ZoneId

@Testcontainers
class CouchbaseWeatherSourceCosmoIT extends Specification implements WeatherSourceTestHelper {
class CouchbaseWeatherSourceCosmoIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper {

@Shared
BucketDefinition bucketDefinition = new BucketDefinition("ie3_in")

@Shared
CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.0.2").withBucket(bucketDefinition)
CouchbaseContainer couchbaseContainer = new CouchbaseContainer("couchbase/server:6.0.2")
.withBucket(bucketDefinition)
.withExposedPorts(8091, 8092, 8093, 8094, 11210)

@Shared
Expand All @@ -41,8 +43,8 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements WeatherSour

def setupSpec() {
// Copy import file with json array of documents into docker
MountableFile couchbaseWeatherJsonsFile = MountableFile.forClasspathResource("/testcontainersFiles/couchbase/cosmo/weather.json")
couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather.json")
MountableFile couchbaseWeatherJsonsFile = getMountableFile("_weather/cosmo/weather.json")
couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_cosmo.json")

// create an index for the document keys
couchbaseContainer.execInContainer("cbq",
Expand All @@ -59,7 +61,7 @@ class CouchbaseWeatherSourceCosmoIT extends Specification implements WeatherSour
"--password", couchbaseContainer.password,
"--format", "list",
"--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%",
"--dataset", "file:///home/weather.json")
"--dataset", "file:///home/weather_cosmo.json")

def connector = new CouchbaseConnector(couchbaseContainer.connectionString, bucketDefinition.name, couchbaseContainer.username, couchbaseContainer.password)
def dtfPattern = "yyyy-MM-dd'T'HH:mm:ssxxx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import edu.ie3.datamodel.io.factory.timeseries.IconTimeBasedWeatherValueFactory
import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries
import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue
import edu.ie3.test.common.IconWeatherTestData
import edu.ie3.test.helper.TestContainerHelper
import edu.ie3.test.helper.WeatherSourceTestHelper
import edu.ie3.util.TimeUtil
import edu.ie3.util.interval.ClosedInterval
import org.testcontainers.couchbase.BucketDefinition
import org.testcontainers.couchbase.CouchbaseContainer
import org.testcontainers.spock.Testcontainers
import org.testcontainers.utility.MountableFile
import spock.lang.Shared
import spock.lang.Specification

import java.time.ZoneId

@Testcontainers
class CouchbaseWeatherSourceIconIT extends Specification implements WeatherSourceTestHelper {
class CouchbaseWeatherSourceIconIT extends Specification implements TestContainerHelper, WeatherSourceTestHelper {

@Shared
BucketDefinition bucketDefinition = new BucketDefinition("ie3_in")
Expand All @@ -39,8 +39,8 @@ class CouchbaseWeatherSourceIconIT extends Specification implements WeatherSourc

def setupSpec() {
// Copy import file with json array of documents into docker
def couchbaseWeatherJsonsFile = MountableFile.forClasspathResource("/testcontainersFiles/couchbase/icon/weather.json")
couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather.json")
def couchbaseWeatherJsonsFile = getMountableFile("_weather/icon/weather.json")
couchbaseContainer.copyFileToContainer(couchbaseWeatherJsonsFile, "/home/weather_icon.json")

// create an index for the document keys
couchbaseContainer.execInContainer("cbq",
Expand All @@ -57,7 +57,7 @@ class CouchbaseWeatherSourceIconIT extends Specification implements WeatherSourc
"--password", couchbaseContainer.password,
"--format", "list",
"--generate-key", "weather::%" + coordinateIdColumnName + "%::%time%",
"--dataset", "file:///home/weather.json")
"--dataset", "file:///home/weather_icon.json")

def connector = new CouchbaseConnector(couchbaseContainer.connectionString, bucketDefinition.name, couchbaseContainer.username, couchbaseContainer.password)
def dtfPattern = "yyyy-MM-dd'T'HH:mm:ssxxx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ class CsvDataSourceTest extends Specification {

@Shared
String csvSep = ","
String testBaseFolderPath = new File(getClass().getResource('/testGridFiles').toURI()).getAbsolutePath()
@Shared
String testBaseFolderPath = "testBaseFolderPath" // does not have to exist for this test
@Shared
FileNamingStrategy fileNamingStrategy = new FileNamingStrategy()

@Shared
DummyCsvSource dummyCsvSource = new DummyCsvSource(csvSep, testBaseFolderPath, fileNamingStrategy)

def "A csv data source is able to find the correct first entity by uuid"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CsvGraphicSourceTest extends Specification implements CsvTestDataMeta {
def "A CsvGraphicSource should provide an instance of GraphicElements based on valid input data correctly"() {
given:
def typeSource = new CsvTypeSource(csvSep, typeFolderPath, fileNamingStrategy)
def rawGridSource = new CsvRawGridSource(csvSep, gridFolderPath, fileNamingStrategy, typeSource)
def rawGridSource = new CsvRawGridSource(csvSep, gridDefaultFolderPath, fileNamingStrategy, typeSource)
def csvGraphicSource = new CsvGraphicSource(csvSep, graphicsFolderPath, fileNamingStrategy, typeSource, rawGridSource)

when:
Expand All @@ -40,7 +40,7 @@ class CsvGraphicSourceTest extends Specification implements CsvTestDataMeta {
given:
def typeSource = new CsvTypeSource(csvSep, typeFolderPath, fileNamingStrategy)
def rawGridSource =
new CsvRawGridSource(csvSep, gridFolderPath, fileNamingStrategy, typeSource) {
new CsvRawGridSource(csvSep, gridDefaultFolderPath, fileNamingStrategy, typeSource) {
@Override
Set<NodeInput> getNodes() {
return Collections.emptySet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM
CsvIdCoordinateSource source

def setupSpec() {
source = new CsvIdCoordinateSource(csvSep, coordinatesFolderPath + "_cosmo", fileNamingStrategy, new CosmoIdCoordinateFactory())
source = new CsvIdCoordinateSource(csvSep, coordinatesCosmoFolderPath, fileNamingStrategy, new CosmoIdCoordinateFactory())
}

def "The CsvCoordinateSource is able to create a valid stream from a coordinate file"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe
CsvIdCoordinateSource source

def setupSpec() {
source = new CsvIdCoordinateSource(csvSep, coordinatesFolderPath + "_icon", fileNamingStrategy, new IconIdCoordinateFactory())
source = new CsvIdCoordinateSource(csvSep, coordinatesIconFolderPath, fileNamingStrategy, new IconIdCoordinateFactory())
}

def "The CsvCoordinateSource is able to create a valid stream from a coordinate file"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta {

def setupSpec() {
CsvTypeSource typeSource = new CsvTypeSource(csvSep, typeFolderPath, fileNamingStrategy)
source = new CsvRawGridSource(csvSep, gridFolderPath, fileNamingStrategy, typeSource)
source = new CsvRawGridSource(csvSep, gridDefaultFolderPath, fileNamingStrategy, typeSource)
}

def "The CsvRawGridSource is able to convert single valid AssetInputEntityData to ConnectorInputEntityData"() {
Expand Down Expand Up @@ -742,7 +742,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta {
def "The CsvRawGridSource returns an empty Optional, if one mandatory element for the RawGridElements is missing"() {
given: "a source pointing to malformed grid data"
CsvTypeSource typeSource = new CsvTypeSource(csvSep, typeFolderPath, fileNamingStrategy)
source = new CsvRawGridSource(csvSep, gridFolderPath + "_malformed", fileNamingStrategy, typeSource)
source = new CsvRawGridSource(csvSep, gridMalformedFolderPath, fileNamingStrategy, typeSource)

when: "loading a total grid structure from file"
def actual = source.getGridData()
Expand All @@ -754,7 +754,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta {
def "The CsvRawGridSource returns an empty Optional, if the RawGridElements contain no single element"() {
given: "a source pointing to malformed grid data"
CsvTypeSource typeSource = new CsvTypeSource(csvSep, typeFolderPath, fileNamingStrategy)
source = new CsvRawGridSource(csvSep, gridFolderPath + "_empty", fileNamingStrategy, typeSource)
source = new CsvRawGridSource(csvSep, gridEmptyFolderPath, fileNamingStrategy, typeSource)

when: "loading a total grid structure from file"
def actual = source.getGridData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat
given:
def typeSource = new CsvTypeSource(csvSep, typeFolderPath, fileNamingStrategy)
def thermalSource = new CsvThermalSource(csvSep, participantsFolderPath, fileNamingStrategy, typeSource)
def rawGridSource = new CsvRawGridSource(csvSep, gridFolderPath, fileNamingStrategy, typeSource)
def rawGridSource = new CsvRawGridSource(csvSep, gridDefaultFolderPath, fileNamingStrategy, typeSource)
def csvSystemParticipantSource = new CsvSystemParticipantSource(csvSep,
participantsFolderPath, fileNamingStrategy, typeSource,
thermalSource, rawGridSource)
Expand Down Expand Up @@ -63,10 +63,10 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat
def typeSource = new CsvTypeSource(csvSep, typeFolderPath, fileNamingStrategy)
def thermalSource = new CsvThermalSource(csvSep, participantsFolderPath, fileNamingStrategy, typeSource)
def rawGridSource = Spy(CsvRawGridSource, constructorArgs: [
csvSep,
gridFolderPath,
fileNamingStrategy,
typeSource
csvSep,
gridDefaultFolderPath,
fileNamingStrategy,
typeSource
]) {
// partly fake the return method of the csv raw grid source to always return empty node sets
// -> elements to build NodeGraphicInputs are missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,32 @@ package edu.ie3.datamodel.io.source.csv

import edu.ie3.datamodel.io.naming.FileNamingStrategy

import java.nio.file.Paths

/**
* Holds meta data for csv tests e.g. file and folder paths
*/
trait CsvTestDataMeta {

static String testParticipantsBaseFolderPath = new File(CsvTestDataMeta.getResource('/testGridFiles').toURI()).absolutePath
static String testTimeSeriesBaseFolderPath = new File(CsvTestDataMeta.getResource('/testTimeSeriesFiles').toURI()).absolutePath
static String graphicsFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("graphics")
static String typeFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("types")
static String gridFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("grid")
static String participantsFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("participants")
static String resultEntitiesFolderPath = testParticipantsBaseFolderPath.concat(File.separator).concat("results")
static String timeSeriesFolderPath = testTimeSeriesBaseFolderPath
static String weatherFolderPath = new File(CsvTestDataMeta.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")
static String timeSeriesFolderPath = getResourceAbs("_timeseries")
static String graphicsFolderPath = getResourceAbs("_graphics")
static String typeFolderPath = getResourceAbs("_types")
static String participantsFolderPath = getResourceAbs("_participants")
static String resultEntitiesFolderPath = getResourceAbs("_results")
static String thermalFolderPath = getResourceAbs("_thermal")
static String coordinatesIconFolderPath = getResourceAbs("_coordinates/icon")
static String coordinatesCosmoFolderPath = getResourceAbs("_coordinates/cosmo")
static String weatherCosmoFolderPath = getResourceAbs("_weather/cosmo")
static String weatherIconFolderPath = getResourceAbs("_weather/icon")

static String gridDefaultFolderPath = getResourceAbs("_grid/default")
static String gridMalformedFolderPath = getResourceAbs("_grid/malformed")
static String gridEmptyFolderPath = getResourceAbs("_grid/empty")

static String csvSep = ","
static FileNamingStrategy fileNamingStrategy = new FileNamingStrategy()

static String getResourceAbs(String directory) {
return Paths.get(CsvTestDataMeta.getResource(directory).toURI()).toString()
}
}
Loading