@@ -314,6 +314,8 @@ public MockResponse dispatch(RecordedRequest request) {
314
314
return new MockResponse (200 );
315
315
} else if (path .matches ("/v1/identifier-contingency-lists/.*" ) && "PUT" .equals (request .getMethod ())) {
316
316
return new MockResponse (200 );
317
+ } else if (path .matches ("/v1/filters-contingency-lists/.*" ) && "PUT" .equals (request .getMethod ())) {
318
+ return new MockResponse (200 );
317
319
} else if (path .matches ("/v1/parameters\\ ?duplicateFrom=" + PARAMETERS_UUID ) && "POST" .equals (request .getMethod ())) {
318
320
return new MockResponse (200 , Headers .of (HttpHeaders .CONTENT_TYPE , MediaType .APPLICATION_JSON_VALUE ), newParametersUuidAsString );
319
321
} else if (path .matches ("/v1/parameters.*" )) {
@@ -526,6 +528,16 @@ void testCreateIdentifierContingencyList() throws Exception {
526
528
).andExpect (status ().isOk ());
527
529
}
528
530
531
+ @ Test
532
+ void testCreateFilterBasedContingencyList () throws Exception {
533
+ mockMvc .perform (post ("/v1/explore/filters-contingency-lists/{listName}?parentDirectoryUuid={parentDirectoryUuid}&description={description}" ,
534
+ "filterBasedContingencyListName" , PARENT_DIRECTORY_UUID , null )
535
+ .header ("userId" , USER1 )
536
+ .contentType (MediaType .APPLICATION_JSON )
537
+ .content ("\" Contingency list content\" " )
538
+ ).andExpect (status ().isOk ());
539
+ }
540
+
529
541
@ Test
530
542
void testCreateFilter () throws Exception {
531
543
mockMvc .perform (post ("/v1/explore/filters?name={name}&type={type}&parentDirectoryUuid={parentDirectoryUuid}&description={description}" ,
@@ -726,6 +738,26 @@ void testDuplicateIdentifierContingencyListInSameDirectory(final MockWebServer m
726
738
checkAuthorizationRequestDoneForDuplication (mockWebServer , CONTINGENCY_LIST_UUID , CONTINGENCY_LIST_UUID );
727
739
}
728
740
741
+ @ Test
742
+ void testDuplicateFilterBasedContingencyList (final MockWebServer mockWebServer ) throws Exception {
743
+ mockMvc .perform (post ("/v1/explore/contingency-lists?duplicateFrom={contingencyListUuid}&type={contingencyListsType}&parentDirectoryUuid={parentDirectoryUuid}" ,
744
+ CONTINGENCY_LIST_UUID , ContingencyListType .FILTERS , PARENT_DIRECTORY_UUID )
745
+ .header ("userId" , USER1 )
746
+ ).andExpect (status ().isOk ());
747
+
748
+ checkAuthorizationRequestDoneForDuplication (mockWebServer , CONTINGENCY_LIST_UUID , PARENT_DIRECTORY_UUID );
749
+ }
750
+
751
+ @ Test
752
+ void testDuplicateFilterBasedContingencyListInSameDirectory (final MockWebServer mockWebServer ) throws Exception {
753
+ mockMvc .perform (post ("/v1/explore/contingency-lists?duplicateFrom={contingencyListUuid}&type={contingencyListsType}" ,
754
+ CONTINGENCY_LIST_UUID , ContingencyListType .FILTERS )
755
+ .header ("userId" , USER1 )
756
+ ).andExpect (status ().isOk ());
757
+
758
+ checkAuthorizationRequestDoneForDuplication (mockWebServer , CONTINGENCY_LIST_UUID , CONTINGENCY_LIST_UUID );
759
+ }
760
+
729
761
@ Test
730
762
void testDuplicateStudy (final MockWebServer mockWebServer ) throws Exception {
731
763
mockMvc .perform (post ("/v1/explore/studies?duplicateFrom={studyUuid}&parentDirectoryUuid={parentDirectoryUuid}" ,
@@ -840,6 +872,24 @@ void testModifyIdentifierContingencyList(final MockWebServer server) throws Exce
840
872
verifyFilterOrContingencyUpdateRequests (server , "/v1/identifier-contingency-lists/" , USER1 );
841
873
}
842
874
875
+ @ Test
876
+ void testModifyFilterContingencyList (final MockWebServer server ) throws Exception {
877
+ final String filters = "{\" filters\" :[{\" id\" :\" uuid1\" ,\" name\" :\" TD_Sensi\" ,\" equipmentType\" :\" TWO_WINDINGS_TRANSFORMER\" },{\" id\" :\" uuid2\" ,\" name\" :\" Ligne ARGIA\" ,\" equipmentType\" :\" LINE\" }]}" ;
878
+ final String name = "filter based contingencyList name" ;
879
+ final String description = "filter based contingencyList description" ;
880
+ mockMvc .perform (put ("/v1/explore/contingency-lists/{id}" ,
881
+ SCRIPT_ID_BASE_FORM_CONTINGENCY_LIST_UUID )
882
+ .contentType (APPLICATION_JSON )
883
+ .content (filters )
884
+ .param ("name" , name )
885
+ .param ("contingencyListType" , ContingencyListType .FILTERS .name ())
886
+ .param ("description" , description )
887
+ .header ("userId" , USER1 )
888
+ ).andExpect (status ().isOk ());
889
+
890
+ verifyFilterOrContingencyUpdateRequests (server , "/v1/filters-contingency-lists/" , USER1 );
891
+ }
892
+
843
893
private void verifyFilterOrContingencyUpdateRequests (final MockWebServer server , String contingencyOrFilterPath , String user ) {
844
894
var requests = TestUtils .getRequestsWithBodyDone (3 , server );
845
895
assertTrue (requests .stream ().anyMatch (r -> r .getPath ().contains (contingencyOrFilterPath )), "elementAttributes updated" );
0 commit comments