Skip to content

Commit 5a3ad32

Browse files
authored
Merge branch 'dev' into ms/#1007-refactor-CsvFileConnector-and-CsvDataSource
2 parents 6496add + 1024473 commit 5a3ad32

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

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

1213
### Fixed
1314
- Fixed `MappingEntryies` not getting processed by adding `Getter` methods for record fields [#1084](https://github.com/ie3-institute/PowerSystemDataModel/issues/1084)

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'signing'
66
id 'pmd' // code check, working on source code
77
id 'com.diffplug.spotless' version '6.25.0' //code format
8-
id 'com.github.spotbugs' version '6.0.14' // code check, working on byte code
8+
id 'com.github.spotbugs' version '6.0.15' // code check, working on byte code
99
id 'de.undercouch.download' version '5.6.0'
1010
id 'kr.motd.sphinx' version '2.10.1' // documentation generation
1111
id 'jacoco' // java code coverage plugin
@@ -73,7 +73,7 @@ dependencies {
7373
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
7474
testImplementation "org.spockframework:spock-core:2.3-groovy-$groovyVersion"
7575
testImplementation 'org.objenesis:objenesis:3.4' // Mock creation with constructor parameters
76-
testImplementation 'net.bytebuddy:byte-buddy:1.14.15' // Mocks of classes
76+
testImplementation 'net.bytebuddy:byte-buddy:1.14.16' // Mocks of classes
7777

7878
// testcontainers (docker framework for testing)
7979
testImplementation "org.testcontainers:testcontainers:$testcontainersVersion"

src/main/java/edu/ie3/datamodel/utils/validation/ConnectorValidationUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected static List<Try<Void, InvalidEntityException>> check(ConnectorInput co
6565

6666
List<Try<Void, InvalidEntityException>> exceptions = new ArrayList<>();
6767
exceptions.add(connectsDifferentNodes(connector));
68+
exceptions.add(lessThanOneParallelDevice(connector));
6869

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

447+
/**
448+
* Check that the given connector has at least one parallel device.
449+
*
450+
* @param connectorInput to check
451+
* @return a try
452+
*/
453+
private static Try<Void, InvalidEntityException> lessThanOneParallelDevice(
454+
ConnectorInput connectorInput) {
455+
return Try.ofVoid(
456+
connectorInput.getParallelDevices() < 1,
457+
() ->
458+
new InvalidEntityException(
459+
connectorInput.getClass().getSimpleName()
460+
+ " needs to have at least one parallel device",
461+
connectorInput));
462+
}
463+
446464
/**
447465
* Check if subnets of connector's nodes are correct depending on if they should be equal or not
448466
*

src/test/groovy/edu/ie3/datamodel/utils/validation/ConnectorValidationUtilsTest.groovy

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ class ConnectorValidationUtilsTest extends Specification {
6262
OlmCharacteristicInput.CONSTANT_CHARACTERISTIC
6363
)
6464

65+
def "A ConnectorInput needs at least one parallel device"() {
66+
when:
67+
def actual = ConnectorValidationUtils.lessThanOneParallelDevice(invalidConnector)
68+
69+
then:
70+
actual.failure
71+
actual.exception.get().class == InvalidEntityException
72+
actual.exception.get().message.contains(expectedMessage)
73+
74+
where:
75+
invalidConnector || expectedMessage
76+
GridTestData.lineFtoG.copy().parallelDevices(0).build() || "LineInput needs to have at least one parallel device"
77+
GridTestData.lineCtoD.copy().parallelDevices(-1).build() || "LineInput needs to have at least one parallel device"
78+
GridTestData.transformerBtoE.copy().parallelDevices(0).build() || "Transformer2WInput needs to have at least one parallel device"
79+
GridTestData.transformerAtoBtoC.copy().parallelDevices(0).build() || "Transformer3WInput needs to have at least one parallel device"
80+
}
81+
6582
def "ConnectorValidationUtils.checkLine() recognizes all potential errors for a line"() {
6683
when:
6784
List<Try<Void, InvalidEntityException>> exceptions = ConnectorValidationUtils.check(invalidLine).stream().filter { it -> it.failure }.toList()

0 commit comments

Comments
 (0)