-
Notifications
You must be signed in to change notification settings - Fork 2
Handle and get dynamically enum filter #544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b0f841c
optimize-contingency-count-endpoint
ghazwarhili 5532de5
handle and get enum filter
ghazwarhili 7b15498
Merge branch 'main' into handle-and-get-dynamically-enum-filter
ghazwarhili da0846e
Revert "optimize-contingency-count-endpoint"
ghazwarhili 306b577
Merge remote-tracking branch 'origin/handle-and-get-dynamically-enum-…
ghazwarhili 84fc80e
Merge branch 'main' into handle-and-get-dynamically-enum-filter
ghazwarhili 031bda3
refacto to use one endpoint to get filters enum values
ghazwarhili 5359304
coverage test
ghazwarhili 7922cc9
Merge branch 'main' into handle-and-get-dynamically-enum-filter
ghazwarhili 15159a4
delete unused import
ghazwarhili bf7fdfa
refacto and fix test
ghazwarhili bbd82f3
refacto and renaming
ghazwarhili 01c82dd
Merge branch 'main' into handle-and-get-dynamically-enum-filter
ghazwarhili 71ee152
enhance converage test
ghazwarhili 94928ec
Merge remote-tracking branch 'origin/handle-and-get-dynamically-enum-…
ghazwarhili b8a33e6
code review remarqs
ghazwarhili File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/org/gridsuite/study/server/service/common/AbstractComputationService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.gridsuite.study.server.service.common; | ||
|
||
import org.gridsuite.study.server.StudyException; | ||
import org.springframework.core.ParameterizedTypeReference; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.client.HttpStatusCodeException; | ||
import org.springframework.web.client.RestTemplate; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import static org.gridsuite.study.server.StudyConstants.DELIMITER; | ||
|
||
public abstract class AbstractComputationService { | ||
|
||
public abstract List<String> getEnumValues(String enumName, UUID resultUuidOpt); | ||
|
||
public List<String> getEnumValues(String enumName, UUID resultUuid, String apiVersion, String computingTypeBaseUri, StudyException.Type type, RestTemplate restTemplate) { | ||
List<String> result; | ||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath(DELIMITER + apiVersion + "/results/{resultUuid}/{enumName}"); | ||
String path = uriComponentsBuilder.buildAndExpand(resultUuid, enumName).toUriString(); | ||
try { | ||
ResponseEntity<List<String>> responseEntity = restTemplate.exchange(computingTypeBaseUri + path, HttpMethod.GET, null, new ParameterizedTypeReference<>() { }); | ||
result = responseEntity.getBody(); | ||
} catch (HttpStatusCodeException e) { | ||
if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) { | ||
throw new StudyException(type); | ||
} | ||
throw e; | ||
} | ||
return result; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,8 @@ public class LoadFlowTest { | |
|
||
private static String LIMIT_VIOLATIONS_JSON; | ||
|
||
private static String COMPUTING_STATUS_JSON; | ||
|
||
private static String LOADFLOW_DEFAULT_PARAMETERS_JSON; | ||
|
||
//output destinations | ||
|
@@ -214,6 +216,7 @@ public void setup() throws IOException { | |
.limitType(LimitViolationType.HIGH_VOLTAGE) | ||
.build()); | ||
LIMIT_VIOLATIONS_JSON = objectMapper.writeValueAsString(limitViolations); | ||
COMPUTING_STATUS_JSON = objectMapper.writeValueAsString(List.of("CONVERGED", "FAILED")); | ||
|
||
LoadFlowParametersInfos loadFlowParametersInfos = LoadFlowParametersInfos.builder() | ||
.provider(PROVIDER) | ||
|
@@ -260,6 +263,11 @@ public MockResponse dispatch(RecordedRequest request) { | |
} else if (path.matches("/v1/results/" + LOADFLOW_RESULT_UUID + "/limit-violations\\?filters=.*globalFilters=.*networkUuid=.*variantId.*sort=.*")) { | ||
return new MockResponse().setResponseCode(200).setBody(LIMIT_VIOLATIONS_JSON) | ||
.addHeader("Content-Type", "application/json; charset=utf-8"); | ||
} else if (path.matches("/v1/results/" + LOADFLOW_RESULT_UUID + "/computation-status")) { | ||
return new MockResponse().setResponseCode(200).setBody(COMPUTING_STATUS_JSON) | ||
.addHeader("Content-Type", "application/json; charset=utf-8"); | ||
} else if (path.matches("/v1/results/" + LOADFLOW_RESULT_UUID + "/computation")) { | ||
return new MockResponse().setResponseCode(404); | ||
} else if (path.matches("/v1/results/invalidate-status\\?resultUuid=" + LOADFLOW_RESULT_UUID)) { | ||
return new MockResponse().setResponseCode(200) | ||
.addHeader("Content-Type", "application/json; charset=utf-8"); | ||
|
@@ -412,6 +420,19 @@ public void testGetLimitViolations() throws Exception { | |
checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); | ||
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2 + "&limitReduction=0.7"))); | ||
|
||
// get computing status | ||
mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/computation/result/enum-values?computingType={computingType}&enumName={enumName}", | ||
studyNameUserIdUuid, modificationNode1Uuid, LOAD_FLOW, "computation-status")) | ||
.andExpectAll(status().isOk(), | ||
content().string(COMPUTING_STATUS_JSON)); | ||
|
||
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + LOADFLOW_RESULT_UUID + "/computation-status"))); | ||
|
||
mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/computation/result/enum-values?computingType={computingType}&enumName={enumName}", | ||
studyNameUserIdUuid, modificationNode1Uuid, LOAD_FLOW, "computation")).andReturn(); | ||
|
||
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + LOADFLOW_RESULT_UUID + "/computation"))); | ||
|
||
Comment on lines
+423
to
+435
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These tests are not about limit violations. They shouldn't be in a |
||
// get limit violations | ||
mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/limit-violations", studyNameUserIdUuid, modificationNode1Uuid)).andExpectAll( | ||
status().isOk(), | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.