Skip to content

Fixed handling of CongestionResult.InputModelType in EntityProcessor #1326

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

## [Unreleased/Snapshot]

### Fixed
- Fixed handling of `CongestionResult.InputModelType` in `EntityProcessor` [#1325](https://github.com/ie3-institute/PowerSystemDataModel/issues/1325)

### Changed
- Updated dependabot workflow and added CODEOWNERS [#1328](https://github.com/ie3-institute/PowerSystemDataModel/issues/1328)

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/processor/Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import edu.ie3.datamodel.models.input.connector.SwitchInput;
import edu.ie3.datamodel.models.input.system.characteristic.CharacteristicInput;
import edu.ie3.datamodel.models.profile.LoadProfile;
import edu.ie3.datamodel.models.result.CongestionResult;
import edu.ie3.datamodel.models.voltagelevels.VoltageLevel;
import edu.ie3.datamodel.utils.Try;
import edu.ie3.datamodel.utils.Try.*;
Expand Down Expand Up @@ -293,6 +294,8 @@ protected String processMethodResult(Object methodReturnObject, Method method, S
"ReactivePowerCharacteristic",
"CharacteristicInput" -> resultStringBuilder.append(
((CharacteristicInput<?, ?>) methodReturnObject).serialize());
case "InputModelType" -> resultStringBuilder.append(
((CongestionResult.InputModelType) methodReturnObject).type);
default -> throw new EntityProcessorException(
"Unable to process value for attribute/field '"
+ fieldName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package edu.ie3.datamodel.io.processor.result

import edu.ie3.datamodel.exceptions.EntityProcessorException
import edu.ie3.datamodel.models.StandardUnits
import edu.ie3.datamodel.models.result.CongestionResult
import edu.ie3.datamodel.models.result.NodeResult
import edu.ie3.datamodel.models.result.ResultEntity
import edu.ie3.datamodel.models.result.connector.LineResult
Expand Down Expand Up @@ -277,6 +278,37 @@ class ResultEntityProcessorTest extends Specification {
validProcessedElement == expectedResults
}

def "A ResultEntityProcessor should serialize a CongestionResult correctly"() {
given:
def resultProcessor = new ResultEntityProcessor(CongestionResult)

def validResult = new CongestionResult(
ZonedDateTime.parse("2020-01-30T17:26:44Z"),
inputModel,
CongestionResult.InputModelType.LINE,
3,
Quantities.getQuantity(110, Units.PERCENT),
Quantities.getQuantity(0, Units.PERCENT),
Quantities.getQuantity(100, Units.PERCENT),
)

def expectedResults = [
inputModel: '22bea5fc-2cb2-4c61-beb9-b476e0107f52',
max : '100.0',
min : '0.0',
subgrid : '3',
time : '2020-01-30T17:26:44Z',
type : 'line',
value : '110.0'
]

when:
def validProcessedElement = resultProcessor.handleEntity(validResult)

then:
validProcessedElement == expectedResults
}

def "A ResultEntityProcessor should throw an EntityProcessorException when it receives an entity result that is not eligible"() {

given:
Expand Down