diff --git a/src/main/java/org/gridsuite/study/server/controller/StudyController.java b/src/main/java/org/gridsuite/study/server/controller/StudyController.java index 6084fb834d..08f63071a1 100644 --- a/src/main/java/org/gridsuite/study/server/controller/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/controller/StudyController.java @@ -20,6 +20,7 @@ import org.gridsuite.study.server.StudyApi; import org.gridsuite.study.server.StudyConstants.ModificationsActionType; import org.gridsuite.study.server.dto.modification.NetworkModificationMetadata; +import org.gridsuite.study.server.dto.securityanalysis.SecurityAnalysisParametersValues; import org.gridsuite.study.server.error.StudyException; import org.gridsuite.study.server.dto.*; import org.gridsuite.study.server.dto.computation.LoadFlowComputationInfos; @@ -1079,7 +1080,7 @@ public ResponseEntity> getResultEnumValues(@Parameter(description = @ApiResponse(responseCode = "204", description = "Reset with user profile cannot be done")}) public ResponseEntity setLoadflowParameters( @PathVariable("studyUuid") UUID studyUuid, - @RequestBody(required = false) String lfParameter, + @RequestBody(required = false) LoadFlowParametersInfos lfParameter, @RequestHeader(HEADER_USER_ID) String userId) { studyService.assertNoBlockedNodeInStudy(studyUuid, networkModificationTreeService.getStudyRootNodeUuid(studyUuid)); return studyService.setLoadFlowParameters(studyUuid, lfParameter, userId) ? ResponseEntity.noContent().build() : ResponseEntity.ok().build(); @@ -2071,7 +2072,7 @@ public ResponseEntity getDynamicSecurityAnalysisStatus(@Parameter(descri @GetMapping(value = "/studies/{studyUuid}/security-analysis/parameters") @Operation(summary = "Get security analysis parameters on study") @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis parameters")}) - public ResponseEntity getSecurityAnalysisParametersValues( + public ResponseEntity getSecurityAnalysisParametersValues( @PathVariable("studyUuid") UUID studyUuid) { return ResponseEntity.ok().body(studyService.getSecurityAnalysisParametersValues(studyUuid)); } @@ -2082,7 +2083,7 @@ public ResponseEntity getSecurityAnalysisParametersValues( @ApiResponse(responseCode = "204", description = "Reset with user profile cannot be done")}) public ResponseEntity setSecurityAnalysisParametersValues( @PathVariable("studyUuid") UUID studyUuid, - @RequestBody(required = false) String securityAnalysisParametersValues, + @RequestBody(required = false) SecurityAnalysisParametersValues securityAnalysisParametersValues, @RequestHeader(HEADER_USER_ID) String userId) { return studyService.setSecurityAnalysisParametersValues(studyUuid, securityAnalysisParametersValues, userId) ? ResponseEntity.noContent().build() : ResponseEntity.ok().build(); } diff --git a/src/main/java/org/gridsuite/study/server/dto/securityanalysis/SecurityAnalysisParametersValues.java b/src/main/java/org/gridsuite/study/server/dto/securityanalysis/SecurityAnalysisParametersValues.java new file mode 100644 index 0000000000..30a0f6cf7c --- /dev/null +++ b/src/main/java/org/gridsuite/study/server/dto/securityanalysis/SecurityAnalysisParametersValues.java @@ -0,0 +1,37 @@ +package org.gridsuite.study.server.dto.securityanalysis; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.gridsuite.study.server.dto.LimitReductionsByVoltageLevel; + +import java.util.List; + +/** + * This DTO is a copy of Security Analysis Server's SecurityAnalysisParametersValues DTO and require updates when original DTO is updated + * + * @author Kamil MARUT {@literal } + */ + +@Getter +@AllArgsConstructor +@Builder +@NoArgsConstructor +public class SecurityAnalysisParametersValues { + + private String provider; + + private double lowVoltageAbsoluteThreshold; + + private double lowVoltageProportionalThreshold; + + private double highVoltageAbsoluteThreshold; + + private double highVoltageProportionalThreshold; + + private double flowProportionalThreshold; + + private List limitReductions; + +} diff --git a/src/main/java/org/gridsuite/study/server/service/LoadFlowService.java b/src/main/java/org/gridsuite/study/server/service/LoadFlowService.java index d299b9a293..3567443c36 100644 --- a/src/main/java/org/gridsuite/study/server/service/LoadFlowService.java +++ b/src/main/java/org/gridsuite/study/server/service/LoadFlowService.java @@ -241,9 +241,9 @@ public LoadFlowParametersInfos getLoadFlowParameters(UUID parametersUuid) { return restTemplate.getForObject(loadFlowServerBaseUri + path, LoadFlowParametersInfos.class); } - public UUID createLoadFlowParameters(String parameters) { + public UUID createLoadFlowParameters(LoadFlowParametersInfos lfParameters) { - Objects.requireNonNull(parameters); + Objects.requireNonNull(lfParameters); var path = UriComponentsBuilder .fromPath(DELIMITER + LOADFLOW_API_VERSION + "/parameters") @@ -253,7 +253,7 @@ public UUID createLoadFlowParameters(String parameters) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity httpEntity = new HttpEntity<>(parameters, headers); + HttpEntity httpEntity = new HttpEntity<>(lfParameters, headers); return restTemplate.postForObject(loadFlowServerBaseUri + path, httpEntity, UUID.class); } @@ -270,7 +270,7 @@ public UUID duplicateLoadFlowParameters(UUID sourceParametersUuid) { return restTemplate.postForObject(loadFlowServerBaseUri + path, null, UUID.class); } - public void updateLoadFlowParameters(UUID parametersUuid, @Nullable String parameters) { + public void updateLoadFlowParameters(UUID parametersUuid, @Nullable LoadFlowParametersInfos lfParameters) { var path = UriComponentsBuilder .fromPath(DELIMITER + LOADFLOW_API_VERSION + PARAMETERS_URI) .buildAndExpand(parametersUuid) @@ -279,7 +279,7 @@ public void updateLoadFlowParameters(UUID parametersUuid, @Nullable String param HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity httpEntity = new HttpEntity<>(parameters, headers); + HttpEntity httpEntity = new HttpEntity<>(lfParameters, headers); restTemplate.put(loadFlowServerBaseUri + path, httpEntity); } diff --git a/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java b/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java index 81ed8fcfda..0ec99d16c9 100644 --- a/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java +++ b/src/main/java/org/gridsuite/study/server/service/SecurityAnalysisService.java @@ -11,6 +11,7 @@ import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.gridsuite.study.server.RemoteServicesProperties; +import org.gridsuite.study.server.dto.securityanalysis.SecurityAnalysisParametersValues; import org.gridsuite.study.server.error.StudyException; import org.gridsuite.study.server.dto.NodeReceiver; import org.gridsuite.study.server.dto.ReportInfos; @@ -225,13 +226,13 @@ public void assertSecurityAnalysisNotRunning(UUID resultUuid) { } } - public void updateSecurityAnalysisParameters(UUID parametersUuid, @Nullable String parameters) { + public void updateSecurityAnalysisParameters(UUID parametersUuid, @Nullable SecurityAnalysisParametersValues saParameters) { var uriBuilder = UriComponentsBuilder.fromPath(DELIMITER + SECURITY_ANALYSIS_API_VERSION + "/parameters/{uuid}"); String path = uriBuilder.buildAndExpand(parametersUuid).toUriString(); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity httpEntity = new HttpEntity<>(parameters, headers); + HttpEntity httpEntity = new HttpEntity<>(saParameters, headers); restTemplate.put(securityAnalysisServerBaseUri + path, httpEntity); } @@ -250,13 +251,13 @@ public UUID duplicateSecurityAnalysisParameters(UUID sourceParametersUuid) { return restTemplate.exchange(securityAnalysisServerBaseUri + path, HttpMethod.POST, httpEntity, UUID.class).getBody(); } - public String getSecurityAnalysisParameters(UUID parametersUuid) { + public SecurityAnalysisParametersValues getSecurityAnalysisParameters(UUID parametersUuid) { Objects.requireNonNull(parametersUuid); String path = UriComponentsBuilder.fromPath(DELIMITER + SECURITY_ANALYSIS_API_VERSION + PARAMETERS_URI) .buildAndExpand(parametersUuid).toUriString(); - return restTemplate.getForObject(securityAnalysisServerBaseUri + path, String.class); + return restTemplate.getForObject(securityAnalysisServerBaseUri + path, SecurityAnalysisParametersValues.class); } public UUID getSecurityAnalysisParametersUuidOrElseCreateDefaults(StudyEntity studyEntity) { @@ -286,7 +287,7 @@ public UUID createDefaultSecurityAnalysisParameters() { return restTemplate.exchange(securityAnalysisServerBaseUri + path, HttpMethod.POST, null, UUID.class).getBody(); } - public UUID createSecurityAnalysisParameters(String parameters) { + public UUID createSecurityAnalysisParameters(SecurityAnalysisParametersValues saParameters) { var path = UriComponentsBuilder .fromPath(DELIMITER + SECURITY_ANALYSIS_API_VERSION + "/parameters") .buildAndExpand() @@ -294,7 +295,7 @@ public UUID createSecurityAnalysisParameters(String parameters) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); - HttpEntity httpEntity = new HttpEntity<>(parameters, headers); + HttpEntity httpEntity = new HttpEntity<>(saParameters, headers); return restTemplate.exchange(securityAnalysisServerBaseUri + path, HttpMethod.POST, httpEntity, UUID.class).getBody(); } diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index c215edb902..fefa7fcb59 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -17,6 +17,7 @@ import org.gridsuite.filter.utils.EquipmentType; import org.gridsuite.study.server.StudyConstants; import org.gridsuite.study.server.dto.modification.*; +import org.gridsuite.study.server.dto.securityanalysis.SecurityAnalysisParametersValues; import org.gridsuite.study.server.dto.voltageinit.ContextInfos; import org.gridsuite.study.server.error.StudyException; import org.gridsuite.study.server.dto.*; @@ -543,6 +544,7 @@ private Optional doDeleteStudyIfNotCreationInProgress(UUID stu removeVoltageInitParameters(s.getVoltageInitParametersUuid()); removeSensitivityAnalysisParameters(s.getSensitivityAnalysisParametersUuid()); removeDynamicSecurityAnalysisParameters(s.getDynamicSecurityAnalysisParametersUuid()); + removeShortCircuitParameters(s.getShortCircuitParametersUuid()); removeNetworkVisualizationParameters(s.getNetworkVisualizationParametersUuid()); removeStateEstimationParameters(s.getStateEstimationParametersUuid()); removePccMinParameters(s.getPccMinParametersUuid()); @@ -1182,15 +1184,15 @@ public LoadFlowParametersInfos getLoadFlowParametersInfos(StudyEntity studyEntit } @Transactional - public String getSecurityAnalysisParametersValues(UUID studyUuid) { + public SecurityAnalysisParametersValues getSecurityAnalysisParametersValues(UUID studyUuid) { StudyEntity studyEntity = getStudy(studyUuid); return securityAnalysisService.getSecurityAnalysisParameters(securityAnalysisService.getSecurityAnalysisParametersUuidOrElseCreateDefaults(studyEntity)); } @Transactional - public boolean setSecurityAnalysisParametersValues(UUID studyUuid, String parameters, String userId) { + public boolean setSecurityAnalysisParametersValues(UUID studyUuid, SecurityAnalysisParametersValues saParameters, String userId) { StudyEntity studyEntity = getStudy(studyUuid); - boolean userProfileIssue = createOrUpdateSecurityAnalysisParameters(studyEntity, parameters, userId); + boolean userProfileIssue = createOrUpdateSecurityAnalysisParameters(studyEntity, saParameters, userId); invalidateSecurityAnalysisStatusOnAllNodes(studyUuid); notificationService.emitStudyChanged(studyUuid, null, null, NotificationService.UPDATE_TYPE_SECURITY_ANALYSIS_STATUS); notificationService.emitElementUpdated(studyUuid, userId); @@ -1222,9 +1224,9 @@ public void createOrUpdateNetworkVisualizationParameters(StudyEntity studyEntity } @Transactional - public boolean setLoadFlowParameters(UUID studyUuid, String parameters, String userId) { + public boolean setLoadFlowParameters(UUID studyUuid, LoadFlowParametersInfos lfParameters, String userId) { StudyEntity studyEntity = getStudy(studyUuid); - boolean userProfileIssue = createOrUpdateLoadFlowParameters(studyEntity, parameters, userId); + boolean userProfileIssue = createOrUpdateLoadFlowParameters(studyEntity, lfParameters, userId); invalidateAllStudyLoadFlowStatus(studyUuid); invalidateSecurityAnalysisStatusOnAllNodes(studyUuid); invalidateSensitivityAnalysisStatusOnAllNodes(studyUuid); @@ -1353,7 +1355,7 @@ public String getShortCircuitParametersInfo(UUID studyUuid) { @Transactional public boolean setShortCircuitParameters(UUID studyUuid, @Nullable String shortCircuitParametersInfos, String userId) { StudyEntity studyEntity = getStudy(studyUuid); - boolean userProfileIssue = createOrUpdateShortcircuitParameters(studyEntity, shortCircuitParametersInfos, userId); + boolean userProfileIssue = createOrUpdateShortCircuitParameters(studyEntity, shortCircuitParametersInfos, userId); invalidateShortCircuitStatusOnAllNodes(studyUuid); invalidatePccMinStatusOnAllNodes(studyUuid); notificationService.emitStudyChanged(studyUuid, null, null, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); @@ -1364,7 +1366,7 @@ public boolean setShortCircuitParameters(UUID studyUuid, @Nullable String shortC return userProfileIssue; } - public boolean createOrUpdateShortcircuitParameters(StudyEntity studyEntity, String parameters, String userId) { + public boolean createOrUpdateShortCircuitParameters(StudyEntity studyEntity, String scParameters, String userId) { /* +-----------------------+----------------+-----------------------------------------+ * | entity.parametersUuid | parametersInfo | action | * | no | no | create default ones | @@ -1374,36 +1376,40 @@ public boolean createOrUpdateShortcircuitParameters(StudyEntity studyEntity, Str * +-----------------------+----------------+-----------------------------------------+ */ boolean userProfileIssue = false; - UUID existingShortcircuitParametersUuid = studyEntity.getShortCircuitParametersUuid(); - UserProfileInfos userProfileInfos = parameters == null ? userAdminService.getUserProfile(userId) : null; - if (parameters == null && userProfileInfos.getShortcircuitParameterId() != null) { - // reset case, with existing profile, having default short circuit params - try { - UUID shortcircuitParametersFromProfileUuid = shortCircuitService.duplicateParameters(userProfileInfos.getShortcircuitParameterId()); - studyEntity.setShortCircuitParametersUuid(shortcircuitParametersFromProfileUuid); - removeShortcircuitParameters(existingShortcircuitParametersUuid); - return userProfileIssue; - } catch (Exception e) { - userProfileIssue = true; - LOGGER.error(String.format("Could not duplicate short circuit parameters with id '%s' from user/profile '%s/%s'. Using default parameters", - userProfileInfos.getShortcircuitParameterId(), userId, userProfileInfos.getName()), e); - // in case of duplication error (ex: wrong/dangling uuid in the profile), move on with default params below + + UUID studySCParametersId = studyEntity.getShortCircuitParametersUuid(); + String scParametersToUse = scParameters; + + // When no parameters given try to use user's profile parameters + if (scParametersToUse == null) { + UserProfileInfos userProfileinfos = userAdminService.getUserProfile(userId); + UUID profileSParamId = userProfileinfos != null ? userProfileinfos.getShortcircuitParameterId() : null; + + if (profileSParamId != null) { + try { + scParametersToUse = shortCircuitService.getParameters(profileSParamId); + } catch (Exception e) { + userProfileIssue = true; + LOGGER.error(String.format("Could not retrieve short circuit parameters with id '%s' from user/profile '%s/%s'. Using default parameters", + profileSParamId, userId, userProfileinfos.getName()), e); + } } } - if (existingShortcircuitParametersUuid == null) { - existingShortcircuitParametersUuid = shortCircuitService.createParameters(parameters); - studyEntity.setShortCircuitParametersUuid(existingShortcircuitParametersUuid); + if (studySCParametersId == null) { + studySCParametersId = shortCircuitService.createParameters(scParametersToUse); + studyEntity.setShortCircuitParametersUuid(studySCParametersId); } else { - shortCircuitService.updateParameters(existingShortcircuitParametersUuid, parameters); + shortCircuitService.updateParameters(studySCParametersId, scParametersToUse); } + return userProfileIssue; } - private void removeShortcircuitParameters(@Nullable UUID shortcircuitParametersUuid) { + private void removeShortCircuitParameters(@Nullable UUID shortcircuitParametersUuid) { if (shortcircuitParametersUuid != null) { try { - shortCircuitService.deleteShortcircuitParameters(shortcircuitParametersUuid); + shortCircuitService.deleteShortCircuitParameters(shortcircuitParametersUuid); } catch (Exception e) { LOGGER.error("Could not remove short circuit parameters with uuid:" + shortcircuitParametersUuid, e); } @@ -1674,37 +1680,55 @@ private StudyCreationRequestEntity insertStudyCreationRequestEntity(UUID studyUu return studyCreationRequestRepository.save(studyCreationRequestEntity); } - public boolean createOrUpdateLoadFlowParameters(StudyEntity studyEntity, String parameters, String userId) { + private LoadFlowParametersInfos buildLoadFlowParametersUsingProvider(LoadFlowParametersInfos lfParameters, String provider) { + return LoadFlowParametersInfos.builder() + .provider(provider) + .limitReduction(lfParameters.getLimitReduction()) + .commonParameters(lfParameters.getCommonParameters()) + .specificParametersPerProvider(lfParameters.getSpecificParametersPerProvider()) + .limitReductions(lfParameters.getLimitReductions()) + .build(); + + } + + public boolean createOrUpdateLoadFlowParameters(StudyEntity studyEntity, LoadFlowParametersInfos lfParameters, String userId) { boolean userProfileIssue = false; - UUID existingLoadFlowParametersUuid = studyEntity.getLoadFlowParametersUuid(); - UserProfileInfos userProfileInfos = parameters == null ? userAdminService.getUserProfile(userId) : null; - if (parameters == null && userProfileInfos.getLoadFlowParameterId() != null) { - // reset case, with existing profile, having default LF params - try { - UUID loadFlowParametersFromProfileUuid = loadflowService.duplicateLoadFlowParameters(userProfileInfos.getLoadFlowParameterId()); - if (existingLoadFlowParametersUuid != null) { - //For a reset to defaultValues we need to keep the provider if it exists because it's updated separately - String keptProvider = loadflowService.getLoadFlowParameters(existingLoadFlowParametersUuid).getProvider(); - loadflowService.updateLoadFlowProvider(loadFlowParametersFromProfileUuid, keptProvider); + UUID studyLFParametersId = studyEntity.getLoadFlowParametersUuid(); + LoadFlowParametersInfos lfParametersToUse = lfParameters; + + // When no parameters given try to use user's profile parameters + if (lfParametersToUse == null) { + UserProfileInfos userProfileinfos = userAdminService.getUserProfile(userId); + UUID profileLFParamId = userProfileinfos != null ? userProfileinfos.getLoadFlowParameterId() : null; + + if (profileLFParamId != null) { + UUID lastCheckedParametersId = profileLFParamId; + try { + LoadFlowParametersInfos userProfileLfParameters = loadflowService.getLoadFlowParameters(profileLFParamId); + if (studyLFParametersId != null) { + lastCheckedParametersId = studyLFParametersId; + String keptProvider = loadflowService.getLoadFlowParameters(studyLFParametersId).getProvider(); // Keep current study provider as this setting is updated separately + lfParametersToUse = buildLoadFlowParametersUsingProvider(userProfileLfParameters, keptProvider); + } else { + lfParametersToUse = userProfileLfParameters; + } + } catch (Exception e) { + userProfileIssue = true; + LOGGER.error(String.format( + "Could not retrieve loadflow parameters with id '%s' from user/profile '%s/%s'. Using default parameters", + lastCheckedParametersId, userId, userProfileinfos.getName()), e); } - studyEntity.setLoadFlowParametersUuid(loadFlowParametersFromProfileUuid); - removeLoadFlowParameters(existingLoadFlowParametersUuid); - return userProfileIssue; - } catch (Exception e) { - userProfileIssue = true; - LOGGER.error(String.format("Could not duplicate loadflow parameters with id '%s' from user/profile '%s/%s'. Using default parameters", - userProfileInfos.getLoadFlowParameterId(), userId, userProfileInfos.getName()), e); - // in case of duplication error (ex: wrong/dangling uuid in the profile), move on with default params below } } - if (existingLoadFlowParametersUuid == null) { - existingLoadFlowParametersUuid = loadflowService.createLoadFlowParameters(parameters); - studyEntity.setLoadFlowParametersUuid(existingLoadFlowParametersUuid); + if (studyLFParametersId == null) { + studyLFParametersId = loadflowService.createLoadFlowParameters(lfParametersToUse); + studyEntity.setLoadFlowParametersUuid(studyLFParametersId); } else { - loadflowService.updateLoadFlowParameters(existingLoadFlowParametersUuid, parameters); + loadflowService.updateLoadFlowParameters(studyLFParametersId, lfParametersToUse); } + return userProfileIssue; } @@ -1727,32 +1751,35 @@ public void updateDynamicSimulationParameters(UUID studyUuid, DynamicSimulationP }); } - public boolean createOrUpdateVoltageInitParameters(StudyEntity studyEntity, VoltageInitParametersInfos parameters, String userId) { + public boolean createOrUpdateVoltageInitParameters(StudyEntity studyEntity, VoltageInitParametersInfos viParameters, String userId) { boolean userProfileIssue = false; - UUID existingVoltageInitParametersUuid = studyEntity.getVoltageInitParametersUuid(); - UserProfileInfos userProfileInfos = parameters == null ? userAdminService.getUserProfile(userId) : null; - if (parameters == null && userProfileInfos.getVoltageInitParameterId() != null) { - // reset case, with existing profile, having default voltage init params - try { - UUID voltageInitParametersFromProfileUuid = voltageInitService.duplicateVoltageInitParameters(userProfileInfos.getVoltageInitParameterId()); - studyEntity.setVoltageInitParametersUuid(voltageInitParametersFromProfileUuid); - removeVoltageInitParameters(existingVoltageInitParametersUuid); - return userProfileIssue; - } catch (Exception e) { - userProfileIssue = true; - LOGGER.error(String.format("Could not duplicate voltage init parameters with id '%s' from user/profile '%s/%s'. Using default parameters", - userProfileInfos.getVoltageInitParameterId(), userId, userProfileInfos.getName()), e); - // in case of duplication error (ex: wrong/dangling uuid in the profile), move on with default params below + + UUID studyVIParametersId = studyEntity.getVoltageInitParametersUuid(); + VoltageInitParametersInfos viParametersToUse = viParameters; + + // When no parameters given try to use user's profile parameters + if (viParametersToUse == null) { + UserProfileInfos userProfileinfos = userAdminService.getUserProfile(userId); + UUID profileVIParamId = userProfileinfos != null ? userProfileinfos.getVoltageInitParameterId() : null; + + if (profileVIParamId != null) { + try { + viParametersToUse = voltageInitService.getVoltageInitParameters(profileVIParamId); + } catch (Exception e) { + userProfileIssue = true; + LOGGER.error(String.format("Could not retrieve voltage init parameters with id '%s' from user/profile '%s/%s'. Using default parameters", + profileVIParamId, userId, userProfileinfos.getName()), e); + } } } - if (existingVoltageInitParametersUuid == null) { - existingVoltageInitParametersUuid = voltageInitService.createVoltageInitParameters(parameters); - studyEntity.setVoltageInitParametersUuid(existingVoltageInitParametersUuid); + if (studyVIParametersId == null) { + studyVIParametersId = voltageInitService.createVoltageInitParameters(viParametersToUse); + studyEntity.setVoltageInitParametersUuid(studyVIParametersId); } else { - VoltageInitParametersInfos oldParameters = voltageInitService.getVoltageInitParameters(existingVoltageInitParametersUuid); - if (Objects.isNull(parameters) || !parameters.equals(oldParameters)) { - voltageInitService.updateVoltageInitParameters(existingVoltageInitParametersUuid, parameters); + VoltageInitParametersInfos currentStudyVIParameters = voltageInitService.getVoltageInitParameters(studyVIParametersId); + if (Objects.isNull(viParametersToUse) || !viParametersToUse.equals(currentStudyVIParameters)) { + voltageInitService.updateVoltageInitParameters(studyVIParametersId, viParametersToUse); } } @@ -1769,30 +1796,53 @@ private void removeVoltageInitParameters(@Nullable UUID voltageInitParametersUui } } - public boolean createOrUpdateSecurityAnalysisParameters(StudyEntity studyEntity, String parameters, String userId) { + private SecurityAnalysisParametersValues buildSecurityParametersUsingProvider(SecurityAnalysisParametersValues saParameters, String provider) { + return SecurityAnalysisParametersValues.builder() + .provider(provider) + .lowVoltageAbsoluteThreshold(saParameters.getLowVoltageAbsoluteThreshold()) + .lowVoltageProportionalThreshold(saParameters.getLowVoltageProportionalThreshold()) + .highVoltageAbsoluteThreshold(saParameters.getHighVoltageAbsoluteThreshold()) + .highVoltageProportionalThreshold(saParameters.getHighVoltageProportionalThreshold()) + .flowProportionalThreshold(saParameters.getFlowProportionalThreshold()) + .limitReductions(saParameters.getLimitReductions()) + .build(); + } + + public boolean createOrUpdateSecurityAnalysisParameters(StudyEntity studyEntity, SecurityAnalysisParametersValues saParameters, String userId) { boolean userProfileIssue = false; - UUID existingSecurityAnalysisParametersUuid = studyEntity.getSecurityAnalysisParametersUuid(); - UserProfileInfos userProfileInfos = parameters == null ? userAdminService.getUserProfile(userId) : null; - if (parameters == null && userProfileInfos.getSecurityAnalysisParameterId() != null) { - // reset case, with existing profile, having default security analysis params - try { - UUID securityAnalysisParametersFromProfileUuid = securityAnalysisService.duplicateSecurityAnalysisParameters(userProfileInfos.getSecurityAnalysisParameterId()); - studyEntity.setSecurityAnalysisParametersUuid(securityAnalysisParametersFromProfileUuid); - removeSecurityAnalysisParameters(existingSecurityAnalysisParametersUuid); - return userProfileIssue; - } catch (Exception e) { - userProfileIssue = true; - LOGGER.error(String.format("Could not duplicate security analysis parameters with id '%s' from user/profile '%s/%s'. Using default parameters", - userProfileInfos.getSecurityAnalysisParameterId(), userId, userProfileInfos.getName()), e); - // in case of duplication error (ex: wrong/dangling uuid in the profile), move on with default params below + + UUID studySAParametersId = studyEntity.getSecurityAnalysisParametersUuid(); + SecurityAnalysisParametersValues saParametersToUse = saParameters; + + // When no parameters given try to use user's profile parameters + if (saParametersToUse == null) { + UserProfileInfos userProfileinfos = userAdminService.getUserProfile(userId); + UUID profileSAParamId = userProfileinfos != null ? userProfileinfos.getSecurityAnalysisParameterId() : null; + + if (profileSAParamId != null) { + UUID lastCheckedParametersId = profileSAParamId; + try { + SecurityAnalysisParametersValues userProfileSAParameters = securityAnalysisService.getSecurityAnalysisParameters(profileSAParamId); + if (studySAParametersId != null) { + lastCheckedParametersId = studySAParametersId; + String keptProvider = securityAnalysisService.getSecurityAnalysisParameters(studySAParametersId).getProvider(); + saParametersToUse = buildSecurityParametersUsingProvider(userProfileSAParameters, keptProvider); + } else { + saParametersToUse = userProfileSAParameters; + } + } catch (Exception e) { + userProfileIssue = true; + LOGGER.error(String.format("Could not retrieve security analysis parameters with id '%s' from user/profile '%s/%s'. Using default parameters", + lastCheckedParametersId, userId, userProfileinfos.getName()), e); + } } } - if (existingSecurityAnalysisParametersUuid == null) { - existingSecurityAnalysisParametersUuid = securityAnalysisService.createSecurityAnalysisParameters(parameters); - studyEntity.setSecurityAnalysisParametersUuid(existingSecurityAnalysisParametersUuid); + if (studySAParametersId == null) { + studySAParametersId = securityAnalysisService.createSecurityAnalysisParameters(saParametersToUse); + studyEntity.setSecurityAnalysisParametersUuid(studySAParametersId); } else { - securityAnalysisService.updateSecurityAnalysisParameters(existingSecurityAnalysisParametersUuid, parameters); + securityAnalysisService.updateSecurityAnalysisParameters(studySAParametersId, saParametersToUse); } return userProfileIssue; @@ -2799,42 +2849,51 @@ public boolean setSpreadsheetConfigCollection(UUID studyUuid, String configColle * If configCollection is null, try to use the one from user profile, or system default if no profile. * * @param studyEntity the study entity - * @param configCollection the spreadsheet config collection (null means reset to default) + * @param spreadsheetConfigCollection the spreadsheet config collection (null means reset to default) * @param userId the user ID for retrieving profile * @return true if reset with user profile cannot be done, false otherwise */ - private boolean createOrUpdateSpreadsheetConfigCollection(StudyEntity studyEntity, String configCollection, String userId) { + private boolean createOrUpdateSpreadsheetConfigCollection(StudyEntity studyEntity, String spreadsheetConfigCollection, String userId) { boolean userProfileIssue = false; - UUID existingSpreadsheetConfigCollectionUuid = studyEntity.getSpreadsheetConfigCollectionUuid(); - UserProfileInfos userProfileInfos = configCollection == null ? userAdminService.getUserProfile(userId) : null; - if (configCollection == null && userProfileInfos.getSpreadsheetConfigCollectionId() != null) { - // reset case, with existing profile, having default spreadsheet config collection - try { - UUID spreadsheetConfigCollectionFromProfileUuid = studyConfigService.duplicateSpreadsheetConfigCollection(userProfileInfos.getSpreadsheetConfigCollectionId()); - studyEntity.setSpreadsheetConfigCollectionUuid(spreadsheetConfigCollectionFromProfileUuid); - removeSpreadsheetConfigCollection(existingSpreadsheetConfigCollectionUuid); - return userProfileIssue; - } catch (Exception e) { - userProfileIssue = true; - LOGGER.error(String.format("Could not duplicate spreadsheet config collection with id '%s' from user/profile '%s/%s'. Using default collection", - userProfileInfos.getSpreadsheetConfigCollectionId(), userId, userProfileInfos.getName()), e); - // in case of duplication error (ex: wrong/dangling uuid in the profile), move on with default collection below + UUID studySCCId = studyEntity.getSpreadsheetConfigCollectionUuid(); + String sccToUse = spreadsheetConfigCollection; + + // When no spreadsheet config collection given try to use user's profile spreadsheet config collection + if (sccToUse == null) { + UserProfileInfos userProfileinfos = userAdminService.getUserProfile(userId); + UUID profileSCCId = userProfileinfos != null ? userProfileinfos.getSpreadsheetConfigCollectionId() : null; + + if (profileSCCId != null) { + try { + sccToUse = studyConfigService.getSpreadsheetConfigCollection(profileSCCId); + } catch (Exception e) { + userProfileIssue = true; + LOGGER.error(String.format( + "Could not retrieve spreadsheet config collection with id '%s' from user/profile '%s/%s'. Using default collection", + profileSCCId, userId, userProfileinfos.getName()), e); + } } } - if (configCollection != null) { - if (existingSpreadsheetConfigCollectionUuid == null) { - UUID newUuid = studyConfigService.createSpreadsheetConfigCollection(configCollection); - studyEntity.setSpreadsheetConfigCollectionUuid(newUuid); + if (studySCCId != null) { + if (sccToUse != null) { + studyConfigService.updateSpreadsheetConfigCollection(studySCCId, sccToUse); } else { - studyConfigService.updateSpreadsheetConfigCollection(existingSpreadsheetConfigCollectionUuid, configCollection); + // No config provided, use system default + UUID defaultCollectionId = studyConfigService.createDefaultSpreadsheetConfigCollection(); + studyEntity.setSpreadsheetConfigCollectionUuid(defaultCollectionId); + removeSpreadsheetConfigCollection(studySCCId); } } else { - // No config provided, use system default - UUID defaultCollectionUuid = studyConfigService.createDefaultSpreadsheetConfigCollection(); - studyEntity.setSpreadsheetConfigCollectionUuid(defaultCollectionUuid); - removeSpreadsheetConfigCollection(existingSpreadsheetConfigCollectionUuid); + if (sccToUse != null) { + studySCCId = studyConfigService.createSpreadsheetConfigCollection(sccToUse); + studyEntity.setSpreadsheetConfigCollectionUuid(studySCCId); + } else { + // No config provided, use system default + UUID defaultCollectionId = studyConfigService.createDefaultSpreadsheetConfigCollection(); + studyEntity.setSpreadsheetConfigCollectionUuid(defaultCollectionId); + } } return userProfileIssue; @@ -3066,30 +3125,33 @@ public boolean setDynamicSecurityAnalysisParameters(UUID studyUuid, String dsaPa return userProfileIssue; } - public boolean createOrUpdateDynamicSecurityAnalysisParameters(StudyEntity studyEntity, String parameters, String userId) { + public boolean createOrUpdateDynamicSecurityAnalysisParameters(StudyEntity studyEntity, String dsaParameters, String userId) { boolean userProfileIssue = false; - UUID existingDynamicSecurityAnalysisParametersUuid = studyEntity.getDynamicSecurityAnalysisParametersUuid(); - UserProfileInfos userProfileInfos = parameters == null ? userAdminService.getUserProfile(userId) : null; - if (parameters == null && userProfileInfos.getDynamicSecurityAnalysisParameterId() != null) { - // reset case, with existing profile, having default dynamic security analysis params - try { - UUID dynamicSecurityAnalysisParametersFromProfileUuid = dynamicSecurityAnalysisService.duplicateParameters(userProfileInfos.getDynamicSecurityAnalysisParameterId()); - studyEntity.setDynamicSecurityAnalysisParametersUuid(dynamicSecurityAnalysisParametersFromProfileUuid); - removeDynamicSecurityAnalysisParameters(existingDynamicSecurityAnalysisParametersUuid); - return userProfileIssue; - } catch (Exception e) { - userProfileIssue = true; - LOGGER.error(String.format("Could not duplicate dynamic security analysis parameters with id '%s' from user/profile '%s/%s'. Using default parameters", - userProfileInfos.getDynamicSecurityAnalysisParameterId(), userId, userProfileInfos.getName()), e); - // in case of duplication error (ex: wrong/dangling uuid in the profile), move on with default params below + + UUID studyDSAParametersId = studyEntity.getDynamicSecurityAnalysisParametersUuid(); + String dsaParametersToUse = dsaParameters; + + // When no parameters given try to use user's profile parameters + if (dsaParametersToUse == null) { + UserProfileInfos userProfileInfos = userAdminService.getUserProfile(userId); + UUID profileDSAParamId = userProfileInfos != null ? userProfileInfos.getDynamicSecurityAnalysisParameterId() : null; + + if (profileDSAParamId != null) { + try { + dsaParametersToUse = dynamicSecurityAnalysisService.getParameters(profileDSAParamId); + } catch (Exception e) { + userProfileIssue = true; + LOGGER.error(String.format("Could not retrieve dynamic security analysis parameters with id '%s' from user/profile '%s/%s'. Using default parameters", + profileDSAParamId, userId, userProfileInfos.getName()), e); + } } } - if (existingDynamicSecurityAnalysisParametersUuid == null) { - UUID newDynamicSecurityAnalysisParametersUuid = dynamicSecurityAnalysisService.createParameters(parameters); - studyEntity.setDynamicSecurityAnalysisParametersUuid(newDynamicSecurityAnalysisParametersUuid); + if (studyDSAParametersId == null) { + studyDSAParametersId = dynamicSecurityAnalysisService.createParameters(dsaParametersToUse); + studyEntity.setDynamicSecurityAnalysisParametersUuid(studyDSAParametersId); } else { - dynamicSecurityAnalysisService.updateParameters(existingDynamicSecurityAnalysisParametersUuid, parameters); + dynamicSecurityAnalysisService.updateParameters(studyDSAParametersId, dsaParametersToUse); } return userProfileIssue; @@ -3248,30 +3310,32 @@ public boolean setSensitivityAnalysisParameters(UUID studyUuid, String parameter return userProfileIssue; } - public boolean createOrUpdateSensitivityAnalysisParameters(StudyEntity studyEntity, String parameters, String userId) { + public boolean createOrUpdateSensitivityAnalysisParameters(StudyEntity studyEntity, String saParameters, String userId) { boolean userProfileIssue = false; - UUID existingSensitivityAnalysisParametersUuid = studyEntity.getSensitivityAnalysisParametersUuid(); - UserProfileInfos userProfileInfos = parameters == null ? userAdminService.getUserProfile(userId) : null; - if (parameters == null && userProfileInfos.getSensitivityAnalysisParameterId() != null) { - // reset case, with existing profile, having default sensitivity analysis params - try { - UUID sensitivityAnalysisParametersFromProfileUuid = sensitivityAnalysisService.duplicateSensitivityAnalysisParameters(userProfileInfos.getSensitivityAnalysisParameterId()); - studyEntity.setSensitivityAnalysisParametersUuid(sensitivityAnalysisParametersFromProfileUuid); - removeSensitivityAnalysisParameters(existingSensitivityAnalysisParametersUuid); - return userProfileIssue; - } catch (Exception e) { - userProfileIssue = true; - LOGGER.error(String.format("Could not duplicate sensitivity analysis parameters with id '%s' from user/profile '%s/%s'. Using default parameters", - userProfileInfos.getSensitivityAnalysisParameterId(), userId, userProfileInfos.getName()), e); - // in case of duplication error (ex: wrong/dangling uuid in the profile), move on with default params below + + UUID studySAParametersId = studyEntity.getSensitivityAnalysisParametersUuid(); + String saParametersToUse = saParameters; + + if (saParametersToUse == null) { + UserProfileInfos userProfileinfos = userAdminService.getUserProfile(userId); + UUID profileSAParamId = userProfileinfos != null ? userProfileinfos.getSensitivityAnalysisParameterId() : null; + + if (profileSAParamId != null) { + try { + saParametersToUse = sensitivityAnalysisService.getSensitivityAnalysisParameters(profileSAParamId); + } catch (Exception e) { + userProfileIssue = true; + LOGGER.error(String.format("Could not retrieve sensitivity analysis parameters with id '%s' from user/profile '%s/%s'. Using default parameters", + profileSAParamId, userId, userProfileinfos.getName()), e); + } } } - if (existingSensitivityAnalysisParametersUuid == null) { - existingSensitivityAnalysisParametersUuid = sensitivityAnalysisService.createSensitivityAnalysisParameters(parameters); - studyEntity.setSensitivityAnalysisParametersUuid(existingSensitivityAnalysisParametersUuid); + if (studySAParametersId == null) { + studySAParametersId = sensitivityAnalysisService.createSensitivityAnalysisParameters(saParametersToUse); + studyEntity.setSensitivityAnalysisParametersUuid(studySAParametersId); } else { - sensitivityAnalysisService.updateSensitivityAnalysisParameters(existingSensitivityAnalysisParametersUuid, parameters); + sensitivityAnalysisService.updateSensitivityAnalysisParameters(studySAParametersId, saParametersToUse); } return userProfileIssue; diff --git a/src/main/java/org/gridsuite/study/server/service/shortcircuit/ShortCircuitService.java b/src/main/java/org/gridsuite/study/server/service/shortcircuit/ShortCircuitService.java index 4e57b2fac2..bdc7cf091c 100644 --- a/src/main/java/org/gridsuite/study/server/service/shortcircuit/ShortCircuitService.java +++ b/src/main/java/org/gridsuite/study/server/service/shortcircuit/ShortCircuitService.java @@ -315,7 +315,7 @@ public UUID duplicateParameters(UUID parametersUuid) { .toUri(), new HttpEntity<>(headers), UUID.class); } - public void deleteShortcircuitParameters(UUID uuid) { + public void deleteShortCircuitParameters(UUID uuid) { Objects.requireNonNull(uuid); String path = UriComponentsBuilder.fromPath(DELIMITER + SHORT_CIRCUIT_API_VERSION + PARAMETERS_URI) .buildAndExpand(uuid) diff --git a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java index 5f12d496ea..4e4d4f1ca1 100644 --- a/src/test/java/org/gridsuite/study/server/LoadFlowTest.java +++ b/src/test/java/org/gridsuite/study/server/LoadFlowTest.java @@ -698,7 +698,7 @@ private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, Strin mockMvc.perform( post("/v1/studies/{studyUuid}/loadflow/parameters", studyNameUserIdUuid) .header("userId", userId) - .contentType(MediaType.ALL) + .contentType(MediaType.APPLICATION_JSON) .content(parameters)) .andExpect(status().is(status.value())); @@ -749,9 +749,9 @@ void testResetLoadFlowParametersUserHasInvalidParamsInProfile(final MockWebServe createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, "", INVALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.NO_CONTENT); var requests = TestUtils.getRequestsDone(3, server); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + INVALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + LOADFLOW_PARAMETERS_UUID_STRING))); // update existing with dft - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_LOADFLOW_INVALID_PARAMETERS_UUID_STRING))); // post duplicate ko + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + INVALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); // retrieve user profile infos ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_LOADFLOW_INVALID_PARAMETERS_UUID_STRING))); // retrieve user profile parameters ko + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + LOADFLOW_PARAMETERS_UUID_STRING))); // put update existing with dft } @Test @@ -760,11 +760,10 @@ void testResetLoadFlowParametersUserHasValidParamsInProfile(final MockWebServer UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, "", VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(5, server); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + LOADFLOW_PARAMETERS_UUID_STRING))); // 2 requests: 1 get for provider and then delete existing - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_LOADFLOW_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_LOADFLOW_DUPLICATED_PARAMETERS_UUID_STRING + "/provider"))); // patch duplicated params for provider + var requests = TestUtils.getRequestsDone(4, server); + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); // retrieve user profile infos ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_LOADFLOW_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + LOADFLOW_PARAMETERS_UUID_STRING))); // 2 requests: first: get existing study loadflow parameters to retrieve provider; second: put update existing with retrieved parameters from user profile } @Test @@ -773,9 +772,10 @@ void testResetLoadFlowParametersUserHasValidParamsInProfileButNoExistingLoadflow UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, "", VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(2, server); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_LOADFLOW_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + var requests = TestUtils.getRequestsDone(3, server); + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); // retrieve user profile ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_LOADFLOW_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters"))); // post create parameters ok using retrieved parameters } // the following testGetDefaultProviders tests are related to StudyTest::testGetDefaultProviders but with a user and different profile cases diff --git a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java index cc572325ff..0ad22c8ab2 100644 --- a/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SecurityAnalysisTest.java @@ -101,8 +101,8 @@ class SecurityAnalysisTest { private static final String CONTINGENCIES_JSON = "[{\"id\":\"l1\",\"elements\":[{\"id\":\"l1\",\"type\":\"BRANCH\"}]}]"; private static final String CONTINGENCIES_COUNT = "2"; - public static final String SECURITY_ANALYSIS_DEFAULT_PARAMETERS_JSON = "{\"lowVoltageAbsoluteThreshold\":0.0,\"lowVoltageProportionalThreshold\":0.0,\"highVoltageAbsoluteThreshold\":0.0,\"highVoltageProportionalThreshold\":0.0,\"flowProportionalThreshold\":0.1}"; - private static final String SECURITY_ANALYSIS_PROFILE_PARAMETERS_JSON = "{\"lowVoltageAbsoluteThreshold\":30.0,\"lowVoltageProportionalThreshold\":0.4,\"highVoltageAbsoluteThreshold\":0.0,\"highVoltageProportionalThreshold\":0.0,\"flowProportionalThreshold\":0.1}"; + public static final String SECURITY_ANALYSIS_DEFAULT_PARAMETERS_JSON = "{\"provider\":\"LF_PROVIDER\",\"lowVoltageAbsoluteThreshold\":0.0,\"lowVoltageProportionalThreshold\":0.0,\"highVoltageAbsoluteThreshold\":0.0,\"highVoltageProportionalThreshold\":0.0,\"flowProportionalThreshold\":0.1,\"limitReductions\":[]}"; + private static final String SECURITY_ANALYSIS_PROFILE_PARAMETERS_JSON = "{\"provider\":\"LF_PROVIDER\",\"lowVoltageAbsoluteThreshold\":30.0,\"lowVoltageProportionalThreshold\":0.4,\"highVoltageAbsoluteThreshold\":0.0,\"highVoltageProportionalThreshold\":0.0,\"flowProportionalThreshold\":0.1,\"limitReductions\":[]}"; private static final String NETWORK_UUID_STRING = "38400000-8cf0-11bd-b23e-10b96e4ef00d"; private static final String NETWORK_UUID_2_STRING = "11111111-aaaa-48be-be46-ef7b93331e32"; @@ -651,14 +651,12 @@ void testSecurityAnalysisParameters(final MockWebServer server) throws Exception assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/parameters/default"))); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/parameters/" + SECURITY_ANALYSIS_PARAMETERS_UUID))); - String mnBodyJson = objectWriter.writeValueAsString(SECURITY_ANALYSIS_DEFAULT_PARAMETERS_JSON); - //update the parameters mockMvc.perform( post("/v1/studies/{studyUuid}/security-analysis/parameters", studyNameUserIdUuid) .header("userId", "userId") .contentType(MediaType.APPLICATION_JSON) - .content(mnBodyJson)).andExpect( + .content(SECURITY_ANALYSIS_DEFAULT_PARAMETERS_JSON)).andExpect( status().isOk()); assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/parameters/" + SECURITY_ANALYSIS_PARAMETERS_UUID))); assertEquals(SECURITY_ANALYSIS_PARAMETERS_UUID, studyRepository.findById(studyNameUserIdUuid).orElseThrow().getSecurityAnalysisParametersUuid()); @@ -675,7 +673,7 @@ void testSecurityAnalysisParameters(final MockWebServer server) throws Exception post("/v1/studies/{studyUuid}/security-analysis/parameters", studyNameUserIdUuid) .header("userId", "userId") .contentType(MediaType.APPLICATION_JSON) - .content(mnBodyJson)).andExpect( + .content(SECURITY_ANALYSIS_DEFAULT_PARAMETERS_JSON)).andExpect( status().isOk()); assertEquals(UPDATE_TYPE_SECURITY_ANALYSIS_STATUS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); assertEquals(UPDATE_TYPE_COMPUTATION_PARAMETERS, output.receive(TIMEOUT, studyUpdateDestination).getHeaders().get(NotificationService.HEADER_UPDATE_TYPE)); @@ -689,13 +687,12 @@ void testCreateSecurityAnalysisParameters(final MockWebServer server) throws Exc UUID studyUuid = studyEntity.getId(); assertNotNull(studyUuid); assertNull(studyEntity.getSecurityAnalysisParametersUuid()); - String mnBodyJson = objectWriter.writeValueAsString(SECURITY_ANALYSIS_DEFAULT_PARAMETERS_JSON); //test update parameters without having already created parameters -> should call create instead of update mockMvc.perform(post("/v1/studies/{studyUuid}/security-analysis/parameters", studyUuid) .header("userId", "userId") .contentType(MediaType.APPLICATION_JSON) - .content(mnBodyJson)) + .content(SECURITY_ANALYSIS_DEFAULT_PARAMETERS_JSON)) .andExpect(status().isOk()); assertEquals(SECURITY_ANALYSIS_PARAMETERS_UUID, studyRepository.findById(studyUuid).orElseThrow().getSecurityAnalysisParametersUuid()); @@ -811,7 +808,7 @@ private void createOrUpdateParametersAndDoChecks(UUID studyNameUserIdUuid, Strin mockMvc.perform( post("/v1/studies/{studyUuid}/security-analysis/parameters", studyNameUserIdUuid) .header("userId", userId) - .contentType(MediaType.ALL) + .contentType(MediaType.APPLICATION_JSON) .content(parameters)) .andExpect(status().is(status.value())); @@ -855,7 +852,7 @@ void testResetSecurityAnalysisParametersUserHasInvalidParamsInProfile(final Mock var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + INVALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SECURITY_ANALYSIS_PARAMETERS_UUID_STRING))); // update existing with dft - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SECURITY_ANALYSIS_INVALID_PARAMETERS_UUID_STRING))); // post duplicate ko + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SECURITY_ANALYSIS_INVALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ko } @Test @@ -879,12 +876,12 @@ void testResetSecurityAnalysisParametersUserHasValidParamsInProfile(final MockWe createOrUpdateParametersAndDoChecks(studyUuid, "", VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(5, server); + var requests = TestUtils.getRequestsDone(6, server); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save.*contingencyListName=" + CONTINGENCY_LIST_NAME + "&receiver=.*nodeUuid.*"))); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/results/invalidate-status\\?resultUuid=.*"))); // result has been invalidated by params reset assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SECURITY_ANALYSIS_PARAMETERS_UUID_STRING))); // 2 requests: 1 get for provider and then delete existing - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SECURITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SECURITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // get retrieve existing user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SECURITY_ANALYSIS_PARAMETERS_UUID_STRING))); // 2 requests: first: get existing study security analysis parameters to retrieve provider; second: put update existing parameters with retrieved parameters from user profile } @Test @@ -893,8 +890,9 @@ void testResetSecurityAnalysisParametersUserHasValidParamsInProfileButNoExisting UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, "", VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(2, server); + var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SECURITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SECURITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters"))); // post create parameters using parameters retrieved from user profile } } diff --git a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java index ef4f551e79..838a02a1ea 100644 --- a/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java +++ b/src/test/java/org/gridsuite/study/server/SensitivityAnalysisTest.java @@ -803,8 +803,8 @@ void testResetSensitivityAnalysisParametersUserHasInvalidParamsInProfile(final M var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + INVALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SENSITIVITY_ANALYSIS_INVALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ko assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SENSITIVITY_ANALYSIS_PARAMETERS_UUID_STRING))); // update existing with dft - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SENSITIVITY_ANALYSIS_INVALID_PARAMETERS_UUID_STRING))); // post duplicate ko } @Test @@ -827,8 +827,8 @@ void testResetSensitivityAnalysisParametersUserHasValidParamsInProfile(final Moc assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?reportUuid=.*&reporterId=.*&reportType=SensitivityAnalysis¶metersUuid=.*&loadFlowParametersUuid=.*&variantId=" + VARIANT_ID + "&receiver=.*"))); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/results/invalidate-status\\?resultUuid=.*"))); // result has been invalidated by params reset assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SENSITIVITY_ANALYSIS_PARAMETERS_UUID_STRING))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SENSITIVITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SENSITIVITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SENSITIVITY_ANALYSIS_PARAMETERS_UUID_STRING))); // put update existing parameters with parameters retrieved from user profile } @Test @@ -837,8 +837,9 @@ void testResetSensitivityAnalysisParametersUserHasValidParamsInProfileButNoExist UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, "", VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(2, server); + var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SENSITIVITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SENSITIVITY_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters"))); // create parameters using retrieve parameters from user profile } } diff --git a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java index bcbfa495fa..fc24adf8bf 100644 --- a/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java +++ b/src/test/java/org/gridsuite/study/server/ShortCircuitTest.java @@ -840,8 +840,8 @@ void testResetShortCircuitAnalysisParametersUserHasInvalidParamsInProfile(final var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + INVALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID_STRING))); // update existing with dft - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SHORT_CIRCUIT_ANALYSIS_INVALID_PARAMETERS_UUID_STRING))); // post duplicate ko + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SHORT_CIRCUIT_ANALYSIS_INVALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ko + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID_STRING))); // put update existing with dft } @Test @@ -852,8 +852,8 @@ void testResetShortCircuitAnalysisParametersUserHasValidParamsInProfile(final Mo var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID_STRING))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SHORT_CIRCUIT_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SHORT_CIRCUIT_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + SHORT_CIRCUIT_ANALYSIS_PARAMETERS_UUID_STRING))); // put update existing with parameters from user profile } @Test @@ -862,9 +862,10 @@ void testResetShortCircuitAnalysisParametersUserHasValidParamsInProfileButNoExis UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, "", VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(2, server); + var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_SHORT_CIRCUIT_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_SHORT_CIRCUIT_ANALYSIS_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters"))); // post create parameters using retrieved user profile parameters } private StudyEntity insertDummyStudy(UUID networkUuid, UUID caseUuid, UUID shortCircuitParametersUuid) { diff --git a/src/test/java/org/gridsuite/study/server/SpreadsheetConfigCollectionTest.java b/src/test/java/org/gridsuite/study/server/SpreadsheetConfigCollectionTest.java index 0ab77c20ae..d9664628c7 100644 --- a/src/test/java/org/gridsuite/study/server/SpreadsheetConfigCollectionTest.java +++ b/src/test/java/org/gridsuite/study/server/SpreadsheetConfigCollectionTest.java @@ -83,7 +83,7 @@ class SpreadsheetConfigCollectionTest { private static final String NO_PROFILE_USER_ID = "noProfileUser"; private static final String VALID_PROFILE_USER_ID = "validProfileUser"; - private static final String USER_PROFILE_VALID_PARAMS_JSON = "{\"id\":\"97bb1890-a90c-43c3-a004-e631246d42d6\",\"name\":\"Profile with valid params\",\"spreadsheetConfigCollectionId\":\"" + SPREADSHEET_CONFIG_COLLECTION_UUID_STRING + "\"}"; + private static final String USER_PROFILE_VALID_PARAMS_JSON = "{\"id\":\"97bb1890-a90c-43c3-a004-e631246d42d6\",\"name\":\"Profile with valid params\",\"spreadsheetConfigCollectionId\":\"" + NEW_SPREADSHEET_CONFIG_COLLECTION_UUID_STRING + "\"}"; // UUID for testing delete failure private static final String ERROR_DELETE_COLLECTION_UUID_STRING = "7715da48-3390-47cb-8d9a-f936c8ca6a71"; @@ -397,14 +397,13 @@ void testResetToDefaultWithUserProfile(final MockWebServer server) throws Except // Check that the study has been updated with the new collection from user profile StudyEntity updatedStudy = studyRepository.findById(studyUuid).orElseThrow(); - assertEquals(NEW_SPREADSHEET_CONFIG_COLLECTION_UUID, updatedStudy.getSpreadsheetConfigCollectionUuid()); + assertEquals(SPREADSHEET_CONFIG_COLLECTION_UUID, updatedStudy.getSpreadsheetConfigCollectionUuid()); // Keep existing spreadsheet config collection id // Verify HTTP requests made to the server - should duplicate from a profile collection var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/users/" + VALID_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/spreadsheet-config-collections\\?duplicateFrom=.*"))); - assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/spreadsheet-config-collections/" + SPREADSHEET_CONFIG_COLLECTION_UUID_STRING))); // delete old collection - + assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/spreadsheet-config-collections/" + NEW_SPREADSHEET_CONFIG_COLLECTION_UUID_STRING))); // get retrieve user profile config collection + assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/spreadsheet-config-collections/" + SPREADSHEET_CONFIG_COLLECTION_UUID_STRING))); // put update existing config collection with user profile config collection } @Test diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 0cbbc52144..20e48aa69f 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -1098,8 +1098,8 @@ void testResetVoltageInitParametersUserHasInvalidParamsInProfile(final MockWebSe var requests = TestUtils.getRequestsDone(4, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + INVALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_VOLTAGE_INIT_INVALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ko assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + VOLTAGE_INIT_PARAMETERS_UUID_STRING))); // get/update existing with dft - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_VOLTAGE_INIT_INVALID_PARAMETERS_UUID_STRING))); // post duplicate ko } @Test @@ -1118,12 +1118,12 @@ void testResetVoltageInitParametersUserHasValidParamsInProfile(final MockWebServ createOrUpdateParametersAndDoChecks(studyUuid, null, VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(5, server); + var requests = TestUtils.getRequestsDone(6, server); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&reportType=VoltageInit¶metersUuid=.*&variantId=variant_1&rootNetworkName=rootNetworkName&nodeName=.*"))); assertTrue(requests.stream().anyMatch(r -> r.matches("/v1/results/invalidate-status\\?resultUuid=.*"))); // result has been invalidated by params reset assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + VOLTAGE_INIT_PARAMETERS_UUID_STRING))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_VOLTAGE_INIT_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_VOLTAGE_INIT_VALID_PARAMETERS_UUID_STRING))); // 2 requests: first: get existing study voltage init parameters to check if current equals new parameters; second: put update existing with retrieved parameters from user profile } @Test @@ -1132,9 +1132,10 @@ void testResetVoltageInitParametersUserHasValidParamsInProfileButNoExistingVolta UUID studyNameUserIdUuid = studyEntity.getId(); createOrUpdateParametersAndDoChecks(studyNameUserIdUuid, null, VALID_PARAMS_IN_PROFILE_USER_ID, HttpStatus.OK); - var requests = TestUtils.getRequestsDone(2, server); + var requests = TestUtils.getRequestsDone(3, server); assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/users/" + VALID_PARAMS_IN_PROFILE_USER_ID + "/profile"))); - assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters?duplicateFrom=" + PROFILE_VOLTAGE_INIT_VALID_PARAMETERS_UUID_STRING))); // post duplicate ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters/" + PROFILE_VOLTAGE_INIT_VALID_PARAMETERS_UUID_STRING))); // get retrieve user profile parameters ok + assertTrue(requests.stream().anyMatch(r -> r.equals("/v1/parameters"))); // post create parameters using retrieved parameters ok } private StudyEntity insertDummyStudy(UUID networkUuid, UUID caseUuid, UUID voltageInitParametersUuid, boolean applyModifications) { diff --git a/src/test/java/org/gridsuite/study/server/studycontroller/StudyTest.java b/src/test/java/org/gridsuite/study/server/studycontroller/StudyTest.java index 485dbc8fa5..9c375cb86e 100644 --- a/src/test/java/org/gridsuite/study/server/studycontroller/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/studycontroller/StudyTest.java @@ -927,12 +927,13 @@ void testDeleteStudy(final MockWebServer server) throws Exception { wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid); - Set requests = TestUtils.getRequestsWithBodyDone(11, server); + Set requests = TestUtils.getRequestsWithBodyDone(12, server); assertEquals(2, requests.stream().filter(r -> r.getPath().matches("/v1/reports")).count()); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/reports"))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/cases/" + CASE_UUID))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/parameters/" + studyEntity.getVoltageInitParametersUuid()))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/parameters/" + studyEntity.getLoadFlowParametersUuid()))); + assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/parameters/" + studyEntity.getShortCircuitParametersUuid()))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/parameters/" + studyEntity.getSecurityAnalysisParametersUuid()))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/parameters/" + studyEntity.getSensitivityAnalysisParametersUuid()))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/parameters/" + studyEntity.getStateEstimationParametersUuid()))); @@ -949,6 +950,7 @@ void testDeleteStudyWithError(final MockWebServer server, final CapturedOutput c studyEntity.setLoadFlowParametersUuid(null); studyEntity.setSecurityAnalysisParametersUuid(null); studyEntity.setVoltageInitParametersUuid(null); + studyEntity.setShortCircuitParametersUuid(null); studyEntity.setSensitivityAnalysisParametersUuid(null); studyEntity.setStateEstimationParametersUuid(null); studyEntity.setPccMinParametersUuid(null); @@ -993,7 +995,7 @@ void testDeleteStudyWithNonExistingCase(final MockWebServer server) throws Excep wireMockStubs.verifyNetworkModificationDeleteGroup(stubUuid); - Set requests = TestUtils.getRequestsWithBodyDone(9, server); + Set requests = TestUtils.getRequestsWithBodyDone(10, server); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/reports"))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/cases/" + nonExistingCaseUuid))); assertTrue(requests.stream().anyMatch(r -> r.getPath().matches("/v1/parameters/.*"))); // x 4