Skip to content

Commit c4a7383

Browse files
authored
Merge branch 'dev' into ms/#795-remove-support-for-old-csv-format
2 parents 4ab9861 + 49bad16 commit c4a7383

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Formatting Spotless Groovy import order [#960](https://github.com/ie3-institute/PowerSystemDataModel/issues/960)
1111
- Implementing missing typical methods in `Try` [#970](https://github.com/ie3-institute/PowerSystemDataModel/issues/970)
12+
- Added log warning when using `SwitchInputs` with `parallelDevices` parameter [#840](https://github.com/ie3-institute/PowerSystemDataModel/issues/840)
1213

1314
### Fixed
1415
- Fixed Couchbase integration tests that randomly failed [#755](https://github.com/ie3-institute/PowerSystemDataModel/issues/755)

src/main/java/edu/ie3/datamodel/io/factory/input/SwitchInputFactory.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ protected SwitchInput buildModel(
3434
OperatorInput operator,
3535
OperationTime operationTime) {
3636
final boolean closed = data.getBoolean(CLOSED);
37+
38+
if (data.containsKey(PARALLEL_DEVICES)) {
39+
String parallelDevices = data.getField(PARALLEL_DEVICES);
40+
41+
log.warn(
42+
"The SwitchInput with id `{}` specifies the unused parameter `parallelDevices` with a value of `{}`."
43+
+ " SwitchInputs do not need to specify `parallelDevices`, as its physical value depends on"
44+
+ " the electrotechnical context of where the switch is embedded.",
45+
id,
46+
parallelDevices);
47+
}
48+
3749
return new SwitchInput(uuid, id, operator, operationTime, nodeA, nodeB, closed);
3850
}
3951
}

src/test/groovy/edu/ie3/datamodel/io/factory/input/SwitchInputFactoryTest.groovy

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,38 @@ class SwitchInputFactoryTest extends Specification implements FactoryTestHelper
5858
assert closed
5959
}
6060
}
61+
62+
def "A SwitchInputFactory should parse a valid SwitchInput with parallelDevices parameter correctly"() {
63+
given: "a system participant input type factory and model data"
64+
def inputFactory = new SwitchInputFactory()
65+
Map<String, String> parameter = [
66+
"uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
67+
"operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]",
68+
"operatesuntil": "",
69+
"id" : "TestID",
70+
"closed" : "true",
71+
"paralleldevices": "2"
72+
]
73+
def inputClass = SwitchInput
74+
def operatorInput = Mock(OperatorInput)
75+
def nodeInputA = Mock(NodeInput)
76+
def nodeInputB = Mock(NodeInput)
77+
78+
expect:
79+
Try<SwitchInput, FactoryException> input = inputFactory.get(new ConnectorInputEntityData(parameter, inputClass, operatorInput, nodeInputA, nodeInputB))
80+
input.success
81+
input.data.get().getClass() == inputClass
82+
input.data.get().with {
83+
assert uuid == UUID.fromString(parameter["uuid"])
84+
assert operationTime.startDate.present
85+
assert operationTime.startDate.get() == ZonedDateTime.parse(parameter["operatesfrom"])
86+
assert !operationTime.endDate.present
87+
assert operator == operatorInput
88+
assert id == parameter["id"]
89+
assert nodeA == nodeInputA
90+
assert nodeB == nodeInputB
91+
assert closed
92+
assert parallelDevices == 1
93+
}
94+
}
6195
}

0 commit comments

Comments
 (0)