Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed spotlessApply handling for `.groovy` files [#637](https://github.com/ie3-institute/PowerSystemDataModel/issues/637)
- Re-using SQL connection per default [#653](https://github.com/ie3-institute/PowerSystemDataModel/issues/653)
- Persisting EmInputs [#665](https://github.com/ie3-institute/PowerSystemDataModel/issues/665)
- Charging point type parsing now works with more id definitions [#686](https://github.com/ie3-institute/PowerSystemDataModel/issues/685)

### Changed
- BREAKING: PvInput Model parameter name height changed to elevationAngle [#393](https://github.com/ie3-institute/PowerSystemDataModel/issues/393) :warning:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ public static ChargingPointType parse(String parsableString) throws ChargingPoin
ChargingPointType res;

// valid regex for either custom or pre-defined types
String validCustomRegex = "(\\w+\\d*)\\s*\\(\\s*(\\d+\\.?\\d+)\\s*\\|\\s*(AC|DC)\\s*\\)";
String validCustomRegex =
"([\\w \\-_]+)\\s*\\(\\s*(\\d+\\.?\\d+(?:E-?\\d+)?)\\s*\\|\\s*(AC|DC)\\s*\\)";

// does it match the valid regex?
Pattern pattern = Pattern.compile(validCustomRegex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,58 +20,59 @@ import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE
*/
class ChargingPointTypeUtilsTest extends Specification {

def "The ChargingPointTypeUtils should throw an exception on instantiation"() {
when:
new ChargingPointTypeUtils()
def "The ChargingPointTypeUtils should throw an exception on instantiation"() {
when:
new ChargingPointTypeUtils()

then:
IllegalStateException ex = thrown()
ex.message == "This is a factory class. Don't try to instantiate it."
}
then:
IllegalStateException ex = thrown()
ex.message == "This is a factory class. Don't try to instantiate it."
}

def "The ChargingPointTypeUtils should parse and return valid charging point type strings as expected"() {
given:
ChargingPointType actual = parse(parsableString)
def "The ChargingPointTypeUtils should parse and return valid charging point type strings as expected"() {
given:
ChargingPointType actual = parse(parsableString)

expect:
actual == expectedObj
actual.toString() == expectedString
expect:
actual == expectedObj
actual.toString() == expectedString

where:
parsableString || expectedObj || expectedString
"household" || HouseholdSocket || "HouseholdSocket"
"HouseholdSocket" || HouseholdSocket || "HouseholdSocket"
"BlueHouseholdSocket" || BlueHouseholdSocket || "BlueHouseholdSocket"
"Cee16ASocket" || Cee16ASocket || "Cee16ASocket"
"cee32" || Cee32ASocket || "Cee32ASocket"
"CEE63" || Cee63ASocket || "Cee63ASocket"
"csT1" || ChargingStationType1 || "ChargingStationType1"
"stationtype2" || ChargingStationType2 || "ChargingStationType2"
"ChargingStationCcsComboType1" || ChargingStationCcsComboType1 || "ChargingStationCcsComboType1"
"csccs2" || ChargingStationCcsComboType2 || "ChargingStationCcsComboType2"
"TeslaSuperChargerV1" || TeslaSuperChargerV1 || "TeslaSuperChargerV1"
"tesla2" || TeslaSuperChargerV2 || "TeslaSuperChargerV2"
"supercharger3" || TeslaSuperChargerV3 || "TeslaSuperChargerV3"
"FastCharger(50|DC)" || new ChargingPointType("FastCharger", Quantities.getQuantity(50d, KILOVOLTAMPERE), ElectricCurrentType.DC) || "FastCharger(50.0|DC)"
"household(1.8|DC)" || new ChargingPointType("household", Quantities.getQuantity(1.8d, KILOVOLTAMPERE), ElectricCurrentType.DC) || "household(1.8|DC)"
"Household(2.3|AC)" || HouseholdSocket || "HouseholdSocket"
"household(2.3|AC)" || HouseholdSocket || "HouseholdSocket"
}
where:
parsableString || expectedObj || expectedString
"household" || HouseholdSocket || "HouseholdSocket"
"HouseholdSocket" || HouseholdSocket || "HouseholdSocket"
"BlueHouseholdSocket" || BlueHouseholdSocket || "BlueHouseholdSocket"
"Cee16ASocket" || Cee16ASocket || "Cee16ASocket"
"cee32" || Cee32ASocket || "Cee32ASocket"
"CEE63" || Cee63ASocket || "Cee63ASocket"
"csT1" || ChargingStationType1 || "ChargingStationType1"
"stationtype2" || ChargingStationType2 || "ChargingStationType2"
"ChargingStationCcsComboType1" || ChargingStationCcsComboType1 || "ChargingStationCcsComboType1"
"csccs2" || ChargingStationCcsComboType2 || "ChargingStationCcsComboType2"
"TeslaSuperChargerV1" || TeslaSuperChargerV1 || "TeslaSuperChargerV1"
"tesla2" || TeslaSuperChargerV2 || "TeslaSuperChargerV2"
"supercharger3" || TeslaSuperChargerV3 || "TeslaSuperChargerV3"
"FastCharger(50|DC)" || new ChargingPointType("FastCharger", Quantities.getQuantity(50d, KILOVOLTAMPERE), ElectricCurrentType.DC) || "FastCharger(50.0|DC)"
"household(1.8|DC)" || new ChargingPointType("household", Quantities.getQuantity(1.8d, KILOVOLTAMPERE), ElectricCurrentType.DC) || "household(1.8|DC)"
"Household(2.3|AC)" || HouseholdSocket || "HouseholdSocket"
"household(2.3|AC)" || HouseholdSocket || "HouseholdSocket"
"Homecharger - 11kW(4.8E-4|AC)" || new ChargingPointType("Homecharger - 11kW", Quantities.getQuantity(4.8E-4d, KILOVOLTAMPERE), ElectricCurrentType.AC) || "Homecharger - 11kW(4.8E-4|AC)"
}

def "The ChargingPointTypeUtils should throw exceptions as expected when invalid charging point type strings are provided"() {
when:
parse(invalidString)
def "The ChargingPointTypeUtils should throw exceptions as expected when invalid charging point type strings are provided"() {
when:
parse(invalidString)

then:
ChargingPointTypeException ex = thrown()
ex.message == expectedExceptionMsg
then:
ChargingPointTypeException ex = thrown()
ex.message == expectedExceptionMsg

where:
where:

invalidString || expectedExceptionMsg
"" || "Provided charging point type string '' is neither a valid custom type string nor can a common charging point type with id '' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
"DCFast" || "Provided charging point type string 'DCFast' is neither a valid custom type string nor can a common charging point type with id 'DCFast' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
"FastCharger(50|PC)" || "Provided charging point type string 'FastCharger(50|PC)' is neither a valid custom type string nor can a common charging point type with id 'FastCharger(50|PC)' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
"FastCharger(AC|2.4)" || "Provided charging point type string 'FastCharger(AC|2.4)' is neither a valid custom type string nor can a common charging point type with id 'FastCharger(AC|2.4)' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
}
invalidString || expectedExceptionMsg
"" || "Provided charging point type string '' is neither a valid custom type string nor can a common charging point type with id '' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
"DCFast" || "Provided charging point type string 'DCFast' is neither a valid custom type string nor can a common charging point type with id 'DCFast' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
"FastCharger(50|PC)" || "Provided charging point type string 'FastCharger(50|PC)' is neither a valid custom type string nor can a common charging point type with id 'FastCharger(50|PC)' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
"FastCharger(AC|2.4)" || "Provided charging point type string 'FastCharger(AC|2.4)' is neither a valid custom type string nor can a common charging point type with id 'FastCharger(AC|2.4)' be found! Please either provide a valid custom string in the format '<Name>(<kVA Value>|<AC|DC>)' (e.g. 'FastCharger(50|DC)') or a common type id (see docs for all available common types)."
}
}