55package org .lfenergy .compas .sct .commons ;
66
77import org .assertj .core .api .SoftAssertions ;
8- import org .assertj .core .groups .Tuple ;
98import org .junit .jupiter .api .BeforeEach ;
109import org .junit .jupiter .api .Tag ;
1110import org .junit .jupiter .api .Test ;
2019import org .lfenergy .compas .sct .commons .scl .SclRootAdapter ;
2120import org .lfenergy .compas .sct .commons .scl .ln .AbstractLNAdapter ;
2221import org .lfenergy .compas .sct .commons .testhelpers .SclTestMarshaller ;
22+ import org .lfenergy .compas .sct .commons .util .PrivateEnum ;
2323
2424import java .util .List ;
2525import java .util .Optional ;
@@ -37,7 +37,7 @@ class ExtRefEditorServiceTest {
3737
3838 @ BeforeEach
3939 void init () {
40- extRefEditorService = new ExtRefEditorService (new IedService (), new LdeviceService (new LnService ()), new LnService (), new DataTypeTemplatesService () );
40+ extRefEditorService = new ExtRefEditorService (new IedService (), new LdeviceService (new LnService ()), new LnService ());
4141 }
4242
4343 @ Test
@@ -327,111 +327,6 @@ void manageBindingForLDEPF_when_extRefMatchFlowKindInternalOrExternal_should_upd
327327 assertExtRefIsBoundAccordingTOLDEPF (extRefBindExternally , analogueChannel10WithBayExternalBayScope );
328328 }
329329
330- @ Test
331- void manageBindingForLDEPF_when_DOI_Mod_and_DAI_stVal_notExists_should_precede () {
332- // Given
333- SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-ldepf/scd_ldepf_withoutModStValInLN0.xml" );
334- // When
335- TChannel channel = new TChannel ();
336- channel .setBayScope (TCBScopeType .BAY_INTERNAL );
337- channel .setChannelType (TChannelType .DIGITAL );
338- channel .setChannelNum ("1" );
339- channel .setChannelShortLabel ("MR.PX1" );
340- channel .setChannelLevMod (TChannelLevMod .POSITIVE_OR_RISING );
341- channel .setChannelLevModQ (TChannelLevMod .OTHER );
342- channel .setIEDType ("BCU" );
343- channel .setIEDRedundancy (TIEDredundancy .NONE );
344- channel .setIEDSystemVersionInstance ("1" );
345- channel .setLDInst ("LDPX" );
346- channel .setLNClass ("PTRC" );
347- channel .setLNInst ("0" );
348- channel .setDOName ("Str" );
349- channel .setDOInst ("0" );
350- channel .setDAName ("general" );
351-
352- EPF epf = new EPF ();
353- Channels channels = new Channels ();
354- channels .getChannel ().add (channel );
355- epf .setChannels (channels );
356- List <SclReportItem > sclReportItems = extRefEditorService .manageBindingForLDEPF (scd , epf );
357- // Then
358- assertThat (sclReportItems ).isEmpty ();
359- TExtRef extRef1 = findExtRef (scd , "IED_NAME1" , "LDEPF" , "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1" );
360- assertThat (extRef1 .getIedName ()).isEqualTo ("IED_NAME1" );
361- TExtRef extRef2 = findExtRef (scd , "IED_NAME2" , "LDEPF" , "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1" );
362- assertThat (extRef2 .getIedName ()).isEqualTo ("IED_NAME2" );
363- TExtRef extRef3 = findExtRef (scd , "IED_NAME3" , "LDEPF" , "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1" );
364- assertThat (extRef3 .getIedName ()).isEqualTo ("IED_NAME1" );
365-
366- assertExtRefIsBoundAccordingTOLDEPF (extRef1 , channel );
367- assertExtRefIsBoundAccordingTOLDEPF (extRef2 , channel );
368- assertExtRefIsBoundAccordingTOLDEPF (extRef3 , channel );
369- }
370-
371- @ Test
372- void manageBindingForLDEPF_when_LDEPF_NotActive_should_precede () {
373- //Given
374- SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-ldepf/scd_with_inactive_ldevice_ldepf.xml" );
375- TChannel channel = new TChannel ();
376- channel .setBayScope (TCBScopeType .BAY_INTERNAL );
377- channel .setChannelType (TChannelType .DIGITAL );
378- channel .setChannelNum ("1" );
379- channel .setChannelShortLabel ("MR.PX1" );
380- channel .setChannelLevMod (TChannelLevMod .POSITIVE_OR_RISING );
381- channel .setChannelLevModQ (TChannelLevMod .OTHER );
382- channel .setIEDType ("BCU" );
383- channel .setIEDRedundancy (TIEDredundancy .NONE );
384- channel .setIEDSystemVersionInstance ("1" );
385- channel .setLDInst ("LDPX" );
386- channel .setLNClass ("PTRC" );
387- channel .setLNInst ("0" );
388- channel .setDOName ("Str" );
389- channel .setDOInst ("0" );
390- channel .setDAName ("general" );
391-
392- EPF epf = new EPF ();
393- Channels channels = new Channels ();
394- channels .getChannel ().add (channel );
395- epf .setChannels (channels );
396- // When
397- List <SclReportItem > sclReportItems = extRefEditorService .manageBindingForLDEPF (scd , epf );
398- // Then
399- assertThat (sclReportItems ).isEmpty ();
400- TExtRef extRef1 = findExtRef (scd , "IED_NAME1" , "LDEPF" , "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1" );
401- assertThat (extRef1 .getIedName ()).isEqualTo ("IED_NAME1" );
402- TExtRef extRef2 = findExtRef (scd , "IED_NAME2" , "LDEPF" , "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1" );
403- assertThat (extRef2 .getIedName ()).isEqualTo ("IED_NAME2" );
404- TExtRef extRef3 = findExtRef (scd , "IED_NAME3" , "LDEPF" , "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEAN_1_general_1" );
405- assertThat (extRef3 .getIedName ()).isEqualTo ("IED_NAME1" );
406-
407- assertExtRefIsBoundAccordingTOLDEPF (extRef1 , channel );
408- assertExtRefIsBoundAccordingTOLDEPF (extRef2 , channel );
409- assertExtRefIsBoundAccordingTOLDEPF (extRef3 , channel );
410- }
411-
412- @ Test
413- void manageBindingForLDEPF_when_DO_Mod_and_DA_stVal_NotFoundInDataTypeTemplate_should_return_error () {
414- // Given
415- SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-ldepf/scd_ldepf_withoutModStValInDataTypeTemplate.xml" );
416- // When
417- EPF epf = new EPF ();
418- epf .setChannels (new Channels ());
419- List <SclReportItem > sclReportItems = extRefEditorService .manageBindingForLDEPF (scd , epf );
420- // Then
421- assertThat (sclReportItems ).hasSize (3 );
422- assertThat (sclReportItems )
423- .extracting (SclReportItem ::message , SclReportItem ::xpath )
424- .containsExactly (
425- Tuple .tuple ("DO@name=Mod/DA@name=stVal not found in DataTypeTemplate" ,
426- "SCL/IED[@name=\" IED_NAME1\" ]/AccessPoint/Server/LDevice[@inst=\" LDEPF\" ]" ),
427- Tuple .tuple ("DO@name=Mod/DA@name=stVal not found in DataTypeTemplate" ,
428- "SCL/IED[@name=\" IED_NAME2\" ]/AccessPoint/Server/LDevice[@inst=\" LDEPF\" ]" ),
429- Tuple .tuple ("DO@name=Mod/DA@name=stVal not found in DataTypeTemplate" ,
430- "SCL/IED[@name=\" IED_NAME3\" ]/AccessPoint/Server/LDevice[@inst=\" LDEPF\" ]" )
431- );
432- }
433-
434-
435330 private void assertExtRefIsBoundAccordingTOLDEPF (TExtRef extRef , TChannel setting ) {
436331 assertThat (extRef .getLdInst ()).isEqualTo (setting .getLDInst ());
437332 assertThat (extRef .getLnClass ()).contains (setting .getLNClass ());
@@ -812,4 +707,72 @@ void manageBindingForLDEPF_should_not_update_dai_setVal_when_channelLevMod_or_ch
812707 });
813708 }
814709
710+ @ Test
711+ void manageBindingForLDEPF_should_return_error_report_when_missing_mandatory_privates () {
712+ //Given
713+ SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-ldepf/scd_ldepf_processing_bind_dai_update.xml" );
714+ scd .getIED ().forEach (tied -> tied .getPrivate ().removeIf (tPrivate -> tPrivate .getType ().equals (PrivateEnum .COMPAS_BAY .getPrivateType ())
715+ || tPrivate .getType ().equals (PrivateEnum .COMPAS_ICDHEADER .getPrivateType ())));
716+
717+ TChannel digitalChannel = new TChannel ();
718+ digitalChannel .setBayScope (TCBScopeType .BAY_INTERNAL );
719+ digitalChannel .setChannelType (TChannelType .DIGITAL );
720+ digitalChannel .setChannelNum ("1" );
721+ digitalChannel .setChannelShortLabel ("MR.PX1" );
722+ digitalChannel .setChannelLevMod (TChannelLevMod .POSITIVE_OR_RISING );
723+ digitalChannel .setChannelLevModQ (TChannelLevMod .OTHER );
724+ digitalChannel .setIEDType ("BCU" );
725+ digitalChannel .setIEDRedundancy (TIEDredundancy .NONE );
726+ digitalChannel .setIEDSystemVersionInstance ("1" );
727+ digitalChannel .setLDInst ("LDPX" );
728+ digitalChannel .setLNClass ("PTRC" );
729+ digitalChannel .setLNInst ("0" );
730+ digitalChannel .setDOName ("Str" );
731+ digitalChannel .setDOInst ("0" );
732+ digitalChannel .setDAName ("general" );
733+ EPF epf = new EPF ();
734+ Channels channels = new Channels ();
735+ channels .getChannel ().add (digitalChannel );
736+ epf .setChannels (channels );
737+ // When
738+ List <SclReportItem > sclReportItems = extRefEditorService .manageBindingForLDEPF (scd , epf );
739+ // Then
740+ assertThat (sclReportItems ).containsExactly (SclReportItem .error ("SCL/IED[@name=\" IED_NAME1\" ]/AccessPoint/Server/LDevice[@inst=\" LDEPF\" ]" , "The IED has no Private Bay" ),
741+ SclReportItem .error ("SCL/IED[@name=\" IED_NAME1\" ]/AccessPoint/Server/LDevice[@inst=\" LDEPF\" ]" , "The IED has no Private compas:ICDHeader" ));
742+ }
743+
744+ @ Test
745+ void manageBindingForLDEPF_should_not_been_configured_when_ldepf_ln0_is_off () {
746+ //Given
747+ SCL scd = SclTestMarshaller .getSCLFromFile ("/scd-ldepf/scd_ldepf_processing_when_status_ln0_off.xml" );
748+ TChannel digitalChannel = new TChannel ();
749+ digitalChannel .setBayScope (TCBScopeType .BAY_INTERNAL );
750+ digitalChannel .setChannelType (TChannelType .DIGITAL );
751+ digitalChannel .setChannelNum ("1" );
752+ digitalChannel .setChannelShortLabel ("MR.PX1" );
753+ digitalChannel .setChannelLevMod (TChannelLevMod .POSITIVE_OR_RISING );
754+ digitalChannel .setChannelLevModQ (TChannelLevMod .OTHER );
755+ digitalChannel .setIEDType ("BCU" );
756+ digitalChannel .setIEDRedundancy (TIEDredundancy .NONE );
757+ digitalChannel .setIEDSystemVersionInstance ("1" );
758+ digitalChannel .setLDInst ("LDPX" );
759+ digitalChannel .setLNClass ("PTRC" );
760+ digitalChannel .setLNInst ("0" );
761+ digitalChannel .setDOName ("Str" );
762+ digitalChannel .setDOInst ("0" );
763+ digitalChannel .setDAName ("general" );
764+ EPF epf = new EPF ();
765+ Channels channels = new Channels ();
766+ channels .getChannel ().add (digitalChannel );
767+ epf .setChannels (channels );
768+ // When
769+ List <SclReportItem > sclReportItems = extRefEditorService .manageBindingForLDEPF (scd , epf );
770+ // Then
771+ assertThat (sclReportItems ).isEmpty ();
772+ assertThat (scd )
773+ .usingRecursiveComparison ()
774+ .isEqualTo (SclTestMarshaller .getSCLFromFile ("/scd-ldepf/scd_ldepf_processing_when_status_ln0_off.xml" ));
775+ }
776+
777+
815778}
0 commit comments