diff --git a/CHANGELOG.md b/CHANGELOG.md index bbf9b8f53a..1a6609f374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated `Couchbase` version within the tests [#1586](https://github.com/ie3-institute/PowerSystemDataModel/issues/1586) - Use the default time pattern for persisting time series keys [#766](https://github.com/ie3-institute/PowerSystemDataModel/issues/766) - Handled some more SonarQube Issues [#1598](https://github.com/ie3-institute/PowerSystemDataModel/issues/1598) +- Change Evcs.locationType from single element to list [#1460](https://github.com/ie3-institute/PowerSystemDataModel/issues/1460) ## [8.1.0] - 2025-07-25 diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java index c6a734535e..4baf07602f 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java @@ -18,14 +18,12 @@ import edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointTypeUtils; import edu.ie3.datamodel.models.input.system.type.evcslocation.EvcsLocationType; import edu.ie3.datamodel.models.input.system.type.evcslocation.EvcsLocationTypeUtils; +import java.util.List; import java.util.UUID; /** * Factory to create instances of {@link EvcsInput}s based on {@link SystemParticipantEntityData} * and additional fields. - * - * @version 0.1 - * @since 26.07.20 */ public class EvcsInputFactory extends SystemParticipantInputEntityFactory { @@ -59,15 +57,19 @@ protected EvcsInput buildModel( final int chargingPoints = data.getInt(CHARGING_POINTS); final double cosPhi = data.getDouble(COS_PHI_RATED); - final EvcsLocationType locationType; - String locationFieldValue = data.getField(LOCATION_TYPE); + final List locationTypes; + String locationFieldValue = data.getField(LOCATION_TYPES); try { - locationType = EvcsLocationTypeUtils.parse(locationFieldValue); + if (locationFieldValue.contains(",")) { + locationTypes = EvcsLocationTypeUtils.parse(locationFieldValue); + } else { + locationTypes = List.of(EvcsLocationTypeUtils.parseSingle(locationFieldValue)); + } } catch (ParsingException e) { throw new FactoryException( String.format( - "Exception while trying to parse field \"%s\" with supposed int value \"%s\"", - LOCATION_TYPE, locationFieldValue), + "Exception while trying to parse field \"%s\" with supposed value \"%s\"", + LOCATION_TYPES, locationFieldValue), e); } @@ -84,7 +86,7 @@ protected EvcsInput buildModel( type, chargingPoints, cosPhi, - locationType, + locationTypes, v2gSupport, data.getFieldsToValues()); } diff --git a/src/main/java/edu/ie3/datamodel/io/naming/FieldNamingStrategy.java b/src/main/java/edu/ie3/datamodel/io/naming/FieldNamingStrategy.java index c47704773c..8af3252f1a 100644 --- a/src/main/java/edu/ie3/datamodel/io/naming/FieldNamingStrategy.java +++ b/src/main/java/edu/ie3/datamodel/io/naming/FieldNamingStrategy.java @@ -101,7 +101,7 @@ public class FieldNamingStrategy { public static final String COS_PHI_RATED = "cosPhiRated"; public static final String E_CONS_ANNUAL = "eConsAnnual"; public static final String FEED_IN_TARIFF = "feedInTariff"; - public static final String LOCATION_TYPE = "locationType"; + public static final String LOCATION_TYPES = "locationTypes"; public static final String LOAD_PROFILE = "loadProfile"; public static final String OLM_CHARACTERISTIC = "olmCharacteristic"; public static final String Q_CHARACTERISTICS = "qCharacteristics"; diff --git a/src/main/java/edu/ie3/datamodel/io/naming/ModelFields.java b/src/main/java/edu/ie3/datamodel/io/naming/ModelFields.java index 32203e634d..0f8034f338 100644 --- a/src/main/java/edu/ie3/datamodel/io/naming/ModelFields.java +++ b/src/main/java/edu/ie3/datamodel/io/naming/ModelFields.java @@ -342,7 +342,8 @@ private static void registerParticipantFields() { addMandatory(ChpInput.class, TYPE, THERMAL_BUS, THERMAL_STORAGE); - addMandatory(EvcsInput.class, TYPE, CHARGING_POINTS, COS_PHI_RATED, LOCATION_TYPE, V2G_SUPPORT); + addMandatory( + EvcsInput.class, TYPE, CHARGING_POINTS, COS_PHI_RATED, LOCATION_TYPES, V2G_SUPPORT); addMandatory(EvInput.class, TYPE, Q_CHARACTERISTICS); diff --git a/src/main/java/edu/ie3/datamodel/io/processor/Processor.java b/src/main/java/edu/ie3/datamodel/io/processor/Processor.java index 4c466e5e8e..410deb10d5 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/Processor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/Processor.java @@ -236,8 +236,16 @@ protected String processMethodResult( "DayOfWeek", "Season", "ChargingPointType", - "EvcsLocationType" -> + "EvcsLocationTypes" -> resultStringBuilder.append(methodReturnObject.toString()); + case "List", "ArrayList" -> { + if (methodReturnObject instanceof Collection collection) { + resultStringBuilder.append( + collection.stream().map(Object::toString).collect(Collectors.joining(",", "[", "]"))); + } else { + resultStringBuilder.append(methodReturnObject.toString()); + } + } case "Quantity", "ComparableQuantity" -> resultStringBuilder.append(handleQuantity((Quantity) methodReturnObject, fieldName)); case "Optional" -> diff --git a/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java b/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java index 14d3f4898e..883b85755b 100644 --- a/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java +++ b/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java @@ -334,8 +334,8 @@ private String[] csvHeaderElements(String[] strings) { } /** - * Transforms a provided map of string to string to valid csv formatted strings (according to csv - * specification RFC 4180) + * Transforms a provided map of string to string into valid csv formatted strings (according to + * csv specification RFC 4180) * * @param entityFieldData a string to string map that should be processed * @return a new map with valid csv formatted keys and values strings diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java index fa7976b8ec..c1a60694f9 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java @@ -12,6 +12,7 @@ import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; import edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointType; import edu.ie3.datamodel.models.input.system.type.evcslocation.EvcsLocationType; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.UUID; @@ -29,15 +30,15 @@ public class EvcsInput extends SystemParticipantInput { /** Rated power factor */ private final double cosPhiRated; - /** Evcs location type */ - private final EvcsLocationType locationType; + /** Evcs location types (minimum one required) */ + private final List locationTypes; /** Whether charging station supports vehicle to grid */ private final boolean v2gSupport; /** * @param uuid Unique identifier - * @param id Human readable identifier + * @param id Human-readable identifier * @param operator of the asset * @param operationTime Time for which the entity is operated * @param node that the asset is connected to @@ -46,7 +47,7 @@ public class EvcsInput extends SystemParticipantInput { * @param type type of the charging points available to this charging station * @param chargingPoints number of charging points available at this charging station * @param cosPhiRated rated cos phi - * @param locationType the location type + * @param locationTypes the location types (minimum one required) * @param v2gSupport whether charging station supports vehicle to grid */ public EvcsInput( @@ -60,19 +61,22 @@ public EvcsInput( ChargingPointType type, int chargingPoints, double cosPhiRated, - EvcsLocationType locationType, + List locationTypes, boolean v2gSupport) { super(uuid, id, operator, operationTime, node, qCharacteristics, em); + if (locationTypes == null || locationTypes.isEmpty()) { + throw new IllegalArgumentException("At least one location type must be provided"); + } this.type = type; this.chargingPoints = chargingPoints; this.cosPhiRated = cosPhiRated; - this.locationType = locationType; + this.locationTypes = List.copyOf(locationTypes); this.v2gSupport = v2gSupport; } /** * @param uuid Unique identifier - * @param id Human readable identifier + * @param id Human-readable identifier * @param operator of the asset * @param operationTime Time for which the entity is operated * @param node that the asset is connected to @@ -81,7 +85,7 @@ public EvcsInput( * @param type type of the charging points available to this charging station * @param chargingPoints number of charging points available at this charging station * @param cosPhiRated rated cos phi - * @param locationType the location type + * @param locationTypes the location types (minimum one required) * @param v2gSupport whether charging station supports vehicle to grid * @param additionalInformation That were provided by the source */ @@ -96,21 +100,21 @@ public EvcsInput( ChargingPointType type, int chargingPoints, double cosPhiRated, - EvcsLocationType locationType, + List locationTypes, boolean v2gSupport, Map additionalInformation) { super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.type = type; this.chargingPoints = chargingPoints; this.cosPhiRated = cosPhiRated; - this.locationType = locationType; + this.locationTypes = locationTypes; this.v2gSupport = v2gSupport; setAdditionalInformation(additionalInformation); } /** * @param uuid Unique identifier - * @param id Human readable identifier + * @param id Human-readable identifier * @param operator of the asset * @param operationTime Time for which the entity is operated * @param node that the asset is connected to @@ -118,7 +122,7 @@ public EvcsInput( * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type type of the charging points available to this charging station * @param cosPhiRated rated cos phi - * @param locationType the location type + * @param locationTypes the location types (minimum one required) * @param v2gSupport whether charging station supports vehicle to grid */ public EvcsInput( @@ -131,7 +135,7 @@ public EvcsInput( EmInput em, ChargingPointType type, double cosPhiRated, - EvcsLocationType locationType, + List locationTypes, boolean v2gSupport) { this( uuid, @@ -144,20 +148,20 @@ public EvcsInput( type, 1, cosPhiRated, - locationType, + locationTypes, v2gSupport); } /** * @param uuid Unique identifier - * @param id Human readable identifier + * @param id Human-readable identifier * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type type of the charging points available to this charging station * @param chargingPoints number of charging points available at this charging station * @param cosPhiRated rated cos phi - * @param locationType the location type + * @param locationTypes the location types (minimum one required) * @param v2gSupport whether charging station supports vehicle to grid */ public EvcsInput( @@ -169,25 +173,28 @@ public EvcsInput( ChargingPointType type, int chargingPoints, double cosPhiRated, - EvcsLocationType locationType, + List locationTypes, boolean v2gSupport) { super(uuid, id, node, qCharacteristics, em); + if (locationTypes == null || locationTypes.isEmpty()) { + throw new IllegalArgumentException("At least one location type must be provided"); + } this.type = type; this.chargingPoints = chargingPoints; this.cosPhiRated = cosPhiRated; - this.locationType = locationType; + this.locationTypes = List.copyOf(locationTypes); this.v2gSupport = v2gSupport; } /** * @param uuid Unique identifier - * @param id Human readable identifier + * @param id Human-readable identifier * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type type of the charging points available to this charging station * @param cosPhiRated rated cos phi - * @param locationType the location type + * @param locationTypes the location types (minimum one required) * @param v2gSupport whether charging station supports vehicle to grid */ public EvcsInput( @@ -198,9 +205,9 @@ public EvcsInput( EmInput em, ChargingPointType type, double cosPhiRated, - EvcsLocationType locationType, + List locationTypes, boolean v2gSupport) { - this(uuid, id, node, qCharacteristics, em, type, 1, cosPhiRated, locationType, v2gSupport); + this(uuid, id, node, qCharacteristics, em, type, 1, cosPhiRated, locationTypes, v2gSupport); } public ChargingPointType getType() { @@ -215,8 +222,8 @@ public double getCosPhiRated() { return cosPhiRated; } - public EvcsLocationType getLocationType() { - return locationType; + public List getLocationTypes() { + return locationTypes; } public boolean getV2gSupport() { @@ -241,13 +248,13 @@ public boolean equals(Object o) { return chargingPoints == evcsInput.chargingPoints && Double.compare(evcsInput.cosPhiRated, cosPhiRated) == 0 && type.equals(evcsInput.type) - && locationType.equals(evcsInput.locationType) + && locationTypes.equals(evcsInput.locationTypes) && v2gSupport == evcsInput.v2gSupport; } @Override public int hashCode() { - return Objects.hash(super.hashCode(), type, chargingPoints, cosPhiRated, locationType); + return Objects.hash(super.hashCode(), type, chargingPoints, cosPhiRated, locationTypes); } @Override @@ -273,8 +280,8 @@ public String toString() { + chargingPoints + ", cosPhiRated=" + cosPhiRated - + ", locationType=" - + locationType + + ", locationTypes=" + + locationTypes + ", v2gSupport=" + getV2gSupport() + ", additionalInformation=" @@ -285,9 +292,6 @@ public String toString() { /** * A builder pattern based approach to create copies of {@link EvcsInput} entities with altered * field values. For detailed field descriptions refer to java docs of {@link EvcsInput} - * - * @version 0.1 - * @since 05.06.20 */ public static class EvcsInputCopyBuilder extends SystemParticipantInputCopyBuilder { @@ -295,7 +299,7 @@ public static class EvcsInputCopyBuilder private ChargingPointType type; private int chargingPoints; private double cosPhiRated; - private EvcsLocationType locationType; + private List locationTypes; private boolean v2gSupport; public EvcsInputCopyBuilder(EvcsInput entity) { @@ -303,7 +307,7 @@ public EvcsInputCopyBuilder(EvcsInput entity) { this.type = entity.type; this.chargingPoints = entity.chargingPoints; this.cosPhiRated = entity.cosPhiRated; - this.locationType = entity.locationType; + this.locationTypes = entity.locationTypes; this.v2gSupport = entity.v2gSupport; } @@ -322,8 +326,8 @@ public EvcsInputCopyBuilder cosPhiRated(double cosPhiRated) { return thisInstance(); } - public EvcsInputCopyBuilder locationType(EvcsLocationType locationType) { - this.locationType = locationType; + public EvcsInputCopyBuilder locationTypes(List locationTypes) { + this.locationTypes = locationTypes; return thisInstance(); } @@ -351,7 +355,7 @@ public EvcsInput build() { type, chargingPoints, cosPhiRated, - locationType, + locationTypes, v2gSupport); } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtils.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtils.java index ffb31c0765..60f6a97073 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtils.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtils.java @@ -6,7 +6,10 @@ package edu.ie3.datamodel.models.input.system.type.evcslocation; import edu.ie3.datamodel.exceptions.ParsingException; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; /** * Utility class providing tools to retrieve {@link EvcsLocationType}s from string representation @@ -28,15 +31,51 @@ private EvcsLocationTypeUtils() { } /** - * Parsing a location type string into one {@link EvcsLocationType}. Matching the string is - * case-insensitive and all - and _ are removed. Throws exception, if type does not exist. + * Parsing a location type string into one {@link EvcsLocationType} or a list of + * EvcsLocationTypes. Matching the string is case-insensitive and all - and _ are removed. + * + * @param parsableString string to parse + * @return List + * @throws ParsingException if string does not represent a location type + */ + public static List parse(String parsableString) throws ParsingException { + if (parsableString == null || parsableString.trim().isEmpty()) { + throw new ParsingException("Location types string cannot be null or empty"); + } + + // Remove brackets if present + parsableString = parsableString.replace("[", "").replace("]", ""); + + // Check if it contains comma for multiple values + if (parsableString.contains(",")) { + return Arrays.stream(parsableString.split(",")) + .map(String::trim) + .filter(s -> !s.isEmpty()) + .map( + s -> { + try { + return parseSingle(s); + } catch (ParsingException e) { + throw new RuntimeException(e); + } + }) + .collect(Collectors.toList()); + } else { + // Single value - wrap in List + return List.of(parseSingle(parsableString.trim())); + } + } + + /** + * Parsing a single location type string into one {@link EvcsLocationType}. Matching the string is + * case-insensitive and all - and _ are removed. * * @param parsableString string to parse * @return corresponding EvcsLocationType * @throws ParsingException if string does not represent a location type */ - public static EvcsLocationType parse(String parsableString) throws ParsingException { - final String key = toKey(parsableString); + public static EvcsLocationType parseSingle(String parsableString) throws ParsingException { + final String key = toKey(parsableString.replace("[", "").replace("]", "")); if (nameToType.containsKey(key)) return nameToType.get(key); else throw new ParsingException("EvcsLocationType '" + key + "' does not exist."); } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy index 98fd26772f..c451b37458 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy @@ -24,7 +24,6 @@ import javax.measure.quantity.Dimensionless /** * Testing EvcsInputFactory * - * @version 0.1* @since 26.07.20 */ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { @@ -49,8 +48,8 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { "type" : "Household", "chargingpoints" : "4", "cosphirated" : "0.95", - "locationtype" : "CHARGING_HUB_TOWN", - "v2gsupport" : "false" + "locationtypes" : "CHARGING_HUB_TOWN, STREET", + "v2gsupport" : "false" ] def inputClass = EvcsInput def nodeInput = Mock(NodeInput) @@ -83,7 +82,10 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { type == ChargingPointTypeUtils.HouseholdSocket chargingPoints == Integer.parseInt(parameter["chargingpoints"]) cosPhiRated == Double.parseDouble(parameter["cosphirated"]) - locationType == EvcsLocationType.CHARGING_HUB_TOWN + locationTypes == [ + EvcsLocationType.CHARGING_HUB_TOWN, + EvcsLocationType.STREET + ] !v2gSupport } } @@ -100,8 +102,8 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { "type" : "-- invalid --", "chargingpoints" : "4", "cosphirated" : "0.95", - "locationtype" : "CHARGING_HUB_TOWN", - "v2gsupport" : "false" + "locationtypes" : "[CHARGING_HUB_TOWN]", + "v2gsupport" : "false" ] def inputClass = EvcsInput def nodeInput = Mock(NodeInput) @@ -129,8 +131,8 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { "type" : "Household", "chargingpoints" : "4", "cosphirated" : "0.95", - "locationType" : "-- invalid --", - "v2gsupport" : "false" + "locationtypes" : "-- invalid --", + "v2gsupport" : "false" ] def inputClass = EvcsInput def nodeInput = Mock(NodeInput) @@ -143,6 +145,6 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { then: input.failure - input.exception.get().cause.message == "Exception while trying to parse field \"locationType\" with supposed int value \"-- invalid --\"" + input.exception.get().cause.message == "Exception while trying to parse field \"locationTypes\" with supposed value \"-- invalid --\"" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy index 6e55061445..234e718118 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy @@ -242,7 +242,6 @@ class InputEntityProcessorTest extends Specification { "type" : SystemParticipantTestData.evInput.type.getUuid().toString(), "controllingEm" : SystemParticipantTestData.evInput.controllingEm.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] - LoadInput | SystemParticipantTestData.loadInput || [ "uuid" : SystemParticipantTestData.loadInput.uuid.toString(), "cosPhiRated" : SystemParticipantTestData.loadInput.cosPhiRated.toString(), @@ -291,7 +290,7 @@ class InputEntityProcessorTest extends Specification { "type" : SystemParticipantTestData.evcsInput.type.toString(), "cosPhiRated" : SystemParticipantTestData.evcsInput.cosPhiRated.toString(), "chargingPoints" : SystemParticipantTestData.evcsInput.chargingPoints.toString(), - "locationType" : SystemParticipantTestData.evcsInput.locationType.name(), + "locationTypes" : SystemParticipantTestData.evcsInput.locationTypes.toString(), "v2gSupport" : SystemParticipantTestData.evcsInput.v2gSupport.toString(), "controllingEm" : SystemParticipantTestData.evcsInput.controllingEm.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy index 968e8b47b9..33be996454 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy @@ -20,7 +20,9 @@ class EvcsInputTest extends Specification { def alteredEntity = evcsInput.copy() .type(ChargingPointTypeUtils.TeslaSuperChargerV3) .cosPhiRated(0.7d).chargingPoints(1) - .locationType(EvcsLocationType.CHARGING_HUB_HIGHWAY) + .locationTypes([ + EvcsLocationType.CHARGING_HUB_HIGHWAY + ]) .v2gSupport(true) .build() @@ -34,7 +36,9 @@ class EvcsInputTest extends Specification { type == ChargingPointTypeUtils.TeslaSuperChargerV3 cosPhiRated == 0.7d chargingPoints == 1 - locationType == EvcsLocationType.CHARGING_HUB_HIGHWAY + locationTypes == [ + EvcsLocationType.CHARGING_HUB_HIGHWAY + ] v2gSupport controllingEm == Optional.of(SystemParticipantTestData.emInput) } @@ -58,7 +62,7 @@ class EvcsInputTest extends Specification { sRated() == evcsInput.type.sRated * 2d cosPhiRated == evcsInput.cosPhiRated chargingPoints == evcsInput.chargingPoints - locationType == evcsInput.locationType + locationTypes == evcsInput.locationTypes v2gSupport == evcsInput.v2gSupport controllingEm == Optional.of(SystemParticipantTestData.emInput) } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtilsTest.groovy index b69bb3279e..280a4c76f6 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/evcslocation/EvcsLocationTypeUtilsTest.groovy @@ -24,11 +24,12 @@ class EvcsLocationTypeUtilsTest extends Specification { def "The EvcsLocationTypeUtils should parse valid evcs location type strings as expected"() { given: - EvcsLocationType parsed = parse(parsableString) + List parsed = parse(parsableString) expect: - parsed == expectedObj - parsed.name().toLowerCase().replaceAll("[-_]*", "") == parsableString.toLowerCase().replaceAll("[-_]*", "") + parsed.size() == 1 + parsed[0] == expectedObj + parsed[0].name().toLowerCase().replaceAll("[-_]*", "") == parsableString.toLowerCase().replaceAll("[-_]*", "") where: parsableString || expectedObj @@ -42,6 +43,19 @@ class EvcsLocationTypeUtilsTest extends Specification { "charginghubhighway" || CHARGING_HUB_HIGHWAY // lower case without underscores } + def "The EvcsLocationTypeUtils should parse multiple evcs location type strings as expected"() { + given: + List parsed = parse(parsableString) + + expect: + parsed == expectedObj + + where: + parsableString || expectedObj + "WORK, CUSTOMER_PARKING" || [WORK, CUSTOMER_PARKING] + "HOME,WORK,STREET" || [HOME, WORK, STREET] + } + def "The EvcsLocationTypeUtils should throw exceptions as expected when invalid evcs location type string is provided"() { when: parse("--invalid--") diff --git a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy index fd06559ca5..d1fac50669 100644 --- a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy @@ -354,7 +354,7 @@ class SystemParticipantTestData { ChargingPointTypeUtils.HouseholdSocket, 4, cosPhiRated, - EvcsLocationType.HOME, + [EvcsLocationType.HOME], v2gSupport ) diff --git a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql index 74e73ed148..ddb243ce15 100644 --- a/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql +++ b/src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql @@ -41,7 +41,7 @@ CREATE TABLE public.evcs_input controlling_em UUID, cos_phi_rated TEXT NOT NULL, id TEXT NOT NULL, - location_type TEXT NOT NULL, + location_types TEXT NOT NULL, node UUID NOT NULL, operates_from TIMESTAMP WITH TIME ZONE, operates_until TIMESTAMP WITH TIME ZONE, diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv index 011aeb72a2..613d63b42f 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv @@ -1,3 +1,3 @@ -uuid,charging_points,cos_phi_rated,id,location_type,node,operates_from,operates_until,operator,q_characteristics,type,v_2g_support,controlling_em +uuid,charging_points,cos_phi_rated,id,location_types,node,operates_from,operates_until,operator,q_characteristics,type,v_2g_support,controlling_em 06a14909-366e-4e94-a593-1016e1455b30,4,0.9,test_evcs_1,HOME,5f1c776c-6935-40f7-ba9e-60646e08992b,,,,"cosPhiFixed:{(0.0,1.0)}",ChargingStationType1,true, 104acdaa-5dc5-4197-aed2-2fddb3c4f237,4,0.9,test_evcs_2,HOME,ed4697fd-016c-40c2-a66b-e793878dadea,,,,"cosPhiFixed:{(0.0,1.0)}",ChargingStationType1,true, diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv index 0fd01d91ff..ef408c5d2c 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv @@ -1,2 +1,2 @@ -uuid,id,operator,operates_from,operates_until,node,q_characteristics,cos_phi_rated,type,charging_points,location_type,v2g_support,controlling_em +uuid,id,operator,operates_from,operates_until,node,q_characteristics,cos_phi_rated,type,charging_points,location_types,v2g_support,controlling_em 798028b5-caff-4da7-bcd9-1750fdd8742c,test_csInput,8f9682df-0744-4b58-a122-f0dc730f6510,2020-03-24T15:11:31Z,2020-03-25T15:11:31Z,4ca90220-74c2-4369-9afa-a18bf068840d,"cosPhiFixed:{(0.00,0.95)}",0.95,hhs,4,HOME,false,977157f4-25e5-4c72-bf34-440edc778792 \ No newline at end of file