Skip to content

Commit

Permalink
Contingency list update function also update description (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: basseche <[email protected]>
  • Loading branch information
basseche authored Jan 17, 2025
1 parent 3484faa commit 6707762
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ public ResponseEntity<Void> changeFilter(@PathVariable UUID id, @RequestBody Str
public ResponseEntity<Void> updateContingencyList(
@PathVariable UUID id,
@RequestParam(name = "name") String name,
@RequestParam(name = QUERY_PARAM_DESCRIPTION) String description,
@RequestParam(name = "contingencyListType") ContingencyListType contingencyListType,
@RequestBody String content,
@RequestHeader(QUERY_PARAM_USER_ID) String userId) {

exploreService.updateContingencyList(id, content, userId, name, contingencyListType);
exploreService.updateContingencyList(id, content, userId, name, description, contingencyListType);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,14 @@ public void updateFilter(UUID id, String filter, String userId, String name, Str
directoryService.updateElement(id, elementAttributes, userId);
}

public void updateContingencyList(UUID id, String content, String userId, String name, ContingencyListType contingencyListType) {
public void updateContingencyList(UUID id, String content, String userId, String name, String description, ContingencyListType contingencyListType) {
contingencyListService.updateContingencyList(id, content, userId, getProperPath(contingencyListType));
updateElementName(id, name, userId);
ElementAttributes elementAttributes = new ElementAttributes();
elementAttributes.setDescription(description);
if (StringUtils.isNotBlank(name)) {
elementAttributes.setElementName(name);
}
directoryService.updateElement(id, elementAttributes, userId);
}

public void updateCompositeModification(UUID id, String userId, String name) {
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/gridsuite/explore/server/ExploreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,13 @@ void testChangeFilter(final MockWebServer server) throws Exception {
void testModifyScriptContingencyList(final MockWebServer server) throws Exception {
final String scriptContingency = "{\"script\":\"alert(\\\"script contingency\\\")\"}";
final String name = "script name";
final String description = "description";
mockMvc.perform(put("/v1/explore/contingency-lists/{id}",
SCRIPT_ID_BASE_FORM_CONTINGENCY_LIST_UUID)
.contentType(APPLICATION_JSON)
.content(scriptContingency)
.param("name", name)
.param("description", description)
.param("contingencyListType", ContingencyListType.SCRIPT.name())
.header("userId", USER1)
).andExpect(status().isOk());
Expand All @@ -722,11 +724,13 @@ void testModifyScriptContingencyList(final MockWebServer server) throws Exceptio
void testModifyFormContingencyList(final MockWebServer server) throws Exception {
final String formContingency = "{\"equipmentType\":\"LINE\",\"name\":\"contingency EN update1\",\"countries1\":[\"AL\"],\"countries2\":[],\"nominalVoltage1\":{\"type\":\"EQUALITY\",\"value1\":45340,\"value2\":null},\"nominalVoltage2\":null,\"freeProperties1\":{},\"freeProperties2\":{}}";
final String name = "form contingency name";
final String description = "form contingency description";
mockMvc.perform(put("/v1/explore/contingency-lists/{id}",
SCRIPT_ID_BASE_FORM_CONTINGENCY_LIST_UUID)
.contentType(APPLICATION_JSON)
.content(formContingency)
.param("name", name)
.param("description", description)
.param("contingencyListType", ContingencyListType.FORM.name())
.header("userId", USER1)
).andExpect(status().isOk());
Expand All @@ -738,12 +742,14 @@ void testModifyFormContingencyList(final MockWebServer server) throws Exception
void testModifyIdentifierContingencyList(final MockWebServer server) throws Exception {
final String identifierContingencyList = "{\"identifierContingencyList\":{\"type\":\"identifier\",\"version\":\"1.0\",\"identifiableType\":\"LINE\",\"identifiers\":[{\"type\":\"LIST\",\"identifierList\":[{\"type\":\"ID_BASED\",\"identifier\":\"34\"},{\"type\":\"ID_BASED\",\"identifier\":\"qs\"}]}]},\"type\":\"IDENTIFIERS\"}";
final String name = "identifier contingencyList name";
final String description = "identifier contingencyList description";
mockMvc.perform(put("/v1/explore/contingency-lists/{id}",
SCRIPT_ID_BASE_FORM_CONTINGENCY_LIST_UUID)
.contentType(APPLICATION_JSON)
.content(identifierContingencyList)
.param("name", name)
.param("contingencyListType", ContingencyListType.IDENTIFIERS.name())
.param("description", description)
.header("userId", USER1)
).andExpect(status().isOk());

Expand Down

0 comments on commit 6707762

Please sign in to comment.