Skip to content

Adding log message when using SwitchInputs with parallelDevices #988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 29, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Formatting Spotless Groovy import order [#960](https://github.com/ie3-institute/PowerSystemDataModel/issues/960)
- Implementing missing typical methods in `Try` [#970](https://github.com/ie3-institute/PowerSystemDataModel/issues/970)
- Added log warning when using `SwitchInputs` with `parallelDevices` parameter [#840](https://github.com/ie3-institute/PowerSystemDataModel/issues/840)

### Fixed
- Fixed Couchbase integration tests that randomly failed [#755](https://github.com/ie3-institute/PowerSystemDataModel/issues/755)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ protected SwitchInput buildModel(
OperatorInput operator,
OperationTime operationTime) {
final boolean closed = data.getBoolean(CLOSED);

if (data.containsKey(PARALLEL_DEVICES)) {
String parallelDevices = data.getField(PARALLEL_DEVICES);

log.warn(
"The SwitchInput with id `{}` specifies the unused parameter `parallelDevices` with a value of `{}`."
+ " SwitchInputs do not need to specify `parallelDevices`, as its physical value depends on"
+ " the electrotechnical context of where the switch is embedded.",
id,
parallelDevices);
}

return new SwitchInput(uuid, id, operator, operationTime, nodeA, nodeB, closed);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,38 @@ class SwitchInputFactoryTest extends Specification implements FactoryTestHelper
assert closed
}
}

def "A SwitchInputFactory should parse a valid SwitchInput with parallelDevices parameter correctly"() {
given: "a system participant input type factory and model data"
def inputFactory = new SwitchInputFactory()
Map<String, String> parameter = [
"uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
"operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]",
"operatesuntil": "",
"id" : "TestID",
"closed" : "true",
"paralleldevices": "2"
]
def inputClass = SwitchInput
def operatorInput = Mock(OperatorInput)
def nodeInputA = Mock(NodeInput)
def nodeInputB = Mock(NodeInput)

expect:
Try<SwitchInput, FactoryException> input = inputFactory.get(new ConnectorInputEntityData(parameter, inputClass, operatorInput, nodeInputA, nodeInputB))
input.success
input.data.get().getClass() == inputClass
input.data.get().with {
assert uuid == UUID.fromString(parameter["uuid"])
assert operationTime.startDate.present
assert operationTime.startDate.get() == ZonedDateTime.parse(parameter["operatesfrom"])
assert !operationTime.endDate.present
assert operator == operatorInput
assert id == parameter["id"]
assert nodeA == nodeInputA
assert nodeB == nodeInputB
assert closed
assert parallelDevices == 1
}
}
}