Skip to content

Commit a94eb79

Browse files
Merge pull request #309 from com-pas/feat/304-change-fatal-to-error
feat: rename SclReportItem#fatal to SclReportItem#error
2 parents e071955 + ef3c8b6 commit a94eb79

File tree

15 files changed

+75
-85
lines changed

15 files changed

+75
-85
lines changed

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import org.lfenergy.compas.sct.commons.scl.com.ConnectedAPAdapter;
88

9+
import java.util.Objects;
10+
911
/**
1012
* A representation of the model object <em><b>Connected AP</b></em>.
1113
*

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReportItem.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
// SPDX-FileCopyrightText: 2022 RTE FRANCE
1+
// SPDX-FileCopyrightText: 2022 2023 RTE FRANCE
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

55
package org.lfenergy.compas.sct.commons.dto;
66

7-
import lombok.AllArgsConstructor;
8-
import lombok.EqualsAndHashCode;
9-
import lombok.Getter;
10-
import lombok.ToString;
7+
public record SclReportItem(String xpath, String message, boolean isError) {
118

12-
@Getter
13-
@EqualsAndHashCode
14-
@AllArgsConstructor
15-
@ToString
16-
public final class SclReportItem {
17-
private final String xpath;
18-
private final String message;
19-
private final boolean isFatal;
20-
21-
public static SclReportItem fatal(String xpath, String message) {
9+
public static SclReportItem error(String xpath, String message) {
2210
return new SclReportItem(xpath, message, true);
2311
}
2412

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ExtRefService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private static List<SclReportItem> checkIedUnityOfIcdSystemVersionUuid(SclRootAd
9595
return systemVersionToIedList.entrySet().stream()
9696
.filter(entry -> StringUtils.isNotBlank(entry.getKey()))
9797
.filter(entry -> entry.getValue().size() > 1)
98-
.map(entry -> SclReportItem.fatal(entry.getValue().stream()
98+
.map(entry -> SclReportItem.error(entry.getValue().stream()
9999
.map(tied -> new IEDAdapter(sclRootAdapter, tied))
100100
.map(IEDAdapter::getXPath)
101101
.collect(Collectors.joining(", ")),

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclElementAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ public String getXPath(){
123123
* @return error description with message and current element xpath
124124
*/
125125
public SclReportItem buildFatalReportItem(String message){
126-
return SclReportItem.fatal(getXPath(), message);
126+
return SclReportItem.error(getXPath(), message);
127127
}
128128
}

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public List<SclReportItem> checkFCDALimitations() {
9090
.map(abstractLNAdapter -> abstractLNAdapter.getCurrentElem().getDataSet())
9191
.flatMap(Collection::stream)
9292
.filter(tDataSet -> tDataSet.getFCDA().size() > max)
93-
.map(tDataSet -> SclReportItem.fatal(getXPath(), String.format("There are too much FCDA for the DataSet %s for the LDevice %s"
93+
.map(tDataSet -> SclReportItem.error(getXPath(), String.format("There are too much FCDA for the DataSet %s for the LDevice %s"
9494
+ " in IED %s: %d > %d max", tDataSet.getName(), lDeviceAdapter.getInst(), parentAdapter.getName(),
9595
tDataSet.getFCDA().size(), max))
9696
).toList()
@@ -106,7 +106,7 @@ public List<SclReportItem> checkFCDALimitations() {
106106
public Optional<SclReportItem> checkControlsLimitation(ServicesConfigEnum servicesConfigEnum) {
107107
long max = getMaxInstanceAuthorized(servicesConfigEnum);
108108
long value = getNumberOfItems(servicesConfigEnum);
109-
return max == MAX_OCCURRENCE_NO_LIMIT_VALUE || value <= max ? Optional.empty() : Optional.of(SclReportItem.fatal(getXPath(),
109+
return max == MAX_OCCURRENCE_NO_LIMIT_VALUE || value <= max ? Optional.empty() : Optional.of(SclReportItem.error(getXPath(),
110110
String.format("There are too much %ss for the IED %s: %d > %d max", servicesConfigEnum.getDisplayName(), parentAdapter.getName(), value, max)));
111111
}
112112

@@ -212,7 +212,7 @@ public Optional<SclReportItem> checkLimitationForBoundIedFcdas(List<TExtRef> tEx
212212
.size();
213213

214214
return value <= max ? Optional.empty() :
215-
Optional.of(SclReportItem.fatal(getParentAdapter().getXPath(),
215+
Optional.of(SclReportItem.error(getParentAdapter().getXPath(),
216216
"The Client IED %s subscribes to too much FCDA: %d > %d max".formatted(getParentAdapter().getName(), value, max)));
217217
}
218218

@@ -256,7 +256,7 @@ private List<SclReportItem> checkExtRefWithoutServiceType(List<TExtRef> tExtRefs
256256
return tExtRefs.stream()
257257
.filter(tExtRef -> !tExtRef.isSetServiceType())
258258
.map(tExtRef ->
259-
SclReportItem.fatal("%s/Inputs/ExtRef[%s]".formatted(xPath,
259+
SclReportItem.error("%s/Inputs/ExtRef[%s]".formatted(xPath,
260260
Utils.xpathAttributeFilter("desc", tExtRef.getDesc())),
261261
"ExtRef is missing ServiceType attribute"))
262262
.toList();
@@ -288,7 +288,7 @@ private Optional<SclReportItem> checkLimitationForOneControlType(Set<TExtRef> tE
288288
long max = getMaxInstanceAuthorizedForBoundIED(servicesConfigEnum);
289289
long value = tExtRefs.size();
290290
return max == AccessPointAdapter.MAX_OCCURRENCE_NO_LIMIT_VALUE || value <= max ? Optional.empty() :
291-
Optional.of(SclReportItem.fatal(getParentAdapter().getXPath(),
291+
Optional.of(SclReportItem.error(getParentAdapter().getXPath(),
292292
"The Client IED %s subscribes to too much %ss: %d > %d max".formatted(getParentAdapter().getName(), servicesConfigEnum.getDisplayName(),
293293
value, max)));
294294
}

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ private Optional<SclReportItem> validateExtRefSource(TExtRef extRef, IEDAdapter
181181
case ON -> null;
182182
};
183183
} catch (IllegalArgumentException e) {
184-
return SclReportItem.fatal(extRefXPath(extRef.getDesc()), String.format(MESSAGE_SOURCE_LDEVICE_STATUS_NEITHER_ON_NOR_OFF, sourceLDevice.getXPath()));
184+
return SclReportItem.error(extRefXPath(extRef.getDesc()), String.format(MESSAGE_SOURCE_LDEVICE_STATUS_NEITHER_ON_NOR_OFF, sourceLDevice.getXPath()));
185185
}
186186
});
187187
}
@@ -211,7 +211,7 @@ private Optional<SclReportItem> warningReportItem(TExtRef extRef, String message
211211
}
212212

213213
private Optional<SclReportItem> fatalReportItem(TExtRef extRef, String message) {
214-
return Optional.of(SclReportItem.fatal(extRefXPath(extRef.getDesc()), message));
214+
return Optional.of(SclReportItem.error(extRefXPath(extRef.getDesc()), message));
215215
}
216216

217217
private String extRefXPath(String extRefDesc) {

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,9 @@ public List<ExtRefInfo.ExtRefBayReference> getExtRefBayReferenceForActifLDEPF(fi
493493
List<ExtRefInfo.ExtRefBayReference> extRefBayReferenceList = new ArrayList<>();
494494
IEDAdapter parentIedAdapter = getParentAdapter();
495495
if (parentIedAdapter.getPrivateCompasBay().isEmpty()) {
496-
sclReportItems.add(SclReportItem.fatal(getXPath(), "The IED has no Private Bay"));
496+
sclReportItems.add(SclReportItem.error(getXPath(), "The IED has no Private Bay"));
497497
if (parentIedAdapter.getCompasICDHeader().isEmpty()) {
498-
sclReportItems.add(SclReportItem.fatal(getXPath(), "The IED has no Private compas:ICDHeader"));
498+
sclReportItems.add(SclReportItem.error(getXPath(), "The IED has no Private compas:ICDHeader"));
499499
}
500500
return Collections.emptyList();
501501
}
@@ -504,7 +504,7 @@ public List<ExtRefInfo.ExtRefBayReference> getExtRefBayReferenceForActifLDEPF(fi
504504
if (LdeviceStatus.ON.equals(s)) {
505505
extRefBayReferenceList.addAll(getLN0Adapter().getInputsAdapter().getCurrentElem().getExtRef().stream().map(extRef -> new ExtRefInfo.ExtRefBayReference(parentIedAdapter.getName(), parentIedAdapter.getPrivateCompasBay().get(), extRef)).toList());
506506
}
507-
}, () -> sclReportItems.add(SclReportItem.fatal(getXPath(), "There is no DOI@name=" + MOD_DO_TYPE_NAME + "/DAI@name=" + STVAL_DA_TYPE_NAME + "/Val for LDevice@inst" + LDEVICE_LDEPF)));
507+
}, () -> sclReportItems.add(SclReportItem.error(getXPath(), "There is no DOI@name=" + MOD_DO_TYPE_NAME + "/DAI@name=" + STVAL_DA_TYPE_NAME + "/Val for LDevice@inst" + LDEVICE_LDEPF)));
508508
return extRefBayReferenceList;
509509
}
510510

sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ExtRefServiceTest.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void updateAllExtRefIedNames_should_return_success_status() {
7777
// When
7878
List<SclReportItem> sclReportItems = ExtRefService.updateAllExtRefIedNames(scd);
7979
// Then
80-
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isFatal))
80+
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError))
8181
.overridingErrorMessage(String.valueOf(sclReportItems))
8282
.isTrue();
8383
}
@@ -90,7 +90,7 @@ void updateAllExtRefIedNames_should_report_errors(String testCase, SCL scl, SclR
9090
List<SclReportItem> sclReportItems = ExtRefService.updateAllExtRefIedNames(scl);
9191
// Then : the sclReport should report all errors described in the comments in the SCD file
9292
assertThat(sclReportItems).isNotNull();
93-
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isFatal)).isFalse();
93+
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse();
9494
assertThat(sclReportItems).containsExactlyInAnyOrder(errors);
9595
}
9696

@@ -100,18 +100,18 @@ public static Stream<Arguments> updateAllExtRefIedNamesErrors() {
100100
"Errors on ExtRefs",
101101
SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml"),
102102
new SclReportItem[]{
103-
SclReportItem.fatal(
103+
SclReportItem.error(
104104
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
105105
"/LN0/Inputs/ExtRef[@desc=\"No matching compas:Flow\"]",
106106
"The signal ExtRef has no matching compas:Flow Private"),
107-
SclReportItem.fatal(
107+
SclReportItem.error(
108108
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
109109
"/LN0/Inputs/ExtRef[@desc=\"Matching two compas:Flow\"]",
110110
"The signal ExtRef has more than one matching compas:Flow Private"),
111-
SclReportItem.fatal(
111+
SclReportItem.error(
112112
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST13\"]",
113113
"The Ldevice status test does not exist. It should be among [on, off]"),
114-
SclReportItem.fatal(
114+
SclReportItem.error(
115115
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST14\"]",
116116
"The LDevice status is undefined"),
117117
SclReportItem.warning(
@@ -131,12 +131,12 @@ public static Stream<Arguments> updateAllExtRefIedNamesErrors() {
131131
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
132132
"/LN0/Inputs/ExtRef[@desc=\"Source LDevice is off for this ExtRef\"]",
133133
"The signal ExtRef source LDevice /SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST22\"] status is off"),
134-
SclReportItem.fatal(
134+
SclReportItem.error(
135135
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
136136
"/LN0/Inputs/ExtRef[@desc=\"Source LDevice is undefined for this ExtRef\"]",
137137
"The signal ExtRef source LDevice /SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST23\"] status is " +
138138
"undefined"),
139-
SclReportItem.fatal(
139+
SclReportItem.error(
140140
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
141141
"/LN0/Inputs/ExtRef[@desc=\"Source LDevice is neither on nor off for this ExtRef\"]",
142142
"The signal ExtRef source LDevice /SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST24\"] " +
@@ -146,12 +146,12 @@ public static Stream<Arguments> updateAllExtRefIedNamesErrors() {
146146
"Errors on IEDs",
147147
SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_ied_errors.xml"),
148148
new SclReportItem[]{
149-
SclReportItem.fatal(
149+
SclReportItem.error(
150150
"/SCL/IED[@name=\"IED_NAME1\"], /SCL/IED[@name=\"IED_NAME2\"]",
151151
"/IED/Private/compas:ICDHeader[@ICDSystemVersionUUID] must be unique but the same ICDSystemVersionUUID was found on several IED."),
152-
SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME3\"]", "IED has no Private COMPAS-ICDHeader element"),
153-
SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME4\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute"),
154-
SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME5\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute")
152+
SclReportItem.error("/SCL/IED[@name=\"IED_NAME3\"]", "IED has no Private COMPAS-ICDHeader element"),
153+
SclReportItem.error("/SCL/IED[@name=\"IED_NAME4\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute"),
154+
SclReportItem.error("/SCL/IED[@name=\"IED_NAME5\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute")
155155
})
156156
);
157157
}
@@ -420,7 +420,7 @@ void configureNetworkForAllControlBlocks_should_create_GSE_and_SMV_elements() {
420420
// When
421421
List<SclReportItem> sclReportItems = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, RANGES_PER_CB_TYPE);
422422
// Then
423-
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isFatal)).isTrue();
423+
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
424424
TConnectedAP connectedAP = new SclRootAdapter(scd).findConnectedApAdapter("IED_NAME2", "AP_NAME").get().getCurrentElem();
425425
TGSE gse = connectedAP.getGSE().stream()
426426
.filter(tgse -> "CB_LD_INST21_GSI".equals(tgse.getCbName()))
@@ -462,7 +462,7 @@ void configureNetworkForAllControlBlocks_should_create_GSE_with_incremental_appi
462462
// When
463463
List<SclReportItem> sclReportItems = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, RANGES_PER_CB_TYPE);
464464
// Then
465-
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isFatal)).isTrue();
465+
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
466466
assertThat(streamAllConnectedApGseP(scd, "APPID"))
467467
.containsExactlyInAnyOrder("0009", "000A", "000B");
468468
assertThat(streamAllConnectedApGseP(scd, "MAC-Address"))
@@ -479,9 +479,9 @@ void configureNetworkForAllControlBlocks_should_fail_when_no_settings_for_this_c
479479
// When
480480
List<SclReportItem> sclReportItems = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType);
481481
// Then
482-
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isFatal)).isFalse();
482+
assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse();
483483
assertThat(sclReportItems)
484-
.extracting(SclReportItem::getMessage, SclReportItem::getXpath)
484+
.extracting(SclReportItem::message, SclReportItem::xpath)
485485
.contains(Tuple.tuple(expectedMessage,
486486
"/SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST21\"]/LN0/GSEControl[@name=\"CB_LD_INST21_GMI\"]"));
487487
}
@@ -704,7 +704,7 @@ void manageBindingForLDEPF_should_return_report_when_manyIedSourceFound() {
704704
List<SclReportItem> sclReportItems = ExtRefService.manageBindingForLDEPF(scd, settings);
705705
// Then
706706
assertThat(sclReportItems).hasSize(2)
707-
.extracting(SclReportItem::getMessage)
707+
.extracting(SclReportItem::message)
708708
.isEqualTo(List.of("There is more than one IED source to bind the signal /IED@name=IED_NAME2/LDevice@inst=LDEPF/LN0/ExtRef@desc=DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1",
709709
"There is more than one IED source to bind the signal /IED@name=IED_NAME3/LDevice@inst=LDEPF/LN0/ExtRef@desc=DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1"));
710710
TExtRef extRef1 = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");

0 commit comments

Comments
 (0)