Skip to content

Commit

Permalink
Merge branch 'dev' into ms/#827-use-java-streams-on-sql-fetsches-effe…
Browse files Browse the repository at this point in the history
…ctively
  • Loading branch information
staudtMarius authored May 23, 2024
2 parents ea320e7 + 1024473 commit ed1fa01
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'signing'
id 'pmd' // code check, working on source code
id 'com.diffplug.spotless' version '6.25.0' //code format
id 'com.github.spotbugs' version '6.0.14' // code check, working on byte code
id 'com.github.spotbugs' version '6.0.15' // code check, working on byte code
id 'de.undercouch.download' version '5.6.0'
id 'kr.motd.sphinx' version '2.10.1' // documentation generation
id 'jacoco' // java code coverage plugin
Expand Down Expand Up @@ -73,7 +73,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation "org.spockframework:spock-core:2.3-groovy-$groovyVersion"
testImplementation 'org.objenesis:objenesis:3.4' // Mock creation with constructor parameters
testImplementation 'net.bytebuddy:byte-buddy:1.14.15' // Mocks of classes
testImplementation 'net.bytebuddy:byte-buddy:1.14.16' // Mocks of classes

// testcontainers (docker framework for testing)
testImplementation "org.testcontainers:testcontainers:$testcontainersVersion"
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

0 comments on commit ed1fa01

Please sign in to comment.