-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for block and node wrappers & for merged GLSK files import
- Loading branch information
1 parent
5d4900a
commit 7cf275b
Showing
5 changed files
with
410 additions
and
1 deletion.
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
73 changes: 73 additions & 0 deletions
73
glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/BlockWrapperTest.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,73 @@ | ||
/* | ||
* Copyright (c) 2023, 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/. | ||
*/ | ||
package com.powsybl.glsk.cse; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import xsd.etso_core_cmpts.QuantityType; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.util.Optional; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Vincent Bochet {@literal <vincent.bochet at rte-france.com>} | ||
*/ | ||
class BlockWrapperTest { | ||
@Test | ||
void checkGetOrderReturnsValue() { | ||
PropGSKBlockType block = new PropGSKBlockType(); | ||
block.setOrder(BigInteger.TEN); | ||
assertEquals(Optional.of(BigInteger.TEN), new BlockWrapper(block).getOrder()); | ||
} | ||
|
||
@Test | ||
void checkGetOrderReturnsEmptyWhenBlockHasNoOrderAttribute() { | ||
assertEquals(Optional.empty(), new BlockWrapper(new Object()).getOrder()); | ||
} | ||
|
||
@Test | ||
void checkGetMaximumShiftReturnsValue() { | ||
PropGSKBlockType block = new PropGSKBlockType(); | ||
QuantityType quantity = new QuantityType(); | ||
quantity.setV(BigDecimal.TEN); | ||
block.setMaximumShift(quantity); | ||
assertEquals(Optional.of(BigDecimal.TEN), new BlockWrapper(block).getMaximumShift()); | ||
} | ||
|
||
@Test | ||
void checkGetMaximumShiftReturnsEmptyWhenBlockHasNoMaximumShiftAttribute() { | ||
assertEquals(Optional.empty(), new BlockWrapper(new Object()).getMaximumShift()); | ||
} | ||
|
||
@Test | ||
void checkGetFactorReturnsValue() { | ||
PropGSKBlockType block = new PropGSKBlockType(); | ||
QuantityType quantity = new QuantityType(); | ||
quantity.setV(BigDecimal.TEN); | ||
block.setFactor(quantity); | ||
assertEquals(Optional.of(BigDecimal.TEN), new BlockWrapper(block).getFactor()); | ||
} | ||
|
||
@Test | ||
void checkGetFactorReturnsEmptyWhenBlockHasNoFactorAttribute() { | ||
assertEquals(Optional.empty(), new BlockWrapper(new Object()).getFactor()); | ||
} | ||
|
||
@Test | ||
void checkGetNodeListReturnsList() { | ||
PropGSKBlockType block = new PropGSKBlockType(); | ||
block.getNode().add(new PropGSKNodeType()); | ||
assertEquals(1, new BlockWrapper(block).getNodeList().get().size()); | ||
} | ||
|
||
@Test | ||
void checkGetNodeListReturnsEmptyWhenBlockHasNoNodeListAttribute() { | ||
assertEquals(Optional.empty(), new BlockWrapper(new Object()).getNodeList()); | ||
} | ||
} |
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
82 changes: 82 additions & 0 deletions
82
glsk/glsk-document-cse/src/test/java/com/powsybl/glsk/cse/NodeWrapperTest.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,82 @@ | ||
/* | ||
* Copyright (c) 2023, 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/. | ||
*/ | ||
package com.powsybl.glsk.cse; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import xsd.etso_core_cmpts.QuantityType; | ||
|
||
import java.math.BigDecimal; | ||
import java.util.Optional; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Vincent Bochet {@literal <vincent.bochet at rte-france.com>} | ||
*/ | ||
class NodeWrapperTest { | ||
@Test | ||
void checkGetNodeReturnsValue() { | ||
MeritOrderUpNodeType node = new MeritOrderUpNodeType(); | ||
assertEquals(node, new NodeWrapper(node).getNode()); | ||
} | ||
|
||
@Test | ||
void checkGetOrderReturnsValue() { | ||
MeritOrderUpNodeType node = new MeritOrderUpNodeType(); | ||
NodeNameType nodeName = new NodeNameType(); | ||
nodeName.setV("name"); | ||
node.setName(nodeName); | ||
assertEquals(Optional.of("name"), new NodeWrapper(node).getName()); | ||
} | ||
|
||
@Test | ||
void checkGetOrderReturnsEmptyWhenNodeHasNoOrderAttribute() { | ||
assertEquals(Optional.empty(), new NodeWrapper(new Object()).getName()); | ||
} | ||
|
||
@Test | ||
void checkGetFactorReturnsValue() { | ||
ManualGSKNodeType node = new ManualGSKNodeType(); | ||
QuantityType quantity = new QuantityType(); | ||
quantity.setV(BigDecimal.TEN); | ||
node.setFactor(quantity); | ||
assertEquals(Optional.of(BigDecimal.TEN), new NodeWrapper(node).getFactor()); | ||
} | ||
|
||
@Test | ||
void checkGetFactorReturnsEmptyWhenNodeHasNoFactorAttribute() { | ||
assertEquals(Optional.empty(), new NodeWrapper(new Object()).getFactor()); | ||
} | ||
|
||
@Test | ||
void checkGetPmaxReturnsValue() { | ||
MeritOrderUpNodeType node = new MeritOrderUpNodeType(); | ||
QuantityType quantity = new QuantityType(); | ||
quantity.setV(BigDecimal.TEN); | ||
node.setPmax(quantity); | ||
assertEquals(Optional.of(BigDecimal.TEN), new NodeWrapper(node).getPmax()); | ||
} | ||
|
||
@Test | ||
void checkGetPmaxReturnsEmptyWhenNodeHasNoPmaxAttribute() { | ||
assertEquals(Optional.empty(), new NodeWrapper(new Object()).getPmax()); | ||
} | ||
|
||
@Test | ||
void checkGetPminReturnsValue() { | ||
MeritOrderUpNodeType node = new MeritOrderUpNodeType(); | ||
QuantityType quantity = new QuantityType(); | ||
quantity.setV(BigDecimal.TEN); | ||
node.setPmin(quantity); | ||
assertEquals(Optional.of(BigDecimal.TEN), new NodeWrapper(node).getPmin()); | ||
} | ||
|
||
@Test | ||
void checkGetPminReturnsEmptyWhenNodeHasNoPminAttribute() { | ||
assertEquals(Optional.empty(), new NodeWrapper(new Object()).getPmin()); | ||
} | ||
} |
Oops, something went wrong.