Skip to content

check voltageRegulatorOn for battery modification - #214

Merged
EtienneLt merged 3 commits into
mainfrom
check-voltage-regulator-on-for-batteries
Aug 5, 2026
Merged

check voltageRegulatorOn for battery modification#214
EtienneLt merged 3 commits into
mainfrom
check-voltage-regulator-on-for-batteries

Conversation

@EtienneLt

Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt self-assigned this Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ec9eff1-7534-4a42-9229-442bd577521e

📥 Commits

Reviewing files that changed from the base of the PR and between 898c9eb and c078451.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/modification/modifications/BatteryModification.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/gridsuite/modification/modifications/BatteryModification.java

📝 Walkthrough

Walkthrough

Changes

Battery voltage regulation validation

Layer / File(s) Summary
Validate voltage regulator target values
src/main/java/.../BatteryModification.java, src/test/java/.../BatteryModificationTest.java
When voltage regulation is enabled, BatteryModification.check rejects missing, null, or NaN target voltages. Tests cover invalid values from existing battery state and requested modifications.

Suggested reviewers: slimaneamar

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description contains only a template comment and provides no meaningful summary of the changes. Add a brief summary of the new voltage regulation validation and its test coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the battery modification validation change for voltage regulation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/gridsuite/modification/modifications/BatteryModification.java`:
- Line 142: Update the voltage-regulation validation condition in
BatteryModification so a null value from voltageRegulationOn.getValue() cannot
be auto-unboxed; treat only Boolean.TRUE as enabled, while preserving the
existing validation behavior for false or absent values.

In
`@src/test/java/org/gridsuite/modification/modifications/BatteryModificationTest.java`:
- Around line 97-119: Extend BatteryModificationTest beside the existing NaN
targetV cases with a test using targetV(new AttributeModification<>(null,
OperationType.SET)) while voltageRegulationOn is enabled. Invoke check through
the resulting BatteryModification, assert NetworkModificationException, and
verify the expected null target-voltage validation message.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 419fd7e3-dd6d-4252-86ec-c9ee42f62ab6

📥 Commits

Reviewing files that changed from the base of the PR and between 8552816 and 898c9eb.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/modification/modifications/BatteryModification.java
  • src/test/java/org/gridsuite/modification/modifications/BatteryModificationTest.java

Comment on lines +97 to +119
// check if battery has NaN targetV then it throws an error if voltageRegulator is set to On
VoltageRegulation voltageRegulation = network.getBattery("v3Battery").getExtension(VoltageRegulation.class);
voltageRegulation.setTargetV(Double.NaN);
BatteryModificationInfos batteryModificationInfos6 = BatteryModificationInfos.builder()
.equipmentId("v3Battery")
.voltageRegulationOn(new AttributeModification<>(true, OperationType.SET))
.build();
BatteryModification generatorModification6 = (BatteryModification) batteryModificationInfos6.toModification();
message = assertThrows(NetworkModificationException.class,
() -> generatorModification6.check(network)).getMessage();
assertEquals("MODIFY_BATTERY_ERROR : 'v3Battery': voltage setpoint value (NaN) is invalid (voltage regulator is on)", message);

// check if battery targetV is set to NaN then it throws an error if voltageRegulator is set to On
voltageRegulation.setTargetV(400.0);
BatteryModificationInfos batteryModificationInfos7 = BatteryModificationInfos.builder()
.equipmentId("v3Battery")
.targetV(new AttributeModification<>(Double.NaN, OperationType.SET))
.voltageRegulationOn(new AttributeModification<>(true, OperationType.SET))
.build();
BatteryModification generatorModification7 = (BatteryModification) batteryModificationInfos7.toModification();
message = assertThrows(NetworkModificationException.class,
() -> generatorModification7.check(network)).getMessage();
assertEquals("MODIFY_BATTERY_ERROR : 'v3Battery': voltage setpoint value (NaN) is invalid (voltage regulator is on)", message);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add coverage for a null requested target voltage.

The tests cover NaN, but they do not cover targetV with a null value. Add a case with targetV(new AttributeModification<>(null, OperationType.SET)) and enabled voltage regulation. This verifies the null-validation branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/test/java/org/gridsuite/modification/modifications/BatteryModificationTest.java`
around lines 97 - 119, Extend BatteryModificationTest beside the existing NaN
targetV cases with a test using targetV(new AttributeModification<>(null,
OperationType.SET)) while voltageRegulationOn is enabled. Invoke check through
the resulting BatteryModification, assert NetworkModificationException, and
verify the expected null target-voltage validation message.

@EtienneLt EtienneLt changed the title check voltage regulator on for battery modification check voltageRegulatorOn for battery modification Aug 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@EtienneLt
EtienneLt merged commit 1e835ff into main Aug 5, 2026
5 checks passed
@EtienneLt
EtienneLt deleted the check-voltage-regulator-on-for-batteries branch August 5, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants