Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package edu.ie3.datamodel.io.factory.timeseries

import edu.ie3.datamodel.exceptions.FactoryException
import edu.ie3.datamodel.models.StandardUnits
import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue
import edu.ie3.datamodel.models.value.WeatherValue
Expand Down Expand Up @@ -45,7 +46,8 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification {
def model = factory.buildModel(data)

then:
model == expectedResults
model.time == expectedResults.time
model.value == expectedResults.value
}

def "A PsdmTimeBasedWeatherValueFactory should be able to create time series values"() {
Expand All @@ -56,7 +58,7 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification {

Map<String, String> parameter = [
"time" : TimeUtil.withDefaults.toString(time),
"uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1",
"uuid" : "c0aaf6fc-693a-458d-8d1d-d0a5093f262a",
"diffuseIrradiance": "282.671997070312",
"directIrradiance" : "286.872985839844",
"temperature" : "278.019012451172",
Expand All @@ -78,6 +80,66 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification {
def model = factory.buildModel(data)

then:
model == expectedResults
model.time == expectedResults.time
model.value == expectedResults.value
}

def "A PsdmTimeBasedWeatherValueFactory should throw FactoryException if required field is missing"() {
given:
def factory = new CosmoTimeBasedWeatherValueFactory()
def coordinate = CosmoWeatherTestData.COORDINATE_193186
def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z")

// Missing 'directIrradiance' field
Map<String, String> parameter = [
"time" : TimeUtil.withDefaults.toString(time),
"uuid" : "1fc66d18-ea7d-4690-890e-9ee946c8b7b5",
"diffuseIrradiance": "182.671997070312",
"temperature" : "278.019012451172",
"windDirection" : "50",
"windVelocity" : "1.66103506088257"
]

def data = new TimeBasedWeatherValueData(parameter, coordinate)

when:
factory.buildModel(data)

then:
thrown(FactoryException)
}

def "Smoke Test: This PsdmTimeBasedWeatherValueFactory should fail since expected results doesn't match input"() {
given:
def factory = new CosmoTimeBasedWeatherValueFactory()
def coordinate = CosmoWeatherTestData.COORDINATE_193186
def time = TimeUtil.withDefaults.toZonedDateTime("2019-01-01T00:00:00Z")

Map<String, String> parameter = [
"time" : TimeUtil.withDefaults.toString(time),
"uuid" : "1fc66d18-ea7d-4690-890e-9ee946c8b7b5",
"diffuseIrradiance": "1.0",
"directIrradiance" : "2.0",
"temperature" : "3.0",
"windDirection" : "4",
"windVelocity" : "5.0"
]

def data = new TimeBasedWeatherValueData(parameter, coordinate)

def expectedResults = new TimeBasedValue(
time, new WeatherValue(coordinate,
Quantities.getQuantity(5.0, StandardUnits.SOLAR_IRRADIANCE),
Quantities.getQuantity(4.0, StandardUnits.SOLAR_IRRADIANCE),
Quantities.getQuantity(3.0, StandardUnits.TEMPERATURE),
Quantities.getQuantity(2d, StandardUnits.WIND_DIRECTION),
Quantities.getQuantity(1.0, StandardUnits.WIND_VELOCITY)))

when:
def model = factory.buildModel(data)

then:
assert model.time == expectedResults.time
assert model.value != expectedResults.value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification {
)

expect:
factory.buildModel(data) == expected
factory.buildModel(data).time == expected.time
factory.buildModel(data).value.toString() == expected.value.toString()
}

def "The simple time based value factory builds correct heat and apparent power value"() {
Expand All @@ -130,7 +131,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification {
)

expect:
factory.buildModel(data) == expected
factory.buildModel(data).time == expected.time
factory.buildModel(data).value == expected.value
}

def "The simple time based value factory builds correct heat and active power value"() {
Expand All @@ -149,7 +151,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification {
)

expect:
factory.buildModel(data) == expected
factory.buildModel(data).time == expected.time
factory.buildModel(data).value == expected.value
}

def "The simple time based value factory builds correct heat demand value"() {
Expand All @@ -167,7 +170,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification {
)

expect:
factory.buildModel(data) == expected
factory.buildModel(data).time == expected.time
factory.buildModel(data).value == expected.value
}

def "The simple time based value factory builds correct apparent power value"() {
Expand All @@ -186,7 +190,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification {
)

expect:
factory.buildModel(data) == expected
factory.buildModel(data).time == expected.time
factory.buildModel(data).value == expected.value
}

def "The simple time based value factory builds correct active power value"() {
Expand All @@ -204,7 +209,8 @@ class TimeBasedSimpleValueFactoryTest extends Specification {
)

expect:
factory.buildModel(data) == expected
factory.buildModel(data).time == expected.time
factory.buildModel(data).value == expected.value
}

def "The simple time based value factory throws a FactoryException upon build request, if a class is not supported"() {
Expand Down