Skip to content

Commit

Permalink
fix(#449): fix test in LNodeStatusServiceTest
Browse files Browse the repository at this point in the history
Signed-off-by: massifben <[email protected]>
  • Loading branch information
massifben committed Jan 14, 2025
1 parent 8f178f4 commit fe6cd80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void setUp() {

@ParameterizedTest
@MethodSource("provideUpdateModStVal")
void updateLnStatusBasedOnPrivateLNodeStatus_should_update_Mod_stVal(String ldInst, String lnClass, String lnInst, String expected) {
void updateLnStatusBasedOnPrivateLNodeStatus_should_update_Mod_stVal(String ldInst, String lnClass, String lnInst, String expected){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
// When
Expand All @@ -48,24 +48,23 @@ void updateLnStatusBasedOnPrivateLNodeStatus_should_update_Mod_stVal(String ldIn

public static Stream<Arguments> provideUpdateModStVal() {
return Stream.of(
Arguments.of(named("LN 'on' à mettre à 'on'", "LDEVICE_1"), "PDIS", "1", "on"),
Arguments.of(named("LN 'off;on' à mettre à 'on'", "LDEVICE_1"), "PDIS", "2", "on"),
Arguments.of(named("LN 'off' à mettre à 'off'", "LDEVICE_1"), "PDIS", "3", "off"),
Arguments.of(named("LN 'off;on' à mettre à 'off'", "LDEVICE_1"), "PDIS", "3", "off"),
Arguments.of(named("LN0 'on' à mettre à 'on'", "LDEVICE_1"), "LLN0", "", "on"),
Arguments.of(named("LN0 'off;on' à mettre à 'on'", "LDEVICE_2"), "LLN0", "", "on"),
Arguments.of(named("LN0 'off' à mettre à 'off'", "LDEVICE_3"), "LLN0", "", "off"),
Arguments.of(named("LN0 'off;on' à mettre à 'off'", "LDEVICE_4"), "LLN0", "", "off")
Arguments.of(named("LN 'on;off' à mettre à 'on'", "LDEVICE_1"), "PDIS", "1", "on"),
Arguments.of(named("LN 'on' à mettre à 'on'", "LDEVICE_1"), "PDIS", "2", "on"),
Arguments.of(named("LN 'on;off' à mettre à 'off'", "LDEVICE_1"), "PDIS", "3", "off"),
Arguments.of(named("LN 'off' à mettre à 'off'", "LDEVICE_1"), "PDIS", "4", "off"),
Arguments.of(named("LN0 'on;off' à mettre à 'on'", "LDEVICE_1"), "LLN0", "", "on"),
Arguments.of(named("LN0 'on' à mettre à 'on'", "LDEVICE_2"), "LLN0", "", "on"),
Arguments.of(named("LN0 'on;off' à mettre à 'off'", "LDEVICE_3"), "LLN0", "", "off"),
Arguments.of(named("LN0 'off' à mettre à 'off'", "LDEVICE_4"), "LLN0", "", "off")
);
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_do_nothing_if_DAI_Mod_stVal_is_missing() {
void updateLnStatusBasedOnPrivateLNodeStatus_do_nothing_if_DAI_Mod_stVal_is_missing(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus_without_mod_stval.scd");
// When
List<SclReportItem> sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl);
// Then
assertThat(sclReportItems).isEmpty();
assertThat(getLDevices(scl.getIED().getFirst())
.flatMap(tlDevice -> Stream.concat(Stream.of(tlDevice.getLN0()), tlDevice.getLN().stream())))
Expand All @@ -74,7 +73,7 @@ void updateLnStatusBasedOnPrivateLNodeStatus_do_nothing_if_DAI_Mod_stVal_is_miss
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LNode_should_return_error() {
void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LNode_should_return_error(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
scl.getSubstation().getFirst().getVoltageLevel().getFirst().getBay().getFirst().getFunction().getFirst().getLNode().getFirst()
Expand All @@ -89,7 +88,7 @@ void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LNode_
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_when_invalid_compasLNodeStatus_value_in_LNode_should_return_error() {
void updateLnStatusBasedOnPrivateLNodeStatus_when_invalid_compasLNodeStatus_value_in_LNode_should_return_error(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
scl.getSubstation().getFirst().getVoltageLevel().getFirst().getBay().getFirst().getFunction().getFirst().getLNode().getFirst()
Expand All @@ -104,12 +103,11 @@ void updateLnStatusBasedOnPrivateLNodeStatus_when_invalid_compasLNodeStatus_valu
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_when_LNode_does_not_match_any_LN_should_return_error() {
void updateLnStatusBasedOnPrivateLNodeStatus_when_LNode_does_not_match_any_LN_should_return_error(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
((TLN) findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "PDIS", "1", ""))
.setPrefix("helloworld");
// When
List<SclReportItem> sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl);
// Then
assertThat(sclReportItems).containsExactly(
Expand All @@ -119,7 +117,7 @@ void updateLnStatusBasedOnPrivateLNodeStatus_when_LNode_does_not_match_any_LN_sh
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LN_should_return_error() {
void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LN_should_return_error(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "PDIS", "1", "")
Expand All @@ -134,7 +132,7 @@ void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LN_sho
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_on_in_LNode_but_off_in_LN_should_return_error() {
void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_on_in_LNode_but_off_in_LN_should_return_error(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "LLN0", "", "")
Expand All @@ -143,7 +141,6 @@ void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_on_in_LNo
.getPrivate().getFirst().getContent().set(0, "off");
// When
List<SclReportItem> sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl);
// Then
assertThat(sclReportItems).containsExactlyInAnyOrder(
SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_1)/LN[LLN0,,]",
"Cannot set DAI Mod.stVal to on, because LN private COMPAS-LNodeStatus is set to off"),
Expand All @@ -153,7 +150,7 @@ void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_on_in_LNo
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_off_in_LNode_but_on_in_LN_should_return_error() {
void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_off_in_LNode_but_on_in_LN_should_return_error(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
findAnyLn(scl, "IED_NAME_1", "LDEVICE_4", "LLN0", "", "")
Expand All @@ -172,13 +169,12 @@ void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_off_in_LN
}

@Test
void updateLnStatusBasedOnPrivateLNodeStatus_when_Mod_stVal_enumType_does_not_contains_value_should_return_error() {
void updateLnStatusBasedOnPrivateLNodeStatus_when_Mod_stVal_enumType_does_not_contains_value_should_return_error(){
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd");
scl.getDataTypeTemplates().getEnumType().getFirst().getEnumVal().removeIf(tEnumVal -> tEnumVal.getValue().equals("on"));
// When
List<SclReportItem> sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl);
// Then
assertThat(sclReportItems).contains(
SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_1)/LN[PDIS,1,]",
"Cannot set DAI Mod.stVal to 'on' because value is not in EnumType [off, test]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<Authentication/>
<LDevice inst="LDEVICE_1">
<LN0 lnType="lnType1" lnClass="LLN0" inst="">
<Private type="COMPAS-LNodeStatus">on</Private>
<Private type="COMPAS-LNodeStatus">on;off</Private>
<DOI name="Mod">
<DAI name="stVal"/>
</DOI>
Expand Down

0 comments on commit fe6cd80

Please sign in to comment.