-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Binary iidm: distinction between null and empty string (#2871)
Signed-off-by: Florian Dupuy <florian.dupuy@rte-france.com> (cherry picked from commit 8441ed7)
- Loading branch information
Showing
6 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
iidm/iidm-serde/src/test/java/com/powsybl/iidm/serde/BinaryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.iidm.serde; | ||
|
||
import com.powsybl.commons.io.TreeDataFormat; | ||
import com.powsybl.iidm.network.Line; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.iidm.network.TopologyKind; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Florian Dupuy {@literal <florian.dupuy at rte-france.com>} | ||
*/ | ||
class BinaryTest extends AbstractIidmSerDeTest { | ||
|
||
@Test | ||
void testEmptyNullStringAttributes() { | ||
Network n0 = Network.create("test", "test"); | ||
n0.setProperty("property", ""); | ||
n0.newVoltageLevel().setId("vl1").setNominalV(220).setTopologyKind(TopologyKind.NODE_BREAKER).add(); | ||
n0.newVoltageLevel().setId("vl2").setNominalV(220).setTopologyKind(TopologyKind.NODE_BREAKER).add(); | ||
Line l0 = n0.newLine().setId("line").setName("") | ||
.setVoltageLevel1("vl1").setNode1(0) | ||
.setVoltageLevel2("vl2").setNode2(0) | ||
.setR(0.1).setX(10) | ||
.add(); | ||
l0.newCurrentLimits1().add(); | ||
l0.cancelSelectedOperationalLimitsGroup1(); // selected group id is now null on side 1 | ||
l0.newOperationalLimitsGroup2("").newCurrentLimits().add(); | ||
l0.setSelectedOperationalLimitsGroup2(""); // selected group id is now "" on side 2 | ||
|
||
Path binFile = fileSystem.getPath("/work/test"); | ||
NetworkSerDe.write(n0, new ExportOptions().setFormat(TreeDataFormat.BIN), binFile); | ||
Network n1 = NetworkSerDe.read(binFile, new ImportOptions().setFormat(TreeDataFormat.BIN)); | ||
Line s = n1.getLine("line"); | ||
assertEquals("", n1.getProperty("property")); | ||
assertEquals(Optional.of(""), s.getOptionalName()); | ||
assertEquals(Optional.empty(), l0.getSelectedOperationalLimitsGroupId1()); | ||
assertEquals(Optional.of(""), l0.getSelectedOperationalLimitsGroupId2()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
iidm/iidm-serde/src/test/resources/V1_12/eurostag-tutorial1-lf-extensions.bin
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
iidm/iidm-serde/src/test/resources/V1_12/eurostag-tutorial1-lf.bin
Binary file not shown.