|
27 | 27 |
|
28 | 28 | import static org.assertj.core.api.Assertions.assertThat;
|
29 | 29 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
| 30 | +import static org.assertj.core.api.Assertions.tuple; |
30 | 31 | import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
31 | 32 | import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.*;
|
32 | 33 | import static org.lfenergy.compas.sct.commons.util.CommonConstants.*;
|
@@ -610,7 +611,7 @@ void epfPostProcessing_when_exist_unused_channel_should_update_setSrcRef() {
|
610 | 611 | @CsvSource({"'',''", "NA,NA"})
|
611 | 612 | void manageBindingForLDEPF_should_not_update_dai_setVal_when_channelLevMod_or_channelLevModq_are_empty_or_NA(String channelLevMod, String channelLevModq) {
|
612 | 613 | //Given
|
613 |
| - SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_bind_dai_update.xml"); |
| 614 | + SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_internal_bind.xml"); |
614 | 615 | TChannel digitalChannel = new TChannel();
|
615 | 616 | digitalChannel.setBayScope(TCBScopeType.BAY_INTERNAL);
|
616 | 617 | digitalChannel.setChannelType(TChannelType.DIGITAL);
|
@@ -710,7 +711,7 @@ void manageBindingForLDEPF_should_not_update_dai_setVal_when_channelLevMod_or_ch
|
710 | 711 | @Test
|
711 | 712 | void manageBindingForLDEPF_should_return_error_report_when_missing_mandatory_privates() {
|
712 | 713 | //Given
|
713 |
| - SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_bind_dai_update.xml"); |
| 714 | + SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_internal_bind.xml"); |
714 | 715 | scd.getIED().forEach(tied -> tied.getPrivate().removeIf(tPrivate -> tPrivate.getType().equals(PrivateEnum.COMPAS_BAY.getPrivateType())
|
715 | 716 | || tPrivate.getType().equals(PrivateEnum.COMPAS_ICDHEADER.getPrivateType())));
|
716 | 717 |
|
@@ -774,5 +775,134 @@ void manageBindingForLDEPF_should_not_been_configured_when_ldepf_ln0_is_off() {
|
774 | 775 | .isEqualTo(SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_when_status_ln0_off.xml"));
|
775 | 776 | }
|
776 | 777 |
|
| 778 | + @Test |
| 779 | + void manageBindingForLDEPF_should_update_binding_properties_when_internal_binding() { |
| 780 | + //Given |
| 781 | + SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_internal_bind.xml"); |
| 782 | + TChannel digitalChannel = new TChannel(); |
| 783 | + digitalChannel.setBayScope(TCBScopeType.BAY_INTERNAL); |
| 784 | + digitalChannel.setChannelType(TChannelType.DIGITAL); |
| 785 | + digitalChannel.setChannelNum("1"); |
| 786 | + digitalChannel.setChannelShortLabel("MR.PX1"); |
| 787 | + digitalChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING); |
| 788 | + digitalChannel.setChannelLevModQ(TChannelLevMod.OTHER); |
| 789 | + digitalChannel.setIEDType("BCU"); |
| 790 | + digitalChannel.setIEDRedundancy(TIEDredundancy.NONE); |
| 791 | + digitalChannel.setIEDSystemVersionInstance("1"); |
| 792 | + digitalChannel.setLDInst("LDPX"); |
| 793 | + digitalChannel.setLNClass("PTRC"); |
| 794 | + digitalChannel.setLNInst("0"); |
| 795 | + digitalChannel.setDOName("Str"); |
| 796 | + digitalChannel.setDOInst("0"); |
| 797 | + digitalChannel.setDAName("general"); |
| 798 | + |
| 799 | + TChannel analogChannel = new TChannel(); |
| 800 | + analogChannel.setBayScope(TCBScopeType.BAY_INTERNAL); |
| 801 | + analogChannel.setChannelType(TChannelType.ANALOG); |
| 802 | + analogChannel.setChannelNum("1"); |
| 803 | + analogChannel.setChannelShortLabel("MR.PX1"); |
| 804 | + analogChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING); |
| 805 | + analogChannel.setChannelLevModQ(TChannelLevMod.OTHER); |
| 806 | + analogChannel.setIEDType("BCU"); |
| 807 | + analogChannel.setIEDRedundancy(TIEDredundancy.NONE); |
| 808 | + analogChannel.setIEDSystemVersionInstance("1"); |
| 809 | + analogChannel.setLDInst("LDPX"); |
| 810 | + analogChannel.setLNClass("PTRC"); |
| 811 | + analogChannel.setLNInst("0"); |
| 812 | + analogChannel.setDOName("Str"); |
| 813 | + analogChannel.setDOInst("0"); |
| 814 | + analogChannel.setDAName("general"); |
| 815 | + |
| 816 | + EPF epf = new EPF(); |
| 817 | + Channels channels = new Channels(); |
| 818 | + channels.getChannel().addAll(List.of(digitalChannel, analogChannel)); |
| 819 | + epf.setChannels(channels); |
| 820 | + // When |
| 821 | + List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf); |
| 822 | + // Then |
| 823 | + assertThat(sclReportItems).isEmpty(); |
| 824 | + assertThat(scd.getIED()) |
| 825 | + .filteredOn(tied -> tied.getName().equals("IED_NAME1")) |
| 826 | + .flatExtracting(TIED::getAccessPoint) |
| 827 | + .extracting(TAccessPoint::getServer) |
| 828 | + .flatExtracting(TServer::getLDevice) |
| 829 | + .filteredOn(tlDevice -> tlDevice.getInst().equals(LDEVICE_LDEPF)) |
| 830 | + // Binding properties should be set |
| 831 | + .allSatisfy(tlDevice -> { |
| 832 | + assertThat(tlDevice.getLN0().getInputs().getExtRef()) |
| 833 | + .filteredOn(tExtRef -> tExtRef.getDesc().contains("DIGITAL")) |
| 834 | + .extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::isSetServiceType) |
| 835 | + .containsExactlyInAnyOrder(tuple("IED_NAME1", "LDPX", List.of("PTRC"), "0", "Str", false)); |
| 836 | + assertThat(tlDevice.getLN0().getInputs().getExtRef()) |
| 837 | + .filteredOn(tExtRef -> tExtRef.getDesc().contains("ANALOG")) |
| 838 | + .extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::isSetServiceType) |
| 839 | + .containsExactlyInAnyOrder(tuple("IED_NAME1", "LDPX", List.of("PTRC"), "0", "Str", false)); |
| 840 | + }); |
| 841 | + } |
| 842 | + |
| 843 | + @Test |
| 844 | + void manageBindingForLDEPF_should_update_binding_properties_when_external_binding() { |
| 845 | + //Given |
| 846 | + SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_processing_external_bind.xml"); |
| 847 | + TChannel digitalChannel = new TChannel(); |
| 848 | + digitalChannel.setBayScope(TCBScopeType.BAY_EXTERNAL); |
| 849 | + digitalChannel.setChannelType(TChannelType.DIGITAL); |
| 850 | + digitalChannel.setChannelNum("1"); |
| 851 | + digitalChannel.setChannelShortLabel("MR.PX1"); |
| 852 | + digitalChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING); |
| 853 | + digitalChannel.setChannelLevModQ(TChannelLevMod.OTHER); |
| 854 | + digitalChannel.setIEDType("BCU"); |
| 855 | + digitalChannel.setIEDRedundancy(TIEDredundancy.NONE); |
| 856 | + digitalChannel.setIEDSystemVersionInstance("1"); |
| 857 | + digitalChannel.setLDInst("LDPX"); |
| 858 | + digitalChannel.setLNClass("PTRC"); |
| 859 | + digitalChannel.setLNInst("0"); |
| 860 | + digitalChannel.setDOName("Str"); |
| 861 | + digitalChannel.setDOInst("0"); |
| 862 | + digitalChannel.setDAName("general"); |
| 863 | + |
| 864 | + TChannel analogChannel = new TChannel(); |
| 865 | + analogChannel.setBayScope(TCBScopeType.BAY_EXTERNAL); |
| 866 | + analogChannel.setChannelType(TChannelType.ANALOG); |
| 867 | + analogChannel.setChannelNum("1"); |
| 868 | + analogChannel.setChannelShortLabel("MR.PX1"); |
| 869 | + analogChannel.setChannelLevMod(TChannelLevMod.POSITIVE_OR_RISING); |
| 870 | + analogChannel.setChannelLevModQ(TChannelLevMod.OTHER); |
| 871 | + analogChannel.setIEDType("BCU"); |
| 872 | + analogChannel.setIEDRedundancy(TIEDredundancy.NONE); |
| 873 | + analogChannel.setIEDSystemVersionInstance("1"); |
| 874 | + analogChannel.setLDInst("LDPX"); |
| 875 | + analogChannel.setLNClass("PTRC"); |
| 876 | + analogChannel.setLNInst("0"); |
| 877 | + analogChannel.setDOName("Str"); |
| 878 | + analogChannel.setDOInst("0"); |
| 879 | + analogChannel.setDAName("general"); |
| 880 | + |
| 881 | + EPF epf = new EPF(); |
| 882 | + Channels channels = new Channels(); |
| 883 | + channels.getChannel().addAll(List.of(digitalChannel, analogChannel)); |
| 884 | + epf.setChannels(channels); |
| 885 | + // When |
| 886 | + List<SclReportItem> sclReportItems = extRefEditorService.manageBindingForLDEPF(scd, epf); |
| 887 | + // Then |
| 888 | + assertThat(sclReportItems).isEmpty(); |
| 889 | + assertThat(scd.getIED()) |
| 890 | + .filteredOn(tied -> tied.getName().equals("IED_NAME1")) |
| 891 | + .flatExtracting(TIED::getAccessPoint) |
| 892 | + .extracting(TAccessPoint::getServer) |
| 893 | + .flatExtracting(TServer::getLDevice) |
| 894 | + .filteredOn(tlDevice -> tlDevice.getInst().equals(LDEVICE_LDEPF)) |
| 895 | + // Binding properties should be set including Service Type |
| 896 | + .allSatisfy(tlDevice -> { |
| 897 | + assertThat(tlDevice.getLN0().getInputs().getExtRef()) |
| 898 | + .filteredOn(tExtRef -> tExtRef.getDesc().contains("DIGITAL")) |
| 899 | + .extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::getServiceType) |
| 900 | + .containsExactlyInAnyOrder(tuple("IED_NAME2", "LDPX", List.of("PTRC"), "0", "Str", TServiceType.GOOSE)); |
| 901 | + assertThat(tlDevice.getLN0().getInputs().getExtRef()) |
| 902 | + .filteredOn(tExtRef -> tExtRef.getDesc().contains("ANALOG")) |
| 903 | + .extracting(TExtRef::getIedName, TExtRef::getLdInst, TExtRef::getLnClass, TExtRef::getLnInst, TExtRef::getDoName, TExtRef::getServiceType) |
| 904 | + .containsExactlyInAnyOrder(tuple("IED_NAME2", "LDPX", List.of("PTRC"), "0", "Str", TServiceType.SMV)); |
| 905 | + }); |
| 906 | + } |
777 | 907 |
|
778 | 908 | }
|
0 commit comments