This repository has been archived by the owner on May 16, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from itesla/branch_contingency
Refactor LineContingency to BranchContingency.
- Loading branch information
Showing
7 changed files
with
96 additions
and
38 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
contingency-api/src/main/java/eu/itesla_project/contingency/BranchContingency.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) 2017, All partners of the iTesla project (http://www.itesla-project.eu/consortium) | ||
* 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 eu.itesla_project.contingency; | ||
|
||
import eu.itesla_project.contingency.tasks.BranchTripping; | ||
import eu.itesla_project.contingency.tasks.ModificationTask; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com> | ||
* @author Mathieu Bague <mathieu.bague at rte-france.com> | ||
*/ | ||
public class BranchContingency implements ContingencyElement { | ||
|
||
private final String id; | ||
private final String substationId; | ||
|
||
public BranchContingency(String id) { | ||
this(id, null); | ||
} | ||
|
||
public BranchContingency(String id, String substationId) { | ||
this.id = Objects.requireNonNull(id); | ||
this.substationId = substationId; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getSubstationId() { | ||
return substationId; | ||
} | ||
|
||
@Override | ||
public ContingencyElementType getType() { | ||
return ContingencyElementType.BRANCH; | ||
} | ||
|
||
@Override | ||
public ModificationTask toTask() { | ||
return new BranchTripping(id, substationId); | ||
} | ||
|
||
} |
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
33 changes: 33 additions & 0 deletions
33
contingency-api/src/test/java/eu/itesla_project/contingency/BranchContingencyTest.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,33 @@ | ||
/** | ||
* Copyright (c) 2017, 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 eu.itesla_project.contingency; | ||
|
||
import eu.itesla_project.contingency.tasks.BranchTripping; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Mathieu Bague <mathieu.bague at rte-france.com> | ||
*/ | ||
public class BranchContingencyTest { | ||
|
||
@Test | ||
public void test() { | ||
BranchContingency contingency = new BranchContingency("id"); | ||
assertEquals("id", contingency.getId()); | ||
assertNull(contingency.getSubstationId()); | ||
assertEquals(ContingencyElementType.BRANCH, contingency.getType()); | ||
|
||
assertNotNull(contingency.toTask()); | ||
assertTrue(contingency.toTask() instanceof BranchTripping); | ||
|
||
contingency = new BranchContingency("id", "substationId"); | ||
assertEquals("substationId", contingency.getSubstationId()); | ||
} | ||
} |
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
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