|
57 | 57 |
|
58 | 58 | import java.util.*; |
59 | 59 |
|
60 | | -import static org.gridsuite.study.server.StudyConstants.HEADER_RECEIVER; |
61 | | -import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID; |
| 60 | +import static org.gridsuite.study.server.StudyConstants.*; |
62 | 61 | import static org.gridsuite.study.server.notification.NotificationService.HEADER_UPDATE_TYPE; |
63 | 62 | import static org.gridsuite.study.server.notification.NotificationService.UPDATE_TYPE_COMPUTATION_PARAMETERS; |
64 | 63 | import static org.gridsuite.study.server.utils.TestUtils.getBinaryAsBuffer; |
@@ -165,6 +164,7 @@ class ShortCircuitTest implements WithAssertions { |
165 | 164 | //output destinations |
166 | 165 | private final String studyUpdateDestination = "study.update"; |
167 | 166 | private final String elementUpdateDestination = "element.update"; |
| 167 | + private final String shortCircuitAnalysisDebugDestination = "shortcircuitanalysis.debug"; |
168 | 168 | private final String shortCircuitAnalysisResultDestination = "shortcircuitanalysis.result"; |
169 | 169 | private final String shortCircuitAnalysisStoppedDestination = "shortcircuitanalysis.stopped"; |
170 | 170 | private final String shortCircuitAnalysisFailedDestination = "shortcircuitanalysis.run.dlx"; |
@@ -196,14 +196,40 @@ public MockResponse dispatch(RecordedRequest request) { |
196 | 196 | String path = Objects.requireNonNull(request.getPath()); |
197 | 197 | String method = Objects.requireNonNull(request.getMethod()); |
198 | 198 |
|
199 | | - if (path.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&busId=BUS_TEST_ID&variantId=" + VARIANT_ID_2)) { |
| 199 | + if (path.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&busId=BUS_TEST_ID&variantId=" + VARIANT_ID_2 + "&debug=.*")) { |
| 200 | + String receiver = "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%20%22rootNetworkUuid%22%3A%20%22" + request.getPath().split("%")[11].substring(4) + "%22%2C%20%22userId%22%3A%22userId%22%7D"; |
| 201 | + input.send(MessageBuilder.withPayload("") |
| 202 | + .setHeader("resultUuid", SHORT_CIRCUIT_ANALYSIS_RESULT_UUID) |
| 203 | + .setHeader("receiver", "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%20%22rootNetworkUuid%22%3A%20%22" + request.getPath().split("%")[11].substring(4) + "%22%2C%20%22userId%22%3A%22userId%22%7D") |
| 204 | + .setHeader("busId", "BUS_TEST_ID") |
| 205 | + .build(), shortCircuitAnalysisResultDestination); |
| 206 | + // mock the notification from shortcircuit-server to send a debug status notif |
| 207 | + input.send(MessageBuilder.withPayload("") |
| 208 | + .setHeader("resultUuid", SHORT_CIRCUIT_ANALYSIS_RESULT_UUID) |
| 209 | + .setHeader("receiver", receiver) |
| 210 | + .setHeader("busId", "BUS_TEST_ID") |
| 211 | + .build(), shortCircuitAnalysisDebugDestination); |
| 212 | + return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), shortCircuitAnalysisResultUuidStr); |
| 213 | + } else if (path.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&busId=BUS_TEST_ID&variantId=" + VARIANT_ID_2)) { |
200 | 214 | input.send(MessageBuilder.withPayload("") |
201 | 215 | .setHeader("resultUuid", SHORT_CIRCUIT_ANALYSIS_RESULT_UUID) |
202 | 216 | .setHeader("receiver", "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%20%22rootNetworkUuid%22%3A%20%22" + request.getPath().split("%")[11].substring(4) + "%22%2C%20%22userId%22%3A%22userId%22%7D") |
203 | 217 | .setHeader("busId", "BUS_TEST_ID") |
204 | 218 | .build(), shortCircuitAnalysisResultDestination); |
205 | 219 | return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), shortCircuitAnalysisResultUuidStr); |
206 | | - } else if (path.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2 + ".*")) { |
| 220 | + } else if (path.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2 + "&debug=.*")) { |
| 221 | + String receiver = "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%20%22rootNetworkUuid%22%3A%20%22" + request.getPath().split("%")[11].substring(4) + "%22%2C%20%22userId%22%3A%22userId%22%7D"; |
| 222 | + input.send(MessageBuilder.withPayload("") |
| 223 | + .setHeader("resultUuid", SHORT_CIRCUIT_ANALYSIS_RESULT_UUID) |
| 224 | + .setHeader("receiver", receiver) |
| 225 | + .build(), shortCircuitAnalysisResultDestination); |
| 226 | + // mock the notification from shortcircuit-server to send a debug status notif |
| 227 | + input.send(MessageBuilder.withPayload("") |
| 228 | + .setHeader("resultUuid", SHORT_CIRCUIT_ANALYSIS_RESULT_UUID) |
| 229 | + .setHeader("receiver", receiver) |
| 230 | + .build(), shortCircuitAnalysisDebugDestination); |
| 231 | + return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), shortCircuitAnalysisResultUuidStr); |
| 232 | + } else if (path.matches("/v1/networks/" + NETWORK_UUID_STRING + "/run-and-save\\?receiver=.*&reportUuid=.*&reporterId=.*&variantId=" + VARIANT_ID_2)) { |
207 | 233 | input.send(MessageBuilder.withPayload("") |
208 | 234 | .setHeader("resultUuid", SHORT_CIRCUIT_ANALYSIS_RESULT_UUID) |
209 | 235 | .setHeader("receiver", "%7B%22nodeUuid%22%3A%22" + request.getPath().split("%")[5].substring(4) + "%22%2C%20%22rootNetworkUuid%22%3A%20%22" + request.getPath().split("%")[11].substring(4) + "%22%2C%20%22userId%22%3A%22userId%22%7D") |
@@ -340,16 +366,18 @@ void testAllBusesShortCircuit(final MockWebServer server) throws Exception { |
340 | 366 | .header("userId", "userId")) |
341 | 367 | .andExpect(status().isForbidden()); |
342 | 368 |
|
343 | | - //run an all-buses short circuit analysis |
| 369 | + //run in debug mode an all-buses short circuit analysis |
344 | 370 | mockMvc.perform(put("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode3Uuid) |
345 | | - .param("debug", "true") |
| 371 | + .param(QUERY_PARAM_DEBUG, "true") |
346 | 372 | .header("userId", "userId")) |
347 | 373 | .andExpect(status().isOk()); |
348 | 374 |
|
349 | 375 | checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); |
350 | 376 |
|
351 | 377 | checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_RESULT); |
352 | 378 |
|
| 379 | + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.COMPUTATION_DEBUG_FILE_STATUS); |
| 380 | + |
353 | 381 | checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_SHORT_CIRCUIT_STATUS); |
354 | 382 |
|
355 | 383 | 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 + "&debug=true"))); |
@@ -557,19 +585,22 @@ void testOneBusShortCircuit(final MockWebServer server) throws Exception { |
557 | 585 | .header("userId", "userId")) |
558 | 586 | .andExpect(status().isForbidden()); |
559 | 587 |
|
560 | | - //run a one bus short circuit analysis |
| 588 | + //run in debug mode a one bus short circuit analysis |
561 | 589 | mockMvc.perform(put("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/shortcircuit/run", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode3Uuid) |
562 | 590 | .param("busId", "BUS_TEST_ID") |
| 591 | + .param(QUERY_PARAM_DEBUG, "true") |
563 | 592 | .header("userId", "userId")) |
564 | 593 | .andExpect(status().isOk()); |
565 | 594 |
|
566 | 595 | checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); |
567 | 596 |
|
568 | 597 | checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_RESULT); |
569 | 598 |
|
| 599 | + checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.COMPUTATION_DEBUG_FILE_STATUS); |
| 600 | + |
570 | 601 | checkUpdateModelStatusMessagesReceived(studyNameUserIdUuid, NotificationService.UPDATE_TYPE_ONE_BUS_SHORT_CIRCUIT_STATUS); |
571 | 602 |
|
572 | | - 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))); |
| 603 | + 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 + "&debug=true"))); |
573 | 604 |
|
574 | 605 | assertEquals(1, rootNetworkNodeInfoRepository.findAllByOneBusShortCircuitAnalysisResultUuidNotNull().size()); |
575 | 606 |
|
|
0 commit comments