diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java index a5219e036..6bc79aac0 100644 --- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/BranchCreationEntity.java @@ -13,6 +13,10 @@ import org.gridsuite.modification.dto.ModificationInfos; import jakarta.persistence.*; +import org.gridsuite.modification.dto.OperationalLimitsGroupInfos; + +import java.util.ArrayList; +import java.util.List; /** * @author Sylvain Bouzols @@ -64,21 +68,25 @@ public class BranchCreationEntity extends EquipmentCreationEntity { @Column(name = "connected2", columnDefinition = "boolean default true") private boolean connected2; - @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) - @JoinColumn(name = "current_limits_id1", - referencedColumnName = "id", - foreignKey = @ForeignKey( - name = "current_limits_id1_fk" - ), nullable = true) - private CurrentLimitsEntity currentLimits1; - - @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) - @JoinColumn(name = "current_limits_id2", - referencedColumnName = "id", - foreignKey = @ForeignKey( - name = "current_limits_id2_fk" - ), nullable = true) - private CurrentLimitsEntity currentLimits2; + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinTable( + joinColumns = @JoinColumn(name = "branch_id"), foreignKey = @ForeignKey(name = "branch_id_fk"), + inverseJoinColumns = @JoinColumn(name = "operational_limits_groups_id"), inverseForeignKey = @ForeignKey(name = "operational_limits_groups_id1_fk")) + @OrderColumn(name = "pos_operationalLimitsGroups") + private List operationalLimitsGroups1; + + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinTable( + joinColumns = @JoinColumn(name = "branch_id"), foreignKey = @ForeignKey(name = "branch_id_fk"), + inverseJoinColumns = @JoinColumn(name = "operational_limits_groups_id"), inverseForeignKey = @ForeignKey(name = "operational_limits_groups_id2_fk")) + @OrderColumn(name = "pos_operationalLimitsGroups") + private List operationalLimitsGroups2; + + @Column(name = "selectedOperationalLimitsGroupId1") + private String selectedOperationalLimitsGroupId1; + + @Column(name = "selectedOperationalLimitsGroupId2") + private String selectedOperationalLimitsGroupId2; protected BranchCreationEntity(BranchCreationInfos branchCreationInfos) { super(branchCreationInfos); @@ -99,23 +107,37 @@ private void assignAttributes(BranchCreationInfos branchCreationInfos) { voltageLevelId2 = branchCreationInfos.getVoltageLevelId2(); busOrBusbarSectionId1 = branchCreationInfos.getBusOrBusbarSectionId1(); busOrBusbarSectionId2 = branchCreationInfos.getBusOrBusbarSectionId2(); - if (branchCreationInfos.getCurrentLimits1() != null) { - currentLimits1 = new CurrentLimitsEntity(branchCreationInfos.getCurrentLimits1()); - } else { - currentLimits1 = null; - } - if (branchCreationInfos.getCurrentLimits2() != null) { - currentLimits2 = new CurrentLimitsEntity(branchCreationInfos.getCurrentLimits2()); - } else { - currentLimits2 = null; - } + operationalLimitsGroups1 = assignOperationalLimitsGroups(branchCreationInfos.getOperationalLimitsGroups1(), operationalLimitsGroups1); + operationalLimitsGroups2 = assignOperationalLimitsGroups(branchCreationInfos.getOperationalLimitsGroups2(), operationalLimitsGroups2); connectionDirection1 = branchCreationInfos.getConnectionDirection1(); connectionName1 = branchCreationInfos.getConnectionName1(); connectionDirection2 = branchCreationInfos.getConnectionDirection2(); connectionName2 = branchCreationInfos.getConnectionName2(); + selectedOperationalLimitsGroupId1 = branchCreationInfos.getSelectedOperationalLimitsGroup1(); + selectedOperationalLimitsGroupId2 = branchCreationInfos.getSelectedOperationalLimitsGroup2(); connectionPosition1 = branchCreationInfos.getConnectionPosition1(); connectionPosition2 = branchCreationInfos.getConnectionPosition2(); connected1 = branchCreationInfos.isConnected1(); connected2 = branchCreationInfos.isConnected2(); } + + /** + * the point of this function is to avoid dereferencing operationalLimitsGroups if it already exists, + * in order to prevent Hibernate from losing the reference during cascade cleaning + */ + private List assignOperationalLimitsGroups( + List operationalLimitsGroupInfos, + List operationalLimitsGroups + ) { + List updatedLimitsGroups = operationalLimitsGroups; + if (operationalLimitsGroups == null) { + updatedLimitsGroups = new ArrayList<>(); + } else { + updatedLimitsGroups.clear(); + } + if (operationalLimitsGroupInfos != null) { + updatedLimitsGroups.addAll(OperationalLimitsGroupEntity.toOperationalLimitsGroupsEntities(operationalLimitsGroupInfos)); + } + return updatedLimitsGroups; + } } diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java index 6680471ba..c0abdf2be 100644 --- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/LineCreationEntity.java @@ -79,6 +79,8 @@ public LineCreationInfos toModificationInfos() { .busOrBusbarSectionId2(getBusOrBusbarSectionId2()) .connectionName1(getConnectionName1()) .connectionName2(getConnectionName2()) + .selectedOperationalLimitsGroup1(getSelectedOperationalLimitsGroupId1()) + .selectedOperationalLimitsGroup2(getSelectedOperationalLimitsGroupId2()) .connectionDirection1(getConnectionDirection1()) .connectionDirection2(getConnectionDirection2()) .connectionPosition1(getConnectionPosition1()) @@ -94,14 +96,10 @@ public LineCreationInfos toModificationInfos() { .properties(CollectionUtils.isEmpty(getProperties()) ? null : getProperties().stream() .map(FreePropertyEntity::toInfos) - .toList()); + .toList()) + .operationalLimitsGroups1(OperationalLimitsGroupEntity.fromOperationalLimitsGroupsEntities(getOperationalLimitsGroups1())) + .operationalLimitsGroups2(OperationalLimitsGroupEntity.fromOperationalLimitsGroupsEntities(getOperationalLimitsGroups2())); - if (getCurrentLimits1() != null) { - builder.currentLimits1(getCurrentLimits1().toCurrentLimitsInfos()); - } - if (getCurrentLimits2() != null) { - builder.currentLimits2(getCurrentLimits2().toCurrentLimitsInfos()); - } return builder; } diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/OperationalLimitsGroupEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/OperationalLimitsGroupEntity.java new file mode 100644 index 000000000..8e4fb7e84 --- /dev/null +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/OperationalLimitsGroupEntity.java @@ -0,0 +1,69 @@ +/* + Copyright (c) 2024, 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 org.gridsuite.modification.server.entities.equipment.creation; + +import jakarta.persistence.*; +import lombok.*; +import org.gridsuite.modification.dto.OperationalLimitsGroupInfos; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author Mathieu Deharbe + */ +@Getter +@NoArgsConstructor +@AllArgsConstructor +@Entity +@Table(name = "operational_limits_group") +public class OperationalLimitsGroupEntity { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "uuid") + private UUID uuid; + + @Column(name = "id") + private String id; + + @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) + @JoinColumn(name = "current_limits_id", + referencedColumnName = "id", + foreignKey = @ForeignKey( + name = "current_limits_id_fk" + )) + private CurrentLimitsEntity currentLimits; + + public static List toOperationalLimitsGroupsEntities(@NonNull List limitsGroups) { + return limitsGroups.stream() + .filter(Objects::nonNull) + .map(limitsGroup -> + new OperationalLimitsGroupEntity( + null, + limitsGroup.getId(), + new CurrentLimitsEntity(limitsGroup.getCurrentLimits()) + ) + ) + .toList(); + } + + public static List fromOperationalLimitsGroupsEntities(List limitsGroupsEntities) { + return CollectionUtils.isEmpty(limitsGroupsEntities) ? null : + limitsGroupsEntities.stream() + .map(limitsGroupEntity -> + OperationalLimitsGroupInfos.builder() + .id(limitsGroupEntity.getId()) + .currentLimits(limitsGroupEntity.getCurrentLimits().toCurrentLimitsInfos()) + .build() + ) + .collect(Collectors.toList()); + } +} diff --git a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java index 92e14bc60..395b93c2f 100644 --- a/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java +++ b/src/main/java/org/gridsuite/modification/server/entities/equipment/creation/TwoWindingsTransformerCreationEntity.java @@ -192,6 +192,8 @@ public TwoWindingsTransformerCreationInfos toModificationInfos() { .busOrBusbarSectionId2(getBusOrBusbarSectionId2()) .connectionName1(getConnectionName1()) .connectionName2(getConnectionName2()) + .selectedOperationalLimitsGroup1(getSelectedOperationalLimitsGroupId1()) + .selectedOperationalLimitsGroup2(getSelectedOperationalLimitsGroupId2()) .connectionDirection1(getConnectionDirection1()) .connectionDirection2(getConnectionDirection2()) .connectionPosition1(getConnectionPosition1()) @@ -208,14 +210,9 @@ public TwoWindingsTransformerCreationInfos toModificationInfos() { .properties(CollectionUtils.isEmpty(getProperties()) ? null : getProperties().stream() .map(FreePropertyEntity::toInfos) - .toList()); - - if (getCurrentLimits1() != null) { - builder.currentLimits1(getCurrentLimits1().toCurrentLimitsInfos()); - } - if (getCurrentLimits2() != null) { - builder.currentLimits2(getCurrentLimits2().toCurrentLimitsInfos()); - } + .toList()) + .operationalLimitsGroups1(OperationalLimitsGroupEntity.fromOperationalLimitsGroupsEntities(getOperationalLimitsGroups1())) + .operationalLimitsGroups2(OperationalLimitsGroupEntity.fromOperationalLimitsGroupsEntities(getOperationalLimitsGroups2())); if (!ratioTapChangerSteps.isEmpty()) { List ratioTapChangerStepCreationInfos = ratioTapChangerSteps.stream().map(TapChangerStepCreationEmbeddable::toModificationInfos).collect(Collectors.toList()); diff --git a/src/main/resources/db/changelog/changesets/changelog_20250116T103740Z.xml b/src/main/resources/db/changelog/changesets/changelog_20250116T103740Z.xml new file mode 100644 index 000000000..aee7025b2 --- /dev/null +++ b/src/main/resources/db/changelog/changesets/changelog_20250116T103740Z.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/db/changelog/changesets/migrationCurrentLimits_20250115T135946Z.sql b/src/main/resources/db/changelog/changesets/migrationCurrentLimits_20250115T135946Z.sql new file mode 100644 index 000000000..ae652d30d --- /dev/null +++ b/src/main/resources/db/changelog/changesets/migrationCurrentLimits_20250115T135946Z.sql @@ -0,0 +1,68 @@ +-- updates limits creations in line_creation on both sides +insert into operational_limits_group (uuid, id, current_limits_id) +select + random_uuid(), + 'DEFAULT', + current_limits_id1 +from line_creation; +insert into line_creation_operational_limits_groups1 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + line_creation.id, + operational_limits_group.uuid, + 0 +from line_creation, operational_limits_group +where line_creation.current_limits_id1 = operational_limits_group.current_limits_id; + +insert into operational_limits_group (uuid, id, current_limits_id) +select + random_uuid(), + 'DEFAULT', + current_limits_id2 +from line_creation; +insert into line_creation_operational_limits_groups2 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + line_creation.id, + operational_limits_group.uuid, + 0 +from line_creation, operational_limits_group +where line_creation.current_limits_id2 = operational_limits_group.current_limits_id; + +-- updates limits creations in two_windings_transformer_creation on both sides +insert into operational_limits_group (uuid, id, current_limits_id) +select + random_uuid(), + 'DEFAULT', + current_limits_id1 +from two_windings_transformer_creation; +insert into two_windings_transformer_creation_operational_limits_groups1 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + two_windings_transformer_creation.id, + operational_limits_group.uuid, + 0 +from two_windings_transformer_creation, operational_limits_group +where two_windings_transformer_creation.current_limits_id1 = operational_limits_group.current_limits_id; + +insert into operational_limits_group (uuid, id, current_limits_id) +select + random_uuid(), + 'DEFAULT', + current_limits_id2 +from two_windings_transformer_creation; +insert into two_windings_transformer_creation_operational_limits_groups2 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + two_windings_transformer_creation.id, + operational_limits_group.uuid, + 0 +from two_windings_transformer_creation, operational_limits_group +where two_windings_transformer_creation.current_limits_id2 = operational_limits_group.current_limits_id; + +-- set the previously created operational limits group as selected in line_creation and two_windings_transformer_creation +UPDATE line_creation +SET + selected_operational_limits_group_id1 = 'DEFAULT', + selected_operational_limits_group_id2 = 'DEFAULT'; + +UPDATE two_windings_transformer_creation +SET + selected_operational_limits_group_id1 = 'DEFAULT', + selected_operational_limits_group_id2 = 'DEFAULT'; \ No newline at end of file diff --git a/src/main/resources/db/changelog/changesets/migrationCurrentLimits_pg_20250115T135946Z.sql b/src/main/resources/db/changelog/changesets/migrationCurrentLimits_pg_20250115T135946Z.sql new file mode 100644 index 000000000..fe70d174b --- /dev/null +++ b/src/main/resources/db/changelog/changesets/migrationCurrentLimits_pg_20250115T135946Z.sql @@ -0,0 +1,68 @@ +-- updates limits creations in line_creation on both sides +insert into operational_limits_group (uuid, id, current_limits_id) +select + gen_random_uuid(), + 'DEFAULT', + current_limits_id1 +from line_creation; +insert into line_creation_operational_limits_groups1 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + line_creation.id, + operational_limits_group.uuid, + 0 +from line_creation, operational_limits_group +where line_creation.current_limits_id1 = operational_limits_group.current_limits_id; + +insert into operational_limits_group (uuid, id, current_limits_id) +select + gen_random_uuid(), + 'DEFAULT', + current_limits_id2 +from line_creation; +insert into line_creation_operational_limits_groups2 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + line_creation.id, + operational_limits_group.uuid, + 0 +from line_creation, operational_limits_group +where line_creation.current_limits_id2 = operational_limits_group.current_limits_id; + +-- updates limits creations in two_windings_transformer_creation on both sides +insert into operational_limits_group (uuid, id, current_limits_id) +select + gen_random_uuid(), + 'DEFAULT', + current_limits_id1 +from two_windings_transformer_creation; +insert into two_windings_transformer_creation_operational_limits_groups1 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + two_windings_transformer_creation.id, + operational_limits_group.uuid, + 0 +from two_windings_transformer_creation, operational_limits_group +where two_windings_transformer_creation.current_limits_id1 = operational_limits_group.current_limits_id; + +insert into operational_limits_group (uuid, id, current_limits_id) +select + gen_random_uuid(), + 'DEFAULT', + current_limits_id2 +from two_windings_transformer_creation; +insert into two_windings_transformer_creation_operational_limits_groups2 (branch_id, operational_limits_groups_id, pos_operational_limits_groups) +select + two_windings_transformer_creation.id, + operational_limits_group.uuid, + 0 +from two_windings_transformer_creation, operational_limits_group +where two_windings_transformer_creation.current_limits_id2 = operational_limits_group.current_limits_id; + +-- set the previously created operational limits group as selected in line_creation and two_windings_transformer_creation +UPDATE line_creation +SET + selected_operational_limits_group_id1 = 'DEFAULT', + selected_operational_limits_group_id2 = 'DEFAULT'; + +UPDATE two_windings_transformer_creation +SET + selected_operational_limits_group_id1 = 'DEFAULT', + selected_operational_limits_group_id2 = 'DEFAULT'; \ No newline at end of file diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index 67f4f50e2..92e1f0486 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -332,4 +332,7 @@ databaseChangeLog: relativeToChangelogFile: true - include: file: changesets/changelog_20241204T222759Z.xml - relativeToChangelogFile: true \ No newline at end of file + relativeToChangelogFile: true + - include: + file: changesets/changelog_20250116T103740Z.xml + relativeToChangelogFile: true diff --git a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java index 46f00237f..05c4b229e 100644 --- a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java +++ b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java @@ -870,8 +870,16 @@ void testDuplicateModificationGroup() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .currentLimits1(c1) - .currentLimits2(c2) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits(c1).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits(c2).build() + ) + ) .build(); mvcResult = mockMvc.perform( diff --git a/src/test/java/org/gridsuite/modification/server/modifications/AbstractNetworkModificationTest.java b/src/test/java/org/gridsuite/modification/server/modifications/AbstractNetworkModificationTest.java index 1aa6a16f1..baacf0f77 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/AbstractNetworkModificationTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/AbstractNetworkModificationTest.java @@ -205,6 +205,7 @@ public void testUpdate() throws Exception { String modificationToUpdateJson = mapper.writeValueAsString(modificationToUpdate); + // TODO : ce TU foire et permet de tester mon problème de jpa, donc à prendre en référence mockMvc.perform(put(URI_NETWORK_MODIF_GET_PUT + modificationUuid).content(modificationToUpdateJson).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()); diff --git a/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java b/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java index cc915f5f7..7ec7155ae 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInBusBreakerTest.java @@ -9,10 +9,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.powsybl.iidm.network.Network; import org.gridsuite.modification.NetworkModificationException; -import org.gridsuite.modification.dto.CurrentLimitsInfos; -import org.gridsuite.modification.dto.FreePropertyInfos; -import org.gridsuite.modification.dto.LineCreationInfos; -import org.gridsuite.modification.dto.ModificationInfos; +import org.gridsuite.modification.dto.*; import org.gridsuite.modification.server.utils.NetworkCreation; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -112,7 +109,16 @@ void testCreateLineOptionalParameters3() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(1.0).temporaryLimits(Collections.emptyList()).build()) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder() + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(1.0).temporaryLimits(Collections.emptyList()).build() + ) + .id("limitSet1") + .build() + ) + ) .build(); String lineCreationInfosPermanentLimitOKJson = mapper.writeValueAsString(lineCreationInfosPermanentLimitOK); @@ -137,15 +143,21 @@ void testCreateLineOptionalParameters4() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build()) - .currentLimits2(null) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build() + ).build() + ) + ) + .operationalLimitsGroups2(null) .build(); String lineCreationInfosPermanentLimitOKJson = mapper.writeValueAsString(lineCreationInfosPermanentLimitOK); mockMvc.perform(post(getNetworkModificationUri()).content(lineCreationInfosPermanentLimitOKJson).contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andReturn(); - lineCreationInfosPermanentLimitOK.setCurrentLimits2(null); // if permanentLimit is null then no currentLimit created + lineCreationInfosPermanentLimitOK.setOperationalLimitsGroups2(null); // if permanentLimit is null then no currentLimit created LineCreationInfos createdModification = (LineCreationInfos) modificationRepository.getModifications(getGroupId(), false, true).get(0); assertThat(createdModification).recursivelyEquals(lineCreationInfosPermanentLimitOK); @@ -164,7 +176,14 @@ void testCreateLineOptionalParameters5() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(-1.0).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder() + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(-1.0).build()) + .build() + ) + ) .build(); String lineCreationInfosPermanentLimitNOKJson = mapper.writeValueAsString(lineCreationInfosPermanentLimitNOK); mockMvc.perform(post(getNetworkModificationUri()).content(lineCreationInfosPermanentLimitNOKJson).contentType(MediaType.APPLICATION_JSON)) @@ -184,7 +203,13 @@ void testCreateLineOptionalParameters6() throws Exception { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(1.0).build()) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(1.0).build()) + .build() + ) + ) .build(); String lineCreationInfosJson = mapper.writeValueAsString(lineCreationInfosOK); @@ -214,8 +239,20 @@ protected ModificationInfos buildModification() { .b2(20.0) .voltageLevelId1("v1") .busOrBusbarSectionId1("bus1") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + .build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + .build() + ) + ) .voltageLevelId2("v2") .busOrBusbarSectionId2("bus2") .properties(List.of(FreePropertyInfos.builder().name(PROPERTY_NAME).value(PROPERTY_VALUE).build())) diff --git a/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java index 267704139..30a9a72bc 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/LineCreationInNodeBreakerTest.java @@ -112,8 +112,20 @@ void testCreateLineWithOnlyPermanentCurrentLimits() throws Exception { .busOrBusbarSectionId1("1A") .voltageLevelId2("v1") .busOrBusbarSectionId2("1.1") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(5.).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(6.).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.).build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(6.).build() + ).build() + ) + ) .connectionName1("cn1LineEdited") .connectionDirection1(ConnectablePosition.Direction.BOTTOM) .connectionName2("cn2LineEdited") @@ -127,10 +139,10 @@ void testCreateLineWithOnlyPermanentCurrentLimits() throws Exception { .andExpect(status().isOk()).andReturn(); LineCreationInfos createdModification = (LineCreationInfos) modificationRepository.getModifications(getGroupId(), false, true).get(0); - assertEquals(5., createdModification.getCurrentLimits1().getPermanentLimit(), 0.); - assertEquals(6., createdModification.getCurrentLimits2().getPermanentLimit(), 0.); - assertTrue(createdModification.getCurrentLimits1().getTemporaryLimits().isEmpty()); - assertTrue(createdModification.getCurrentLimits2().getTemporaryLimits().isEmpty()); + assertEquals(5., createdModification.getOperationalLimitsGroups1().get(0).getCurrentLimits().getPermanentLimit(), 0.); + assertEquals(6., createdModification.getOperationalLimitsGroups2().get(0).getCurrentLimits().getPermanentLimit(), 0.); + assertTrue(createdModification.getOperationalLimitsGroups1().get(0).getCurrentLimits().getTemporaryLimits().isEmpty()); + assertTrue(createdModification.getOperationalLimitsGroups2().get(0).getCurrentLimits().getTemporaryLimits().isEmpty()); testNetworkModificationsCount(getGroupId(), 1); } @@ -150,14 +162,26 @@ void testCreateLineWithOnlyTemporaryCurrentLimits() throws Exception { .busOrBusbarSectionId1("1A") .voltageLevelId2("v1") .busOrBusbarSectionId2("1.1") - .currentLimits1(CurrentLimitsInfos.builder() - .temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").value(200.0).acceptableDuration(600).build())) - .build()) - .currentLimits2(CurrentLimitsInfos.builder() - .temporaryLimits(List.of( - CurrentTemporaryLimitCreationInfos.builder().name("IT10").value(200.0).acceptableDuration(600).build(), - CurrentTemporaryLimitCreationInfos.builder().name("IT20").value(100.0).acceptableDuration(1200).build())) - .build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder() + .temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").value(200.0).acceptableDuration(600).build())) + .build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder() + .temporaryLimits(List.of( + CurrentTemporaryLimitCreationInfos.builder().name("IT10").value(200.0).acceptableDuration(600).build(), + CurrentTemporaryLimitCreationInfos.builder().name("IT20").value(100.0).acceptableDuration(1200).build())) + .build() + ).build() + ) + ) .connectionName1("cn1LineEdited") .connectionDirection1(ConnectablePosition.Direction.BOTTOM) .connectionName2("cn2LineEdited") @@ -171,10 +195,10 @@ void testCreateLineWithOnlyTemporaryCurrentLimits() throws Exception { .andExpect(status().isOk()).andReturn(); LineCreationInfos createdModification = (LineCreationInfos) modificationRepository.getModifications(getGroupId(), false, true).get(0); - assertNull(createdModification.getCurrentLimits1().getPermanentLimit()); - assertNull(createdModification.getCurrentLimits2().getPermanentLimit()); - assertEquals(1, createdModification.getCurrentLimits1().getTemporaryLimits().size()); - assertEquals(2, createdModification.getCurrentLimits2().getTemporaryLimits().size()); + assertNull(createdModification.getOperationalLimitsGroups1().get(0).getCurrentLimits().getPermanentLimit()); + assertNull(createdModification.getOperationalLimitsGroups2().get(0).getCurrentLimits().getPermanentLimit()); + assertEquals(1, createdModification.getOperationalLimitsGroups1().get(0).getCurrentLimits().getTemporaryLimits().size()); + assertEquals(2, createdModification.getOperationalLimitsGroups2().get(0).getCurrentLimits().getTemporaryLimits().size()); testNetworkModificationsCount(getGroupId(), 1); } @@ -194,14 +218,26 @@ void testCreateLineWithBothCurrentLimits() throws Exception { .busOrBusbarSectionId1("1A") .voltageLevelId2("v1") .busOrBusbarSectionId2("1.1") - .currentLimits1(CurrentLimitsInfos.builder() - .permanentLimit(200.) - .temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").value(200.0).acceptableDuration(600).build())) - .build()) - .currentLimits2(CurrentLimitsInfos.builder() - .permanentLimit(100.) - .temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT20").value(600.0).acceptableDuration(1200).build())) - .build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder() + .permanentLimit(200.) + .temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").value(200.0).acceptableDuration(600).build())) + .build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder() + .permanentLimit(100.) + .temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT20").value(600.0).acceptableDuration(1200).build())) + .build() + ).build() + ) + ) .connectionName1("cn1LineEdited") .connectionDirection1(ConnectablePosition.Direction.BOTTOM) .connectionName2("cn2LineEdited") @@ -217,15 +253,15 @@ void testCreateLineWithBothCurrentLimits() throws Exception { .andExpect(status().isOk()).andReturn(); LineCreationInfos createdModification = (LineCreationInfos) modificationRepository.getModifications(getGroupId(), false, true).get(0); - assertEquals(200., createdModification.getCurrentLimits1().getPermanentLimit(), 0.); - assertEquals(100., createdModification.getCurrentLimits2().getPermanentLimit(), 0.); - assertEquals(1, createdModification.getCurrentLimits1().getTemporaryLimits().size()); - assertEquals(1, createdModification.getCurrentLimits2().getTemporaryLimits().size()); + assertEquals(200., createdModification.getOperationalLimitsGroups1().get(0).getCurrentLimits().getPermanentLimit(), 0.); + assertEquals(100., createdModification.getOperationalLimitsGroups2().get(0).getCurrentLimits().getPermanentLimit(), 0.); + assertEquals(1, createdModification.getOperationalLimitsGroups1().get(0).getCurrentLimits().getTemporaryLimits().size()); + assertEquals(1, createdModification.getOperationalLimitsGroups2().get(0).getCurrentLimits().getTemporaryLimits().size()); testNetworkModificationsCount(getGroupId(), 1); assertEquals( - "LineCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=LINE_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=idLineEdited, properties=null), equipmentName=nameLineEdited), r=110.0, x=110.0, voltageLevelId1=v2, voltageLevelId2=v1, busOrBusbarSectionId1=1A, busOrBusbarSectionId2=1.1, currentLimits1=CurrentLimitsInfos(permanentLimit=200.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT10, value=200.0, acceptableDuration=600)]), currentLimits2=CurrentLimitsInfos(permanentLimit=100.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT20, value=600.0, acceptableDuration=1200)]), connectionName1=cn1LineEdited, connectionDirection1=BOTTOM, connectionName2=cn2LineEdited, connectionDirection2=TOP, connectionPosition1=0, connectionPosition2=0, connected1=true, connected2=false), g1=15.0, b1=15.0, g2=25.0, b2=25.0)", + "LineCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=LINE_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=idLineEdited, properties=null), equipmentName=nameLineEdited), r=110.0, x=110.0, voltageLevelId1=v2, voltageLevelId2=v1, busOrBusbarSectionId1=1A, busOrBusbarSectionId2=1.1, operationalLimitsGroups1=[OperationalLimitsGroupInfos(id=null, currentLimits=CurrentLimitsInfos(permanentLimit=200.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT10, value=200.0, acceptableDuration=600)]))], operationalLimitsGroups2=[OperationalLimitsGroupInfos(id=null, currentLimits=CurrentLimitsInfos(permanentLimit=100.0, temporaryLimits=[CurrentTemporaryLimitCreationInfos(name=IT20, value=600.0, acceptableDuration=1200)]))], selectedOperationalLimitsGroup1=null, selectedOperationalLimitsGroup2=null, connectionName1=cn1LineEdited, connectionDirection1=BOTTOM, connectionName2=cn2LineEdited, connectionDirection2=TOP, connectionPosition1=0, connectionPosition2=0, connected1=true, connected2=false), g1=15.0, b1=15.0, g2=25.0, b2=25.0)", lineCreation.toString() ); } @@ -277,8 +313,20 @@ protected ModificationInfos buildModificationUpdate() { .busOrBusbarSectionId1("1A") .voltageLevelId2("v1") .busOrBusbarSectionId2("1.1") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.).temporaryLimits(Collections.emptyList()).build() + ).build() + ) + ) .connectionName1("cn1LineEdited") .connectionDirection1(ConnectablePosition.Direction.BOTTOM) .connectionName2("cn2LineEdited") diff --git a/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationBusBreakerTest.java b/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationBusBreakerTest.java index 247cfe9ab..0d7b6b78b 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationBusBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationBusBreakerTest.java @@ -59,8 +59,20 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v12") .busOrBusbarSectionId2("bus12") .connected2(true) - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build() + ).build() + ) + ) .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn202") @@ -166,8 +178,20 @@ protected ModificationInfos buildModificationUpdate() { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus3") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build() + ).build() + ) + ) .connectionName1("cn2012") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn2022") diff --git a/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationMixedBreakerTest.java b/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationMixedBreakerTest.java index c5caebadc..c2c8b77ef 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationMixedBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationMixedBreakerTest.java @@ -160,8 +160,24 @@ protected ModificationInfos buildModificationUpdate() { .busOrBusbarSectionId1("bus1") .voltageLevelId2("v2") .busOrBusbarSectionId2("bus3") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder() + .currentLimits(CurrentLimitsInfos.builder() + .permanentLimit(3.) + .temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())) + .build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder() + .currentLimits( + CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build() + ).build() + ) + ) .connectionName1("cn2012") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn2022") diff --git a/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java b/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java index 6b131528c..b7d8791b4 100644 --- a/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java +++ b/src/test/java/org/gridsuite/modification/server/modifications/TwoWindingsTransformerCreationNodeBreakerTest.java @@ -62,8 +62,23 @@ protected ModificationInfos buildModification() { .voltageLevelId2("v2") .busOrBusbarSectionId2("1A") .connected2(true) - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(2147483647).value(671.).build())).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of( + CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(2147483647).value(671.).build() + ) + ).build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build() + ).build() + ) + ) .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) .connected1(true) @@ -171,8 +186,20 @@ protected ModificationInfos buildModificationUpdate() { .busOrBusbarSectionId1("1.1") .voltageLevelId2("v2") .busOrBusbarSectionId2("1A") - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(3.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT5").acceptableDuration(98647).value(45.).build())).build() + ).build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(2.).temporaryLimits(List.of(CurrentTemporaryLimitCreationInfos.builder().name("IT10").acceptableDuration(683647).value(791.).build())).build() + ).build() + ) + ) .connectionName1("cn2012") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn2022") @@ -342,7 +369,7 @@ void testCreateTwoWindingsTransformerWithRatioTapChangerInNodeBreaker() throws E testCreateTwoWindingsTransformerInNodeBreaker(twoWindingsTransformerCreationInfos2, 2); assertEquals( - "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, currentLimits1=null, currentLimits2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", + "TwoWindingsTransformerCreationInfos(super=BranchCreationInfos(super=EquipmentCreationInfos(super=EquipmentModificationInfos(super=ModificationInfos(uuid=null, type=TWO_WINDINGS_TRANSFORMER_CREATION, date=null, stashed=false, messageType=null, messageValues=null, activated=true), equipmentId=id2wt1WithRatioTapChanger2, properties=null), equipmentName=2wtName), r=400.0, x=300.0, voltageLevelId1=v1, voltageLevelId2=v4, busOrBusbarSectionId1=1.1, busOrBusbarSectionId2=1.A, operationalLimitsGroups1=null, operationalLimitsGroups2=null, selectedOperationalLimitsGroup1=null, selectedOperationalLimitsGroup2=null, connectionName1=null, connectionDirection1=TOP, connectionName2=null, connectionDirection2=TOP, connectionPosition1=null, connectionPosition2=null, connected1=true, connected2=true), g=100.0, b=200.0, ratedU1=1000.0, ratedU2=1010.0, ratedS=null, ratioTapChanger=RatioTapChangerCreationInfos(super=TapChangerCreationInfos(lowTapPosition=0, tapPosition=1, regulating=true, targetDeadband=null, regulatingTerminalId=v1load, regulatingTerminalType=LOAD, regulatingTerminalVlId=v1, steps=[TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78473, x=39.784725, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78474, x=39.784726, g=0.0, b=0.0, alpha=0.0), TapChangerStepCreationInfos(index=0, rho=1.0, r=39.78475, x=39.784727, g=0.0, b=0.0, alpha=0.0)]), loadTapChangingCapabilities=true, targetV=220.0), phaseTapChanger=null)", twoWindingsTransformerCreationInfos2.toString() ); diff --git a/src/test/java/org/gridsuite/modification/server/service/BuildTest.java b/src/test/java/org/gridsuite/modification/server/service/BuildTest.java index 646fb3474..06ff22fe2 100644 --- a/src/test/java/org/gridsuite/modification/server/service/BuildTest.java +++ b/src/test/java/org/gridsuite/modification/server/service/BuildTest.java @@ -528,7 +528,7 @@ void runBuildTest(final MockWebServer server) throws Exception { .connectionPosition(0) .terminalConnected(true) .build())); - entities2.add(ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("newLine").equipmentName("newLine").r(1.0).x(2.0).g1(3.0).b1(4.0).g2(5.0).b2(6.0).voltageLevelId1("v1").busOrBusbarSectionId1("1.1").voltageLevelId2("v2").busOrBusbarSectionId2("1B").currentLimits1(null).currentLimits2(null).connectionName1("cn101").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn102").connectionDirection2(ConnectablePosition.Direction.TOP).connected1(true).connected2(true).build())); + entities2.add(ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("newLine").equipmentName("newLine").r(1.0).x(2.0).g1(3.0).b1(4.0).g2(5.0).b2(6.0).voltageLevelId1("v1").busOrBusbarSectionId1("1.1").voltageLevelId2("v2").busOrBusbarSectionId2("1B").operationalLimitsGroups1(null).operationalLimitsGroups2(null).connectionName1("cn101").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn102").connectionDirection2(ConnectablePosition.Direction.TOP).connected1(true).connected2(true).build())); List tapChangerStepCreationEmbeddables = new ArrayList<>(); tapChangerStepCreationEmbeddables.add(new TapChangerStepCreationEmbeddable(TapChangerType.PHASE, 1, 1, 0, 0, 0, 0, 0.)); @@ -584,8 +584,20 @@ void runBuildTest(final MockWebServer server) throws Exception { .voltageLevelId2("v2") .busOrBusbarSectionId2("1A") .connected2(true) - .currentLimits1(CurrentLimitsInfos.builder().permanentLimit(3.).build()) - .currentLimits2(CurrentLimitsInfos.builder().permanentLimit(2.).build()) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(3.).build()) + .build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(2.).build()) + .build() + ) + ) .connectionName1("cn201") .connectionDirection1(ConnectablePosition.Direction.TOP) .connectionName2("cn202") diff --git a/src/test/java/org/gridsuite/modification/server/service/ModificationRepositoryTest.java b/src/test/java/org/gridsuite/modification/server/service/ModificationRepositoryTest.java index c3683a2e0..47b364c17 100644 --- a/src/test/java/org/gridsuite/modification/server/service/ModificationRepositoryTest.java +++ b/src/test/java/org/gridsuite/modification/server/service/ModificationRepositoryTest.java @@ -404,12 +404,43 @@ void testShuntCompensatorCreation() { @Test void testLineCreation() { var createLineEntity1 = ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("idLine1").equipmentName("nameLine1").r(1.0).x(1.1).g1(10.0).b1(11.0).g2(100.0).b2(100.1).voltageLevelId1("vlId11").busOrBusbarSectionId1("busId11").voltageLevelId2("vlId12").busOrBusbarSectionId2("busId12").connectionName1("cn11").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn22").connectionDirection2(ConnectablePosition.Direction.TOP).build()); - var createLineEntity2 = ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("idLine2").equipmentName("nameLine2").r(2.0).x(2.2).g1(20.0).b1(22.0).g2(200.0).b2(200.2).voltageLevelId1("vlId21").busOrBusbarSectionId1("busId21").voltageLevelId2("vlId22").busOrBusbarSectionId2("busId22").connectionName1("cn33").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn44").connectionDirection2(ConnectablePosition.Direction.BOTTOM).currentLimits2(CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build()).build()); - var createLineEntity3 = ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("idLine3").equipmentName("nameLine3").r(3.0).x(3.3).g1(30.0).b1(33.0).g2(300.0).b2(300.3).voltageLevelId1("vlId31").busOrBusbarSectionId1("busId31").voltageLevelId2("vlId32").busOrBusbarSectionId2("busId32").connectionName1("cn55").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn66").connectionDirection2(ConnectablePosition.Direction.TOP).currentLimits1(CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build()).build()); - var createLineEntity4 = ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("idLine4").equipmentName("nameLine4").r(3.0).x(3.3).g1(null).b1(null).g2(null).b2(null).voltageLevelId1("vlId41").busOrBusbarSectionId1("busId41").voltageLevelId2("vlId42").busOrBusbarSectionId2("busId42").connectionName1("cn77").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn88").connectionDirection2(ConnectablePosition.Direction.BOTTOM).currentLimits1(CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build()).currentLimits2(CurrentLimitsInfos.builder().permanentLimit(4.0).temporaryLimits(Collections.emptyList()).build()).build()); + var createLineEntity2 = ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("idLine2").equipmentName("nameLine2").r(2.0).x(2.2).g1(20.0).b1(22.0).g2(200.0).b2(200.2).voltageLevelId1("vlId21").busOrBusbarSectionId1("busId21").voltageLevelId2("vlId22").busOrBusbarSectionId2("busId22").connectionName1("cn33").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn44").connectionDirection2(ConnectablePosition.Direction.BOTTOM) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build()) + .build() + ) + ) + .build()); + var createLineEntity3 = ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("idLine3").equipmentName("nameLine3").r(3.0).x(3.3).g1(30.0).b1(33.0).g2(300.0).b2(300.3).voltageLevelId1("vlId31").busOrBusbarSectionId1("busId31").voltageLevelId2("vlId32").busOrBusbarSectionId2("busId32").connectionName1("cn55").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn66").connectionDirection2(ConnectablePosition.Direction.TOP) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build()) + .build() + ) + ) + .build()); + var createLineEntity4 = ModificationEntity.fromDTO(LineCreationInfos.builder().equipmentId("idLine4").equipmentName("nameLine4").r(3.0).x(3.3).g1(null).b1(null).g2(null).b2(null).voltageLevelId1("vlId41").busOrBusbarSectionId1("busId41").voltageLevelId2("vlId42").busOrBusbarSectionId2("busId42").connectionName1("cn77").connectionDirection1(ConnectablePosition.Direction.TOP).connectionName2("cn88").connectionDirection2(ConnectablePosition.Direction.BOTTOM) + .operationalLimitsGroups1( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(5.0).temporaryLimits(Collections.emptyList()).build()) + .build() + ) + ) + .operationalLimitsGroups2( + List.of( + OperationalLimitsGroupInfos.builder().currentLimits( + CurrentLimitsInfos.builder().permanentLimit(4.0).temporaryLimits(Collections.emptyList()).build()) + .build() + ) + ) + .build()); networkModificationRepository.saveModifications(TEST_GROUP_ID, List.of(createLineEntity1, createLineEntity2, createLineEntity3, createLineEntity4)); - assertRequestsCount(2, 4, 0, 0); + assertRequestsCount(2, 7, 0, 0); List modificationInfos = networkModificationRepository.getModifications(TEST_GROUP_ID, true, true); assertEquals(4, modificationInfos.size()); @@ -428,15 +459,15 @@ void testLineCreation() { SQLStatementCountValidator.reset(); networkModificationRepository.deleteModifications(TEST_GROUP_ID, List.of(createLineEntity2.getId(), createLineEntity3.getId())); - assertRequestsCount(6, 0, 0, 7); + assertRequestsCount(10, 0, 0, 11); SQLStatementCountValidator.reset(); assertEquals(2, networkModificationRepository.getModifications(TEST_GROUP_ID, false, true).size()); - assertRequestsCount(8, 0, 0, 0); + assertRequestsCount(12, 0, 0, 0); SQLStatementCountValidator.reset(); networkModificationRepository.deleteModificationGroup(TEST_GROUP_ID, true); - assertRequestsCount(6, 0, 0, 5); + assertRequestsCount(10, 0, 0, 12); assertThrows(NetworkModificationException.class, () -> networkModificationRepository.getModifications(TEST_GROUP_ID, true, true), new NetworkModificationException(MODIFICATION_GROUP_NOT_FOUND, TEST_GROUP_ID.toString()).getMessage()); @@ -926,7 +957,7 @@ void testLineAttachToVoltageLevel() { SQLStatementCountValidator.reset(); networkModificationRepository.deleteModifications(TEST_GROUP_ID, List.of(lineAttachToEntity1.getId(), lineAttachToEntity2.getId())); - assertRequestsCount(6, 0, 0, 12); + assertRequestsCount(10, 0, 0, 12); SQLStatementCountValidator.reset(); networkModificationRepository.deleteModificationGroup(TEST_GROUP_ID, true);