|
| 1 | +/** |
| 2 | + * Copyright (c) 2023, RTE (http://www.rte-france.com) |
| 3 | + * This Source Code Form is subject to the terms of the Mozilla Public |
| 4 | + * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 | + * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | + */ |
| 7 | +package org.gridsuite.securityanalysis.server; |
| 8 | + |
| 9 | +import com.powsybl.iidm.network.Network; |
| 10 | +import com.powsybl.iidm.network.TwoSides; |
| 11 | +import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; |
| 12 | +import com.powsybl.iidm.network.util.LimitViolationUtils; |
| 13 | +import com.powsybl.security.LimitViolation; |
| 14 | +import com.powsybl.security.LimitViolationBuilder; |
| 15 | +import com.powsybl.security.LimitViolationType; |
| 16 | +import org.gridsuite.securityanalysis.server.entities.ContingencyLimitViolationEntity; |
| 17 | +import org.gridsuite.securityanalysis.server.entities.SubjectLimitViolationEntity; |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | +import org.springframework.boot.test.context.SpringBootTest; |
| 20 | + |
| 21 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 22 | + |
| 23 | +/** |
| 24 | + * @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com> |
| 25 | + */ |
| 26 | +@SpringBootTest |
| 27 | +class ContingencyLimitViolationTest { |
| 28 | + |
| 29 | + @Test |
| 30 | + void testContingencyLimitViolationEntityNewFields() { |
| 31 | + Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits(); |
| 32 | + LimitViolation limitViolation = new LimitViolation("NHV1_NHV2_1", "NHV1_NHV2_1", LimitViolationType.CURRENT, "10'", 10 * 60, 1200, 1, 1250, TwoSides.TWO); |
| 33 | + |
| 34 | + SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity("NHV1_NHV2_1", "NHV1_NHV2_1_name"); |
| 35 | + |
| 36 | + ContingencyLimitViolationEntity contingencyLimitViolationEntity = ContingencyLimitViolationEntity.toEntity(network, limitViolation, subjectLimitViolationEntity); |
| 37 | + |
| 38 | + assertEquals("1'", contingencyLimitViolationEntity.getNextLimitName()); |
| 39 | + assertEquals(1100, contingencyLimitViolationEntity.getPatlLimit()); |
| 40 | + assertEquals(100 * limitViolation.getValue() / contingencyLimitViolationEntity.getPatlLimit(), contingencyLimitViolationEntity.getPatlLoading()); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + void testContingencyLimitViolationEntityNewFieldsWithPermanentLimitReached() { |
| 45 | + Network network = EurostagTutorialExample1Factory.createWithFixedCurrentLimits(); |
| 46 | + LimitViolation limitViolation = new LimitViolation("NHV1_NHV2_1", "NHV1_NHV2_1", LimitViolationType.CURRENT, LimitViolationUtils.PERMANENT_LIMIT_NAME, 10 * 60, 1100, 1, 1150, TwoSides.TWO); |
| 47 | + |
| 48 | + SubjectLimitViolationEntity subjectLimitViolationEntity = new SubjectLimitViolationEntity("NHV1_NHV2_1", "NHV1_NHV2_1_name"); |
| 49 | + |
| 50 | + ContingencyLimitViolationEntity contingencyLimitViolationEntity = ContingencyLimitViolationEntity.toEntity(network, limitViolation, subjectLimitViolationEntity); |
| 51 | + |
| 52 | + assertEquals("10'", contingencyLimitViolationEntity.getNextLimitName()); |
| 53 | + assertEquals(1100, contingencyLimitViolationEntity.getPatlLimit()); |
| 54 | + assertEquals(100 * limitViolation.getValue() / contingencyLimitViolationEntity.getPatlLimit(), contingencyLimitViolationEntity.getPatlLoading()); |
| 55 | + } |
| 56 | +} |
0 commit comments