Skip to content
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

[WIP] Add allResults parameter #423

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,9 @@ public ResponseEntity<String> getShortCircuitResult(@Parameter(description = "st
public ResponseEntity<String> getShortCircuitAnalysisFaultResultsPage(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Full or only those with limit violations or none fault results") @RequestParam(name = "mode", required = false, defaultValue = "WITH_LIMIT_VIOLATIONS") String mode,
@Parameter(description = "Fetch all results or paged results") @RequestParam(name = "allResults", required = false, defaultValue = "false") boolean allResults,
Pageable pageable) {
String faultResultsPage = shortCircuitService.getShortCircuitAnalysisFaultResultsPage(nodeUuid, mode, pageable);
String faultResultsPage = shortCircuitService.getShortCircuitAnalysisFaultResultsPage(nodeUuid, mode, allResults, pageable);
return faultResultsPage != null ? ResponseEntity.ok().body(faultResultsPage) :
ResponseEntity.noContent().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public String getShortCircuitAnalysisResult(UUID nodeUuid, String mode, Shortcir
return getShortCircuitAnalysisResource(resultPath + params);
}

public String getShortCircuitAnalysisFaultResultsPage(UUID nodeUuid, String mode, Pageable pageable) {
public String getShortCircuitAnalysisFaultResultsPage(UUID nodeUuid, String mode, boolean allResults, Pageable pageable) {
StringBuilder paramsBuilder = new StringBuilder();
paramsBuilder.append("?mode=" + mode + "&page=" + pageable.getPageNumber() + "&size=" + pageable.getPageSize());
paramsBuilder.append("?mode=" + mode + "&allResults=" + allResults + "&page=" + pageable.getPageNumber() + "&size=" + pageable.getPageSize());

for (Sort.Order order : pageable.getSort()) {
paramsBuilder.append("&sort=" + order.getProperty() + "," + order.getDirection());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public MockResponse dispatch(RecordedRequest request) {
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "\\?mode=WITH_LIMIT_VIOLATIONS")) {
return new MockResponse().setResponseCode(200).setBody(SHORT_CIRCUIT_ANALYSIS_RESULT_JSON)
.addHeader("Content-Type", "application/json; charset=utf-8");
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged" + "\\?mode=WITH_LIMIT_VIOLATIONS&page=0&size=20&sort=id,DESC")) {
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged" + "\\?mode=WITH_LIMIT_VIOLATIONS&allResults=false&page=0&size=20&sort=id,DESC")) {
return new MockResponse().setResponseCode(200).setBody(SHORT_CIRCUIT_ANALYSIS_RESULT_JSON)
.addHeader("Content-Type", "application/json; charset=utf-8");
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/status")) {
Expand Down Expand Up @@ -373,7 +373,7 @@ public void testPagedShortCircuit() throws Exception {
status().isOk(),
content().string(SHORT_CIRCUIT_ANALYSIS_RESULT_JSON));

assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged\\?mode=WITH_LIMIT_VIOLATIONS&page=0&size=20&sort=id,DESC")));
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged\\?mode=WITH_LIMIT_VIOLATIONS&allResults=false&page=0&size=20&sort=id,DESC")));

// get short circuit result with pagination but with unknown node
mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/results/fault_results/paged?page=0&size=20", studyNameUserIdUuid, unknownModificationNodeUuid)).andExpect(
Expand Down