Skip to content

Commit

Permalink
unit test for getters with default values
Browse files Browse the repository at this point in the history
Signed-off-by: vmouradian <[email protected]>
  • Loading branch information
vmouradian committed Jan 16, 2025
1 parent 92c6ffc commit aefec28
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.powsybl.contingency.Contingency;
import com.powsybl.contingency.json.ContingencyJsonModule;
import com.powsybl.loadflow.LoadFlowParameters;
import com.powsybl.openloadflow.OpenLoadFlowParameters;
import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand Down Expand Up @@ -45,12 +46,25 @@ void testContingencyLoadFlowParametersExtension() {
ContingencyLoadFlowParameters extension = contingency.getExtension(ContingencyLoadFlowParameters.class);
assertEquals(extension, contingency.getExtensionByName("contingency-load-flow-parameters"));

// test base getters
assertFalse(extension.isDistributedSlack().isPresent());
assertTrue(extension.isAreaInterchangeControl().isPresent());
assertTrue(extension.getBalanceType().isPresent());

assertTrue(extension.isAreaInterchangeControl().get());
assertEquals(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD, extension.getBalanceType().get());

// test getters with default values
LoadFlowParameters loadFlowParameters = new LoadFlowParameters()
.setDistributedSlack(true)
.setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_GENERATION_REMAINING_MARGIN);

OpenLoadFlowParameters openLoadFlowParameters = OpenLoadFlowParameters.create(loadFlowParameters)
.setAreaInterchangeControl(false);

assertTrue(extension.isDistributedSlack(loadFlowParameters));
assertTrue(extension.isAreaInterchangeControl(openLoadFlowParameters));
assertEquals(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD, extension.getBalanceType(loadFlowParameters));
}

@Test
Expand Down

0 comments on commit aefec28

Please sign in to comment.