Skip to content
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
6 changes: 6 additions & 0 deletions docs/readthedocs/models/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ Equality Checks
If you think you would benefit from such a method, please consider handing in an issue
`here <https://github.com/ie3-institute/PowerSystemUtils/issues>`_.

Conditional Parameters
Some of the models have conditional parameters. When reading model data from a data source, their respective factories for building these
models can handle nulls and empty Strings (as well as any combination of those) safely. E.g.: When given parameters for a line's
:code:`operationTime` where :code:`operationStartTime` and :code:`operationEndTime` are both :code:`null` or :code:`""`, the
factory will build an always-on line model.

*****
Input
*****
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,39 @@ class AssetInputEntityFactoryTest extends Specification implements FactoryTestHe
}
}

def "An AssetInputFactory should parse a valid operated AssetInput correctly (with nulls and empty strings)"() {
given: "a system participant input type factory and model data"
def inputFactory = new TestAssetInputFactory()
Map<String, String> parameter = [
"uuid": "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7",
"operatesfrom" : operatesfrom,
"operatesuntil": operatesuntil,
"id" : "TestID"
]
def inputClass = TestAssetInput
def operatorInput = Mock(OperatorInput)

when:
Optional<TestAssetInput> input = inputFactory.get(new AssetInputEntityData(parameter, inputClass, operatorInput))

then:
input.present
input.get().getClass() == inputClass
((TestAssetInput) input.get()).with {
assert uuid == UUID.fromString(parameter["uuid"])
assert operationTime == OperationTime.notLimited()
assert operator == operatorInput
assert id == parameter["id"]
}

where:
operatesfrom | operatesuntil
null | null
"" | null
null | ""
"" | ""
}

def "An AssetInputFactory should parse a valid operated AssetInput correctly (operation start time provided)"() {
given: "a system participant input type factory and model data"
def inputFactory = new TestAssetInputFactory()
Expand Down