|
13 | 13 | import com.powsybl.commons.report.TypedValue; |
14 | 14 | import com.powsybl.network.store.client.NetworkStoreService; |
15 | 15 | import com.powsybl.network.store.iidm.impl.NetworkFactoryImpl; |
16 | | -import org.gridsuite.modification.ModificationType; |
| 16 | +import org.gridsuite.modification.dto.VoltageInitModificationInfos; |
| 17 | +import org.gridsuite.modification.dto.VoltageLevelModificationInfos; |
17 | 18 | import org.gridsuite.modification.server.dto.ModificationApplicationGroup; |
18 | 19 | import org.gridsuite.modification.server.dto.NetworkInfos; |
19 | 20 | import org.gridsuite.modification.server.dto.NetworkModificationResult; |
20 | 21 | import org.gridsuite.modification.server.dto.NetworkModificationResult.ApplicationStatus; |
21 | 22 | import org.gridsuite.modification.server.dto.ReportInfos; |
22 | 23 | import org.gridsuite.modification.server.entities.ModificationEntity; |
| 24 | +import org.gridsuite.modification.server.entities.equipment.modification.VoltageInitModificationEntity; |
| 25 | +import org.gridsuite.modification.server.entities.equipment.modification.VoltageLevelModificationEntity; |
23 | 26 | import org.gridsuite.modification.server.modifications.NetworkModificationApplicator; |
24 | 27 | import org.gridsuite.modification.server.utils.TestUtils; |
25 | 28 | import org.gridsuite.modification.server.utils.elasticsearch.DisableElasticsearch; |
@@ -79,28 +82,97 @@ void setUp() { |
79 | 82 |
|
80 | 83 | @Test |
81 | 84 | void testApplyModificationsWithAllCollectionsNeededForBusView() { |
82 | | - List<ModificationEntity> modificationInfosList = List.of(mock(ModificationEntity.class)); |
83 | | - |
84 | | - when(modificationInfosList.get(0).getType()).thenReturn(ModificationType.VOLTAGE_INIT_MODIFICATION.name()); |
| 85 | + var modificationInfos = VoltageInitModificationInfos.builder() |
| 86 | + .stashed(false) |
| 87 | + .activated(true) |
| 88 | + .build(); |
| 89 | + List<ModificationEntity> modificationInfosList = List.of(new VoltageInitModificationEntity(modificationInfos)); |
85 | 90 |
|
86 | | - NetworkModificationResult result = TestUtils.applyModificationsBlocking(networkModificationApplicator, new ModificationApplicationGroup(UUID.randomUUID(), modificationInfosList, reportInfos), networkInfos); |
| 91 | + NetworkModificationResult result = TestUtils.applyModificationsBlocking( |
| 92 | + networkModificationApplicator, |
| 93 | + new ModificationApplicationGroup(UUID.randomUUID(), modificationInfosList, reportInfos), |
| 94 | + networkInfos |
| 95 | + ); |
87 | 96 |
|
88 | 97 | assertNotNull(result); |
89 | 98 | verify(largeNetworkModificationExecutionService).supplyAsync(any()); |
90 | 99 | } |
91 | 100 |
|
92 | 101 | @Test |
93 | 102 | void testApplyModificationsWithGroupsAndAllCollectionsNeededForBusView() { |
94 | | - List<ModificationApplicationGroup> modificationInfosGroups = List.of(new ModificationApplicationGroup(UUID.randomUUID(), List.of(mock(ModificationEntity.class)), mock(ReportInfos.class))); |
95 | | - |
96 | | - when(modificationInfosGroups.get(0).modifications().get(0).getType()).thenReturn(ModificationType.VOLTAGE_INIT_MODIFICATION.name()); |
| 103 | + var modificationInfos = VoltageInitModificationInfos.builder() |
| 104 | + .stashed(false) |
| 105 | + .activated(true) |
| 106 | + .build(); |
| 107 | + List<ModificationEntity> modificationInfosList = List.of(new VoltageInitModificationEntity(modificationInfos)); |
| 108 | + List<ModificationApplicationGroup> modificationInfosGroups = List.of( |
| 109 | + new ModificationApplicationGroup( |
| 110 | + UUID.randomUUID(), |
| 111 | + modificationInfosList, |
| 112 | + mock(ReportInfos.class) |
| 113 | + )); |
97 | 114 |
|
98 | 115 | NetworkModificationResult result = networkModificationApplicator.applyModifications(modificationInfosGroups, networkInfos); |
99 | 116 |
|
100 | 117 | assertNotNull(result); |
101 | 118 | verify(largeNetworkModificationExecutionService).supplyAsync(any()); |
102 | 119 | } |
103 | 120 |
|
| 121 | + @Test |
| 122 | + void testApplyModificationsWithAllCollectionsNeededForBusViewStashedAndNotActivated() { |
| 123 | + var modificationInfosList = createModificationsWithUnactiveAllCollectionAndActiveNone(); |
| 124 | + |
| 125 | + NetworkModificationResult result = TestUtils.applyModificationsBlocking( |
| 126 | + networkModificationApplicator, |
| 127 | + new ModificationApplicationGroup(UUID.randomUUID(), modificationInfosList, reportInfos), |
| 128 | + networkInfos |
| 129 | + ); |
| 130 | + |
| 131 | + assertNotNull(result); |
| 132 | + verifyNoInteractions(largeNetworkModificationExecutionService); |
| 133 | + } |
| 134 | + |
| 135 | + @Test |
| 136 | + void testApplyModificationsWithGroupsAndAllCollectionsNeededForBusViewStashedAndNotActivated() { |
| 137 | + var modificationInfosList = createModificationsWithUnactiveAllCollectionAndActiveNone(); |
| 138 | + List<ModificationApplicationGroup> modificationInfosGroups = List.of( |
| 139 | + new ModificationApplicationGroup( |
| 140 | + UUID.randomUUID(), |
| 141 | + modificationInfosList, |
| 142 | + mock(ReportInfos.class) |
| 143 | + )); |
| 144 | + |
| 145 | + NetworkModificationResult result = networkModificationApplicator.applyModifications(modificationInfosGroups, networkInfos); |
| 146 | + |
| 147 | + assertNotNull(result); |
| 148 | + verifyNoInteractions(largeNetworkModificationExecutionService); |
| 149 | + } |
| 150 | + |
| 151 | + private List<ModificationEntity> createModificationsWithUnactiveAllCollectionAndActiveNone() { |
| 152 | + // All collections but stashed |
| 153 | + var modificationInfosStashed = VoltageInitModificationInfos.builder() |
| 154 | + .stashed(true) |
| 155 | + .activated(true) |
| 156 | + .build(); |
| 157 | + // All collections but not activated |
| 158 | + var modificationInfosNotActivated = VoltageInitModificationInfos.builder() |
| 159 | + .stashed(true) |
| 160 | + .activated(false) |
| 161 | + .build(); |
| 162 | + // None and active |
| 163 | + var modificationInfosPreloadingNone = VoltageLevelModificationInfos.builder() |
| 164 | + .stashed(false) |
| 165 | + .activated(true) |
| 166 | + .equipmentId(UUID.randomUUID().toString()) |
| 167 | + .build(); |
| 168 | + // So in the end strategy should be none |
| 169 | + return List.of( |
| 170 | + new VoltageInitModificationEntity(modificationInfosStashed), |
| 171 | + new VoltageInitModificationEntity(modificationInfosNotActivated), |
| 172 | + new VoltageLevelModificationEntity(modificationInfosPreloadingNone) |
| 173 | + ); |
| 174 | + } |
| 175 | + |
104 | 176 | @ParameterizedTest |
105 | 177 | @MethodSource("provideArgumentsForComputeHigherSeverity") |
106 | 178 | void computeHigherSeverity(List<ReportNode> reports, ApplicationStatus expectedSeverity) { |
|
0 commit comments