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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- Enhancing `VoltageLevel` with `equals` method [#1063](https://github.com/ie3-institute/PowerSystemDataModel/issues/1063)
- `ConnectorValidationUtils` checks if parallel devices is > 0 [#1077](https://github.com/ie3-institute/PowerSystemDataModel/issues/1077)

### Fixed
- Fixed `MappingEntryies` not getting processed by adding `Getter` methods for record fields [#1084](https://github.com/ie3-institute/PowerSystemDataModel/issues/1084)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected static List<Try<Void, InvalidEntityException>> check(ConnectorInput co

List<Try<Void, InvalidEntityException>> exceptions = new ArrayList<>();
exceptions.add(connectsDifferentNodes(connector));
exceptions.add(lessThanOneParallelDevice(connector));

// Further checks for subclasses
if (LineInput.class.isAssignableFrom(connector.getClass())) {
Expand Down Expand Up @@ -443,6 +444,23 @@ private static Try<Void, InvalidEntityException> connectsDifferentNodes(
connectorInput));
}

/**
* Check that the given connector has at least one parallel device.
*
* @param connectorInput to check
* @return a try
*/
private static Try<Void, InvalidEntityException> lessThanOneParallelDevice(
ConnectorInput connectorInput) {
return Try.ofVoid(
connectorInput.getParallelDevices() < 1,
() ->
new InvalidEntityException(
connectorInput.getClass().getSimpleName()
+ " needs to have at least one parallel device",
connectorInput));
}

/**
* Check if subnets of connector's nodes are correct depending on if they should be equal or not
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ class ConnectorValidationUtilsTest extends Specification {
OlmCharacteristicInput.CONSTANT_CHARACTERISTIC
)

def "A ConnectorInput needs at least one parallel device"() {
when:
def actual = ConnectorValidationUtils.lessThanOneParallelDevice(invalidConnector)

then:
actual.failure
actual.exception.get().class == InvalidEntityException
actual.exception.get().message.contains(expectedMessage)

where:
invalidConnector || expectedMessage
GridTestData.lineFtoG.copy().parallelDevices(0).build() || "LineInput needs to have at least one parallel device"
GridTestData.lineCtoD.copy().parallelDevices(-1).build() || "LineInput needs to have at least one parallel device"
GridTestData.transformerBtoE.copy().parallelDevices(0).build() || "Transformer2WInput needs to have at least one parallel device"
GridTestData.transformerAtoBtoC.copy().parallelDevices(0).build() || "Transformer3WInput needs to have at least one parallel device"
}

def "ConnectorValidationUtils.checkLine() recognizes all potential errors for a line"() {
when:
List<Try<Void, InvalidEntityException>> exceptions = ConnectorValidationUtils.check(invalidLine).stream().filter { it -> it.failure }.toList()
Expand Down