1515import org .gridsuite .securityanalysis .server .entities .AbstractLimitViolationEntity ;
1616import org .gridsuite .securityanalysis .server .entities .SubjectLimitViolationEntity ;
1717import org .junit .jupiter .api .Test ;
18- import org .springframework .boot .test .context .SpringBootTest ;
1918
2019import static com .powsybl .iidm .network .test .EurostagTutorialExample1Factory .NGEN_NHV1 ;
2120import static com .powsybl .iidm .network .test .EurostagTutorialExample1Factory .NHV1_NHV2_1 ;
2423/**
2524 * @author Caroline Jeandat <caroline.jeandat at rte-france.com>
2625 */
27- @ SpringBootTest
28- abstract class AbstractLimitViolationTest {
26+ abstract class AbstractLimitViolationTest <T extends AbstractLimitViolationEntity > {
2927
3028 @ Test
31- void testAbstractLimitViolationEntityNewFields () {
32- testAbstractLimitViolationMapping ("10'" , 10 * 60 , 1200 , 1 , 1250 , TwoSides .TWO , "1'" , 1100 , 10 * 60 , null );
29+ void testLimitViolationEntityNewFields () {
30+ testLimitViolationMapping ("10'" , 10 * 60 , 1200 , 1 , 1250 , TwoSides .TWO , "1'" , 1100 , 10 * 60 , null );
3331 }
3432
3533 @ Test
36- void testAbstractLimitViolationEntityNewFieldsWithPermanentLimitReached () {
37- testAbstractLimitViolationMapping (LimitViolationUtils .PERMANENT_LIMIT_NAME , Integer .MAX_VALUE , 1100 , 1 , 1150 ,
34+ void testLimitViolationEntityNewFieldsWithPermanentLimitReached () {
35+ testLimitViolationMapping (LimitViolationUtils .PERMANENT_LIMIT_NAME , Integer .MAX_VALUE , 1100 , 1 , 1150 ,
3836 TwoSides .TWO , "10'" , 1100 , Integer .MAX_VALUE , null );
3937 }
4038
4139 @ Test
42- void testAbstractLimitViolationEntityNewFieldsWithPermanentLimitReachedAndNoTemporaryLimit () {
43- testAbstractLimitViolationMapping (LimitViolationUtils .PERMANENT_LIMIT_NAME , Integer .MAX_VALUE , 500 , 1 , 1000 ,
40+ void testLimitViolationEntityNewFieldsWithPermanentLimitReachedAndNoTemporaryLimit () {
41+ testLimitViolationMapping (LimitViolationUtils .PERMANENT_LIMIT_NAME , Integer .MAX_VALUE , 500 , 1 , 1000 ,
4442 TwoSides .ONE , null , 500 , Integer .MAX_VALUE , null );
4543 }
4644
4745 @ Test
48- void testAbstractLimitViolationEntityNewFieldsWithLastLimitReached () {
49- testAbstractLimitViolationMapping ("N/A" , 0 , 1100 , 1 , 3000 , TwoSides .TWO , null , 1100 , 0 , null );
46+ void testLimitViolationEntityNewFieldsWithLastLimitReached () {
47+ testLimitViolationMapping ("N/A" , 0 , 1100 , 1 , 3000 , TwoSides .TWO , null , 1100 , 0 , null );
5048 }
5149
5250 @ Test
53- void testAbstractLimitViolationEntityNewFieldsWithLimitReductionEffective () {
51+ void testLimitViolationEntityNewFieldsWithLimitReductionEffective () {
5452 // for this test to be relevant, "value" needs to be less that "limit"
55- testAbstractLimitViolationMapping ("10'" , 60 , 1200 , 0.8 , 1150 , TwoSides .TWO , "1'" , 1100 , 10 * 60 , 60 );
53+ testLimitViolationMapping ("10'" , 60 , 1200 , 0.8 , 1150 , TwoSides .TWO , "1'" , 1100 , 10 * 60 , 60 );
5654 }
5755
5856 @ Test
59- void test2wtContingencyLimitViolationEntityNewFieldsWithLimitReductionEffective () {
57+ void test2wtLimitViolationEntityNewFieldsWithLimitReductionEffective () {
6058 // for this test to be relevant, "value" needs to be less that "limit"
6159 Network network = EurostagTutorialExample1Factory .createWithFixedCurrentLimits ();
6260 // create limit set for two windings transformer
@@ -96,7 +94,7 @@ void test2wtContingencyLimitViolationEntityNewFieldsWithLimitReductionEffective(
9694 limitViolationEntity .getPatlLoading ());
9795 }
9896
99- private void testAbstractLimitViolationMapping (String limitName , int acceptableDuration , double limit ,
97+ private void testLimitViolationMapping (String limitName , int acceptableDuration , double limit ,
10098 double limitReduction , double value , TwoSides side , String expectedNextLimitName , long expectedPatlLimit ,
10199 Integer expectedAcceptableDuration , Integer expectedUpcomingAcceptableDuration ) {
102100 Network network = EurostagTutorialExample1Factory .createWithFixedCurrentLimits ();
@@ -106,7 +104,7 @@ private void testAbstractLimitViolationMapping(String limitName, int acceptableD
106104 SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity (NHV1_NHV2_1 ,
107105 "NHV1_NHV2_1_name" );
108106
109- AbstractLimitViolationEntity limitViolationEntity = createLimitViolationEntity (network , limitViolation ,
107+ T limitViolationEntity = createLimitViolationEntity (network , limitViolation ,
110108 subjectLimitViolationEntity );
111109
112110 assertEquals (expectedNextLimitName , limitViolationEntity .getNextLimitName ());
@@ -117,6 +115,6 @@ private void testAbstractLimitViolationMapping(String limitName, int acceptableD
117115 limitViolationEntity .getPatlLoading ());
118116 }
119117
120- protected abstract AbstractLimitViolationEntity createLimitViolationEntity (Network network ,
118+ protected abstract T createLimitViolationEntity (Network network ,
121119 LimitViolation limitViolation , SubjectLimitViolationEntity subjectLimitViolationEntity );
122120}
0 commit comments