diff --git a/sct-app/src/main/java/org/lfenergy/compas/sct/app/SclAutomationService.java b/sct-app/src/main/java/org/lfenergy/compas/sct/app/SclAutomationService.java
index 1b4295c38..234f86698 100644
--- a/sct-app/src/main/java/org/lfenergy/compas/sct/app/SclAutomationService.java
+++ b/sct-app/src/main/java/org/lfenergy/compas/sct/app/SclAutomationService.java
@@ -5,12 +5,11 @@
package org.lfenergy.compas.sct.app;
import lombok.NonNull;
-import org.apache.commons.lang3.tuple.Pair;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.sct.commons.dto.HeaderDTO;
import org.lfenergy.compas.sct.commons.dto.SubNetworkDTO;
+import org.lfenergy.compas.sct.commons.dto.SubNetworkTypeDTO;
import org.lfenergy.compas.sct.commons.exception.ScdException;
-import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.SclService;
import org.lfenergy.compas.sct.commons.scl.SubstationService;
@@ -22,42 +21,41 @@
* The following features are supported:
*
*
- * - {@link SclAutomationService#createSCD(SCL, HeaderDTO, Set) Adds all elements under the SCL object from given SSD and STD files}
+ *
- {@link SclAutomationService#createSCD(SCL, HeaderDTO, List) Adds all elements under the SCL object from given SSD and STD files}
*
*/
public class SclAutomationService {
/**
- * Possible Subnetwork and ConnectAP names which should be used in generated SCD in order a have global coherence
+ * Possible Subnetwork and ConnectedAP names which should be used in generated SCD in order a have global coherence
* Configuration based on used framework can be used to externalize this datas
*/
- private static final Map, List> comMap = Map.of(
- Pair.of("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString()), Arrays.asList("PROCESS_AP", "TOTO_AP_GE"),
- Pair.of("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.IP.toString()), Arrays.asList("ADMIN_AP", "TATA_AP_EFFACEC"));
+ public static final List SUB_NETWORK_TYPES = List.of(
+ new SubNetworkTypeDTO("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString(), List.of("PROCESS_AP", "TOTO_AP_GE")),
+ new SubNetworkTypeDTO("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.IP.toString(), List.of("ADMIN_AP", "TATA_AP_EFFACEC")));
private SclAutomationService() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
/**
- * Create a SCD file from specified parameters, it calls all functions defined in the process one by one, every step
- * return a SCD file which will be used by the next step.
+ * Create an SCD file from specified parameters, it calls all functions defined in the process one by one, every step
+ * return an SCD file which will be used by the next step.
* @param ssd : (mandatory) file contains substation datas
* @param headerDTO : (mandatory) object which hold header datas and historys' one
- * @param stds : (optional) list of STD files containing IED datas (IED, Communication and DataTypeTemplate)
- * @return a SCD file encapsuled in object SclRootAdapter
+ * @param stds : list of STD files containing IED datas (IED, Communication and DataTypeTemplate)
+ * @return an SCD object
* @throws ScdException
*/
- public static SclRootAdapter createSCD(@NonNull SCL ssd, @NonNull HeaderDTO headerDTO, Set stds) throws ScdException {
- SclRootAdapter scdAdapter = SclService.initScl(Optional.ofNullable(headerDTO.getId()),
- headerDTO.getVersion(), headerDTO.getRevision());
+ public static SCL createSCD(@NonNull SCL ssd, @NonNull HeaderDTO headerDTO, List stds) throws ScdException {
+ SCL scd = SclService.initScl(headerDTO.getId(), headerDTO.getVersion(), headerDTO.getRevision());
if (!headerDTO.getHistoryItems().isEmpty()) {
HeaderDTO.HistoryItem hItem = headerDTO.getHistoryItems().get(0);
- SclService.addHistoryItem(scdAdapter.getCurrentElem(), hItem.getWho(), hItem.getWhat(), hItem.getWhy());
+ SclService.addHistoryItem(scd, hItem.getWho(), hItem.getWhat(), hItem.getWhy());
}
- SubstationService.addSubstation(scdAdapter.getCurrentElem(), ssd);
- SclService.importSTDElementsInSCD(scdAdapter, stds, comMap);
- SclService.removeAllControlBlocksAndDatasetsAndExtRefSrcBindings(scdAdapter.getCurrentElem());
- return scdAdapter;
+ SubstationService.addSubstation(scd, ssd);
+ SclService.importSTDElementsInSCD(scd, stds, SUB_NETWORK_TYPES);
+ SclService.removeAllControlBlocksAndDatasetsAndExtRefSrcBindings(scd);
+ return scd;
}
}
diff --git a/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceTest.java b/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceTest.java
index 71e409f3a..1feb4f25e 100644
--- a/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceTest.java
+++ b/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceTest.java
@@ -18,8 +18,8 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.List;
+import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -33,29 +33,30 @@ class SclAutomationServiceTest {
@BeforeEach
void init() {
headerDTO = new HeaderDTO();
+ headerDTO.setId(UUID.randomUUID());
headerDTO.setRevision("hRevision");
headerDTO.setVersion("hVersion");
}
@Test
- void createSCD_should_return_generatedSCD() throws Exception {
+ void createSCD_should_return_generatedSCD() {
// Given
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd.xml");
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
// When
- SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std));
+ SCL scd = SclAutomationService.createSCD(ssd, headerDTO, List.of(std));
// Then
- assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
- assertNull(expectedSCD.getCurrentElem().getHeader().getHistory());
- assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());
- assertEquals(1, expectedSCD.getCurrentElem().getIED().size());
- assertNotNull(expectedSCD.getCurrentElem().getDataTypeTemplates());
- assertEquals(2, expectedSCD.getCurrentElem().getCommunication().getSubNetwork().size());
- assertIsMarshallable(expectedSCD.getCurrentElem());
+ assertNotNull(scd.getHeader().getId());
+ assertNull(scd.getHeader().getHistory());
+ assertEquals(1, scd.getSubstation().size());
+ assertEquals(1, scd.getIED().size());
+ assertNotNull(scd.getDataTypeTemplates());
+ assertEquals(2, scd.getCommunication().getSubNetwork().size());
+ assertIsMarshallable(scd);
}
@Test
- void createSCD_With_HItem() throws Exception {
+ void createSCD_With_HItem() {
// Given
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
historyItem.setWhat("what");
@@ -67,16 +68,16 @@ void createSCD_With_HItem() throws Exception {
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
// When
- SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std1, std2, std3));
+ SCL scd = SclAutomationService.createSCD(ssd, headerDTO, List.of(std1, std2, std3));
// Then
- assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
- assertEquals(1, expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
- assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());
- assertIsMarshallable(expectedSCD.getCurrentElem());
+ assertNotNull(scd.getHeader().getId());
+ assertEquals(1, scd.getHeader().getHistory().getHitem().size());
+ assertEquals(1, scd.getSubstation().size());
+ assertIsMarshallable(scd);
}
@Test
- void createSCD_With_HItems() throws Exception {
+ void createSCD_With_HItems() {
// Given
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
historyItem.setWhat("what");
@@ -92,26 +93,26 @@ void createSCD_With_HItems() throws Exception {
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
// When
- SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std1, std2, std3));
+ SCL scd = SclAutomationService.createSCD(ssd, headerDTO, List.of(std1, std2, std3));
// Then
- assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
- assertEquals(1, expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
- assertEquals("what", expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().get(0).getWhat());
- assertIsMarshallable(expectedSCD.getCurrentElem());
+ assertNotNull(scd.getHeader().getId());
+ assertEquals(1, scd.getHeader().getHistory().getHitem().size());
+ assertEquals("what", scd.getHeader().getHistory().getHitem().get(0).getWhat());
+ assertIsMarshallable(scd);
}
@Test
- void createSCD_SSD_Without_Substation() throws Exception {
+ void createSCD_SSD_Without_Substation() {
// Given
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd_without_substations.xml");
// When & Then
- Set stdListEmpty = new HashSet<>();
+ List stdListEmpty = List.of();
assertThrows(ScdException.class,
() -> SclAutomationService.createSCD(ssd, headerDTO, stdListEmpty));
}
@Test
- void createSCD_should_throw_exception_when_null_ssd() throws Exception {
+ void createSCD_should_throw_exception_when_null_ssd() {
// Given
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
historyItem.setWhat("what");
@@ -119,32 +120,32 @@ void createSCD_should_throw_exception_when_null_ssd() throws Exception {
historyItem.setWhy("because");
headerDTO.getHistoryItems().add(historyItem);
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
- Set stdList = Set.of(std1);
+ List stdList = List.of(std1);
// When & Then
assertThrows(NullPointerException.class, () -> SclAutomationService.createSCD(null, headerDTO, stdList));
}
@Test
- void createSCD_should_throw_exception_when_null_headerDTO() throws Exception {
+ void createSCD_should_throw_exception_when_null_headerDTO() {
// Given
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
- Set stdList = Set.of(std1);
+ List stdList = List.of(std1);
// When & Then
assertThrows(NullPointerException.class, () -> SclAutomationService.createSCD(ssd, null, stdList));
}
@Test
- void createSCD_should_delete_ControlBlocks_DataSet_and_ExtRef_src_attributes() throws Exception {
+ void createSCD_should_delete_ControlBlocks_DataSet_and_ExtRef_src_attributes() {
// Given
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/ssd.xml");
SCL std = SclTestMarshaller.getSCLFromFile("/scl-remove-controlBlocks-dataSet-extRefSrc/scl-with-control-blocks.xml");
// When
- SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std));
+ SCL scd = SclAutomationService.createSCD(ssd, headerDTO, List.of(std));
// Then
- LN0 ln0 = expectedSCD.streamIEDAdapters()
+ LN0 ln0 = new SclRootAdapter(scd).streamIEDAdapters()
.findFirst()
.map(iedAdapter -> iedAdapter.findLDeviceAdapterByLdInst("lDeviceInst1").orElseThrow())
.map(LDeviceAdapter::getLN0Adapter)
@@ -154,7 +155,7 @@ void createSCD_should_delete_ControlBlocks_DataSet_and_ExtRef_src_attributes() t
assertThat(ln0.getDataSet()).isEmpty();
assertThat(ln0.getInputs().getExtRef()).hasSize(2);
assertFalse(ln0.getInputs().getExtRef().get(0).isSetSrcLDInst());
- assertIsMarshallable(expectedSCD.getCurrentElem());
+ assertIsMarshallable(scd);
}
@Test
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTO.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTO.java
index 61385eaa7..475cdb5cc 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTO.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTO.java
@@ -4,13 +4,10 @@
package org.lfenergy.compas.sct.commons.dto;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
import org.lfenergy.compas.sct.commons.scl.com.ConnectedAPAdapter;
+import java.util.Objects;
+
/**
* A representation of the model object Connected AP.
*
@@ -18,39 +15,22 @@
* The following features are supported:
*
*
- * - {@link ConnectedApDTO#getApName() Ap Name}
- * - {@link ConnectedApDTO#getIedName() Ied Name}
+ * - {@link ConnectedApDTO#apName()} () Ap Name}
+ * - {@link ConnectedApDTO#iedName()} () Ied Name}
*
*
* @see org.lfenergy.compas.scl2007b4.model.TConnectedAP
*/
-@Setter
-@Getter
-@NoArgsConstructor
-@AllArgsConstructor
-public class ConnectedApDTO {
- private String iedName;
- private String apName;
-
- /**
- * Create ConnectedApDTO from constructor
- * @param connectedAPAdapter object containing data to use
- */
- public ConnectedApDTO(ConnectedAPAdapter connectedAPAdapter) {
- this.iedName = connectedAPAdapter.getIedName();
- this.apName = connectedAPAdapter.getApName();
- }
+public record ConnectedApDTO(String iedName, String apName) {
/**
* Convert ConnectedAPAdapter object to dto ConnectedApDTO
+ *
* @param connectedAPAdapter object to convert
* @return dto ConnectedApDTO
*/
public static ConnectedApDTO from(ConnectedAPAdapter connectedAPAdapter) {
- ConnectedApDTO connectedApDTO = new ConnectedApDTO();
- connectedApDTO.iedName = connectedAPAdapter.getIedName();
- connectedApDTO.apName = connectedAPAdapter.getApName();
-
- return connectedApDTO;
+ return new ConnectedApDTO(connectedAPAdapter.getIedName(), connectedAPAdapter.getApName());
}
+
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/EnumValDTO.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/EnumValDTO.java
new file mode 100644
index 000000000..f629dbd4a
--- /dev/null
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/EnumValDTO.java
@@ -0,0 +1,8 @@
+// SPDX-FileCopyrightText: 2023 RTE FRANCE
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.sct.commons.dto;
+
+public record EnumValDTO(Integer ord, String value) {
+}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReport.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReport.java
deleted file mode 100644
index 12e11624a..000000000
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReport.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * // SPDX-FileCopyrightText: 2022 RTE FRANCE
- * //
- * // SPDX-License-Identifier: Apache-2.0
- */
-
-package org.lfenergy.compas.sct.commons.dto;
-
-import lombok.*;
-import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Report of services which work on the SCD.
- */
-@AllArgsConstructor
-@NoArgsConstructor
-@Setter
-@Getter
-@Builder
-public class SclReport {
-
- /**
- * The SCD on which errors were encountered
- */
- private SclRootAdapter sclRootAdapter;
-
- /**
- * List of errors
- */
- private List sclReportItems = new ArrayList<>();
-
- /**
- *
- * @return true the service succeeded, false otherwise
- */
- public boolean isSuccess() {
- return sclReportItems.stream().noneMatch(SclReportItem::isFatal);
- }
-}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReportItem.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReportItem.java
index ad0ac0596..b7a3f03eb 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReportItem.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SclReportItem.java
@@ -1,24 +1,12 @@
-// SPDX-FileCopyrightText: 2022 RTE FRANCE
+// SPDX-FileCopyrightText: 2022 2023 RTE FRANCE
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.sct.commons.dto;
-import lombok.AllArgsConstructor;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.ToString;
+public record SclReportItem(String xpath, String message, boolean isError) {
-@Getter
-@EqualsAndHashCode
-@AllArgsConstructor
-@ToString
-public final class SclReportItem {
- private final String xpath;
- private final String message;
- private final boolean isFatal;
-
- public static SclReportItem fatal(String xpath, String message) {
+ public static SclReportItem error(String xpath, String message) {
return new SclReportItem(xpath, message, true);
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java
index 148448461..cd6ffb39c 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTO.java
@@ -8,16 +8,12 @@
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.NoArgsConstructor;
-import org.apache.commons.lang3.tuple.Pair;
-import org.lfenergy.compas.sct.commons.scl.com.CommunicationAdapter;
-import org.lfenergy.compas.sct.commons.scl.com.ConnectedAPAdapter;
+import org.lfenergy.compas.scl2007b4.model.TCommunication;
+import org.lfenergy.compas.scl2007b4.model.TConnectedAP;
+import org.lfenergy.compas.scl2007b4.model.TSubNetwork;
import org.lfenergy.compas.sct.commons.scl.com.SubNetworkAdapter;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
+import java.util.*;
/**
* A representation of the model object Sub Network.
@@ -39,7 +35,7 @@ public class SubNetworkDTO {
private String name;
private SubnetworkType type;
- private Set connectedAPs = new HashSet<>();
+ private final Set connectedAPs = new HashSet<>();
/**
* Constructor
@@ -145,20 +141,21 @@ public static SubnetworkType fromValue(String text) {
}
/**
- * Create default SubnetworkType in Communication node of SCL file
- * @param iedName name of existing IED in SCL
- * @param comAdapter Communication node Adapter object value
- * @param comMap possible name of SubnetworkTypes and corresponding ConnectedAPs
- * @return
+ * Create default Subnetwork in Communication node of SCL file
+ * @param iedName Name of existing IED in SCL
+ * @param communication Communication node in SCL
+ * @param subNetworkTypes Possible name of Subnetwork and corresponding ConnectedAPs
+ * @return List of Subnetwork
*/
- public static Set createDefaultSubnetwork(String iedName, CommunicationAdapter comAdapter, Map, List> comMap){
- Set subNetworkDTOS = new HashSet<>();
- comMap.forEach((subnetworkNameType, apNames) -> {
- SubNetworkDTO subNetworkDTO = new SubNetworkDTO(subnetworkNameType.getLeft(), subnetworkNameType.getRight());
- apNames.forEach(s -> {
- if(getStdConnectedApNames(comAdapter).contains(s)){
- ConnectedApDTO connectedApDTO = new ConnectedApDTO(iedName, s);
- subNetworkDTO.addConnectedAP(connectedApDTO);}
+ public static List createDefaultSubnetwork(String iedName, TCommunication communication, List subNetworkTypes){
+ List subNetworkDTOS = new ArrayList<>();
+ subNetworkTypes.forEach(subnetwork -> {
+ SubNetworkDTO subNetworkDTO = new SubNetworkDTO(subnetwork.subnetworkName(), subnetwork.subnetworkType());
+ subnetwork.accessPointNames().forEach(accessPointName -> {
+ if(getStdConnectedApNames(communication).contains(accessPointName)){
+ ConnectedApDTO connectedApDTO = new ConnectedApDTO(iedName, accessPointName);
+ subNetworkDTO.addConnectedAP(connectedApDTO);
+ }
});
subNetworkDTOS.add(subNetworkDTO);
});
@@ -167,13 +164,15 @@ public static Set createDefaultSubnetwork(String iedName, Communi
/**
* Gets ConnectedAP name's from Communication node
- * @param comAdapter Communication node object value
- * @return
+ * @param communication Communication node object value
+ * @return List of ConnectedAP names
*/
- private static List getStdConnectedApNames(CommunicationAdapter comAdapter){
- return comAdapter.getSubNetworkAdapters().stream()
- .map(SubNetworkAdapter::getConnectedAPAdapters)
- .flatMap(connectedAPAdapters -> connectedAPAdapters.stream().map(ConnectedAPAdapter::getApName))
- .collect(Collectors.toList());
+ private static List getStdConnectedApNames(TCommunication communication){
+ return communication.getSubNetwork().stream()
+ .map(TSubNetwork::getConnectedAP)
+ .flatMap(List::stream)
+ .map(TConnectedAP::getApName)
+ .toList();
}
+
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkTypeDTO.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkTypeDTO.java
new file mode 100644
index 000000000..a247d4313
--- /dev/null
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/SubNetworkTypeDTO.java
@@ -0,0 +1,10 @@
+// SPDX-FileCopyrightText: 2023 RTE FRANCE
+//
+// SPDX-License-Identifier: Apache-2.0
+
+package org.lfenergy.compas.sct.commons.dto;
+
+import java.util.List;
+
+public record SubNetworkTypeDTO(String subnetworkName, String subnetworkType, List accessPointNames) {
+}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ExtRefService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ExtRefService.java
index 3ec2823f6..00ccd1b23 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ExtRefService.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ExtRefService.java
@@ -14,7 +14,6 @@
import org.lfenergy.compas.scl2007b4.model.TExtRef;
import org.lfenergy.compas.scl2007b4.model.TIED;
import org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings;
-import org.lfenergy.compas.sct.commons.dto.SclReport;
import org.lfenergy.compas.sct.commons.dto.SclReportItem;
import java.util.*;
@@ -39,11 +38,11 @@ private ExtRefService() {
*
* @return list of encountered errors
*/
- public static SclReport updateAllExtRefIedNames(SCL scd) {
+ public static List updateAllExtRefIedNames(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
List iedErrors = validateIed(sclRootAdapter);
if (!iedErrors.isEmpty()) {
- return new SclReport(sclRootAdapter, iedErrors);
+ return iedErrors;
}
Map icdSystemVersionToIed = sclRootAdapter.streamIEDAdapters()
.collect(Collectors.toMap(
@@ -53,7 +52,7 @@ public static SclReport updateAllExtRefIedNames(SCL scd) {
Function.identity()
));
- List extRefErrors = sclRootAdapter.streamIEDAdapters()
+ return sclRootAdapter.streamIEDAdapters()
.flatMap(IEDAdapter::streamLDeviceAdapters)
.filter(LDeviceAdapter::hasLN0)
.map(LDeviceAdapter::getLN0Adapter)
@@ -61,8 +60,6 @@ public static SclReport updateAllExtRefIedNames(SCL scd) {
.map(LN0Adapter::getInputsAdapter)
.map(inputsAdapter -> inputsAdapter.updateAllExtRefIedNames(icdSystemVersionToIed))
.flatMap(List::stream).toList();
-
- return new SclReport(sclRootAdapter, extRefErrors);
}
private static List validateIed(SclRootAdapter sclRootAdapter) {
@@ -98,7 +95,7 @@ private static List checkIedUnityOfIcdSystemVersionUuid(SclRootAd
return systemVersionToIedList.entrySet().stream()
.filter(entry -> StringUtils.isNotBlank(entry.getKey()))
.filter(entry -> entry.getValue().size() > 1)
- .map(entry -> SclReportItem.fatal(entry.getValue().stream()
+ .map(entry -> SclReportItem.error(entry.getValue().stream()
.map(tied -> new IEDAdapter(sclRootAdapter, tied))
.map(IEDAdapter::getXPath)
.collect(Collectors.joining(", ")),
@@ -111,12 +108,12 @@ private static List checkIedUnityOfIcdSystemVersionUuid(SclRootAd
* Create All DataSet and ControlBlock in the SCL based on the ExtRef
*
* @param scd input SCD object. It could be modified by adding new DataSet and ControlBlocks
- * @return a report with all errors encountered
+ * @return list of encountered errors
*/
- public static SclReport createDataSetAndControlBlocks(SCL scd) {
+ public static List createDataSetAndControlBlocks(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
Stream lDeviceAdapters = sclRootAdapter.streamIEDAdapters().flatMap(IEDAdapter::streamLDeviceAdapters);
- return createDataSetAndControlBlocks(sclRootAdapter, lDeviceAdapters);
+ return createDataSetAndControlBlocks(lDeviceAdapters);
}
/**
@@ -124,12 +121,12 @@ public static SclReport createDataSetAndControlBlocks(SCL scd) {
*
* @param scd input SCD object. The object will be modified with the new DataSet and ControlBlocks
* @param targetIedName the name of the IED where the ExtRef are
- * @return a report with all the errors encountered
+ * @return list of encountered errors
*/
- public static SclReport createDataSetAndControlBlocks(SCL scd, String targetIedName) {
+ public static List createDataSetAndControlBlocks(SCL scd, String targetIedName) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
- return createDataSetAndControlBlocks(sclRootAdapter, iedAdapter.streamLDeviceAdapters());
+ return createDataSetAndControlBlocks(iedAdapter.streamLDeviceAdapters());
}
@@ -139,24 +136,23 @@ public static SclReport createDataSetAndControlBlocks(SCL scd, String targetIedN
* @param scd input SCD object. The object will be modified with the new DataSet and ControlBlocks
* @param targetIedName the name of the IED where the ExtRef are
* @param targetLDeviceInst the name of the LDevice where the ExtRef are
- * @return a report with all encountered errors
+ * @return list of encountered errors
*/
- public static SclReport createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst) {
+ public static List createDataSetAndControlBlocks(SCL scd, String targetIedName, String targetLDeviceInst) {
if (StringUtils.isBlank(targetIedName)) {
throw new ScdException(MESSAGE_MISSING_IED_NAME_PARAMETER);
}
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
IEDAdapter iedAdapter = sclRootAdapter.getIEDAdapterByName(targetIedName);
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst(targetLDeviceInst);
- return createDataSetAndControlBlocks(sclRootAdapter, Stream.of(lDeviceAdapter));
+ return createDataSetAndControlBlocks(Stream.of(lDeviceAdapter));
}
- private static SclReport createDataSetAndControlBlocks(SclRootAdapter sclRootAdapter, Stream lDeviceAdapters) {
- List sclReportItems = lDeviceAdapters
+ private static List createDataSetAndControlBlocks(Stream lDeviceAdapters) {
+ return lDeviceAdapters
.map(LDeviceAdapter::createDataSetAndControlBlocks)
.flatMap(List::stream)
.toList();
- return new SclReport(sclRootAdapter, sclReportItems);
}
/**
@@ -169,20 +165,19 @@ private static SclReport createDataSetAndControlBlocks(SclRootAdapter sclRootAda
* @param controlBlockNetworkSettings a method tha gives the network configuration information for a given ControlBlock
* @param rangesPerCbType provide NetworkRanges for GSEControl and SampledValueControl. NetworkRanges contains :
* start-end app APPID range (long value), start-end MAC-Addresses (Mac-Addresses values: Ex: "01-0C-CD-01-01-FF")
- * @return a report with all the errors encountered
+ * @return list of encountered errors
* @see Utils#macAddressToLong(String) for the expected MAC address format
* @see ControlBlockNetworkSettings
* @see ControlBlockNetworkSettings.RangesPerCbType
* @see ControlBlockNetworkSettings.NetworkRanges
*/
- public static SclReport configureNetworkForAllControlBlocks(SCL scd, ControlBlockNetworkSettings controlBlockNetworkSettings,
+ public static List configureNetworkForAllControlBlocks(SCL scd, ControlBlockNetworkSettings controlBlockNetworkSettings,
RangesPerCbType rangesPerCbType) {
List sclReportItems = new ArrayList<>();
sclReportItems.addAll(configureNetworkForControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType.gse(), ControlBlockEnum.GSE));
sclReportItems.addAll(configureNetworkForControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType.sampledValue(), ControlBlockEnum.SAMPLED_VALUE));
- return new SclReport(new SclRootAdapter(scd), sclReportItems);
+ return sclReportItems;
}
-
private static List configureNetworkForControlBlocks(SCL scd, ControlBlockNetworkSettings controlBlockNetworkSettings,
NetworkRanges networkRanges, ControlBlockEnum controlBlockEnum) {
PrimitiveIterator.OfLong appIdIterator = Utils.sequence(networkRanges.appIdStart(), networkRanges.appIdEnd());
@@ -199,7 +194,6 @@ private static List configureNetworkForControlBlocks(SCL scd, Con
.flatMap(Optional::stream)
.toList();
}
-
private static Optional configureControlBlockNetwork(ControlBlockNetworkSettings controlBlockNetworkSettings, PrimitiveIterator.OfLong appIdIterator, Iterator macAddressIterator, ControlBlockAdapter controlBlockAdapter) {
SettingsOrError settingsOrError = controlBlockNetworkSettings.getNetworkSettings(controlBlockAdapter);
if (settingsOrError.errorMessage() != null) {
@@ -228,7 +222,6 @@ private static Optional configureControlBlockNetwork(ControlBlock
settings.minTime(), settings.maxTime());
}
-
/**
* Remove ExtRef which are fed by same Control Block
*
@@ -243,14 +236,13 @@ public static List filterDuplicatedExtRefs(List tExtRefs) {
return filteredList;
}
-
/**
* ExtRef Binding For LDevice (inst=LDEPF) that matching LDEPF configuration
* @param scd SCL
* @param settings ILDEPFSettings
- * @return a report contains errors
+ * @return list of encountered errors
*/
- public static SclReport manageBindingForLDEPF(SCL scd, ILDEPFSettings settings) {
+ public static List manageBindingForLDEPF(SCL scd, ILDEPFSettings settings) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
List sclReportItems = new ArrayList<>();
sclRootAdapter.streamIEDAdapters()
@@ -274,11 +266,10 @@ public static SclReport manageBindingForLDEPF(SCL scd, ILDEPFSettings settings)
}
}))
);
- return new SclReport(sclRootAdapter, sclReportItems);
+ return sclReportItems;
}
-
private static void updateLDEPFExtRefBinding(TExtRef extRef, TIED iedSource, LDEPFSettingData setting) {
extRef.setIedName(iedSource.getName());
extRef.setLdInst(setting.getLdInst());
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/PrivateService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/PrivateService.java
index 68d4002ca..54b3a2880 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/PrivateService.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/PrivateService.java
@@ -195,7 +195,7 @@ private static TPrivate createPrivate(JAXBElement> jaxbElement) {
* @return map of ICD_SYSTEM_VERSION_UUID attribute in IED/Private:COMPAS-ICDHeader and related Private coupled with
* all corresponding STD
*/
- public static Map createMapICDSystemVersionUuidAndSTDFile(Set stds) {
+ public static Map createMapICDSystemVersionUuidAndSTDFile(List stds) {
Map icdSysVerToPrivateStdsMap = new HashMap<>();
stds.forEach(std -> std.getIED()
.forEach(ied -> ied.getPrivate()
@@ -252,11 +252,11 @@ public static String stdCheckFormatExceptionMessage(TPrivate key) throws ScdExce
/**
* Creates stream of IcdHeader for all Privates COMPAS-ICDHeader in /Substation of SCL
*
- * @param scdRootAdapter SCL file in which Private should be found
+ * @param scd SCL file in which Private should be found
* @return stream of COMPAS-ICDHeader Private
*/
- public static Stream streamIcdHeaders(SclRootAdapter scdRootAdapter) {
- return scdRootAdapter.getCurrentElem()
+ public static Stream streamIcdHeaders(SCL scd) {
+ return scd
.getSubstation()
.get(0)
.getVoltageLevel()
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclElementAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclElementAdapter.java
index 47c07085f..e90297d47 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclElementAdapter.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclElementAdapter.java
@@ -123,6 +123,6 @@ public String getXPath(){
* @return error description with message and current element xpath
*/
public SclReportItem buildFatalReportItem(String message){
- return SclReportItem.fatal(getXPath(), message);
+ return SclReportItem.error(getXPath(), message);
}
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclService.java
index 6c654489e..273adc80d 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclService.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SclService.java
@@ -36,7 +36,7 @@
*
* - Initialization functions
*
- * - {@link SclService#initScl(Optional, String, String) Initialize the SCL object}
+ * - {@link SclService#initScl(UUID, String, String) Initialize the SCL object}
* - {@link SclService#addHistoryItem(SCL, String, String, String) Adds History object under THeader reference object}
* - {@link SclService#updateHeader(SCL, HeaderDTO) Update Header reference object}
*
@@ -47,7 +47,7 @@
* - Communication features
*
* - {@link SclService#getSubnetwork(SCL) Returns list of SubNetworkDTO }
- * - {@link SclService#addSubnetworks(SCL, Set, Optional) Adds the Subnetwork elements under TCommunication reference object}
+ * - {@link SclService#addSubnetworks(SCL, List, SCL) Adds the Subnetwork elements under TCommunication reference object}
*
* - ExtRef features
*
@@ -65,7 +65,7 @@
*
* - EnumType features
*
- * - {@link SclService#getEnumTypeElements(SCL, String) Returns Map (ord, enumVal) of TEnumType reference object}
+ * - {@link SclService#getEnumTypeValues(SCL, String) Returns Map (ord, enumVal) of TEnumType reference object}
*
*
*
@@ -89,17 +89,16 @@ private SclService() {
/**
* Initialise SCD file with Header and Private SCLFileType
*
- * @param hId optional SCL Header ID, if empty random UUID will be created
+ * @param hId SCL Header ID
* @param hVersion SCL Header Version
* @param hRevision SCL Header Revision
- * @return SclRootAdapter object as SCD file
- * @throws ScdException throws when inconsistenc in SCL file
+ * @return SCL SCD object
+ * @throws ScdException throws when inconsistance in SCL file
*/
- public static SclRootAdapter initScl(Optional hId, String hVersion, String hRevision) throws ScdException {
- UUID headerId = hId.orElseGet(UUID::randomUUID);
- SclRootAdapter scdAdapter = new SclRootAdapter(headerId.toString(), hVersion, hRevision);
+ public static SCL initScl(final UUID hId, final String hVersion, final String hRevision) throws ScdException {
+ SclRootAdapter scdAdapter = new SclRootAdapter(hId.toString(), hVersion, hRevision);
scdAdapter.addPrivate(PrivateService.createPrivate(TCompasSclFileType.SCD));
- return scdAdapter;
+ return scdAdapter.getCurrentElem();
}
/**
@@ -109,13 +108,11 @@ public static SclRootAdapter initScl(Optional hId, String hVersion, String
* @param who Who realize the action
* @param what What kind of action is realized
* @param why Why this action is done
- * @return SclRootAdapter object as SCD file
*/
- public static SclRootAdapter addHistoryItem(SCL scd, String who, String what, String why) {
+ public static void addHistoryItem(SCL scd, String who, String what, String why) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
HeaderAdapter headerAdapter = sclRootAdapter.getHeaderAdapter();
headerAdapter.addHistoryItem(who, what, why);
- return sclRootAdapter;
}
/**
@@ -123,12 +120,10 @@ public static SclRootAdapter addHistoryItem(SCL scd, String who, String what, St
*
* @param scd SCL file in which Header should be updated
* @param headerDTO Header new values
- * @return SclRootAdapter object as SCD file
*/
- public static SclRootAdapter updateHeader(@NonNull SCL scd, @NonNull HeaderDTO headerDTO) {
+ public static void updateHeader(@NonNull SCL scd, @NonNull HeaderDTO headerDTO) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
HeaderAdapter headerAdapter = sclRootAdapter.getHeaderAdapter();
-
boolean hUpdated = false;
String hVersion = headerDTO.getVersion();
String hRevision = headerDTO.getRevision();
@@ -136,12 +131,10 @@ public static SclRootAdapter updateHeader(@NonNull SCL scd, @NonNull HeaderDTO h
headerAdapter.updateVersion(hVersion);
hUpdated = true;
}
-
if (hRevision != null && !hRevision.equals(headerAdapter.getHeaderRevision())) {
headerAdapter.updateRevision(hRevision);
hUpdated = true;
}
-
if (hUpdated && !headerDTO.getHistoryItems().isEmpty()) {
headerAdapter.addHistoryItem(
headerDTO.getHistoryItems().get(0).getWho(),
@@ -149,8 +142,6 @@ public static SclRootAdapter updateHeader(@NonNull SCL scd, @NonNull HeaderDTO h
headerDTO.getHistoryItems().get(0).getWhy()
);
}
-
- return sclRootAdapter;
}
/**
@@ -159,36 +150,31 @@ public static SclRootAdapter updateHeader(@NonNull SCL scd, @NonNull HeaderDTO h
* @param scd SCL file in which IED should be added
* @param iedName name of IED to add in SCL
* @param icd ICD containing IED to add and related DataTypeTemplate
- * @return IEDAdapter as added IED
* @throws ScdException throws when inconsistency between IED to add and SCL file content
*/
- public static IEDAdapter addIED(SCL scd, String iedName, SCL icd) throws ScdException {
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- return sclRootAdapter.addIED(icd, iedName);
+ public static void addIED(SCL scd, String iedName, SCL icd) throws ScdException {
+ new SclRootAdapter(scd).addIED(icd, iedName);
}
/**
* Adds new SubNetworks in SCL file from ICD file
*
* @param scd SCL file in which SubNetworks should be added
- * @param subNetworks list of SubNetworks DTO contenting SubNetwork and ConnectedAp parameter names
+ * @param subNetworks List of SubNetworks DTO contenting SubNetwork and ConnectedAp parameter names
* @param icd ICD file from which SubNetworks functional data are copied from
- * @return optional of CommunicationAdapter object as Communication node of SCL file.
- * Calling getParentAdapter() will give SCL file
* @throws ScdException throws when no Communication in SCL and createIfNotExists == false
*/
- public static Optional addSubnetworks(SCL scd, Set subNetworks, Optional icd) throws ScdException {
+ public static void addSubnetworks(SCL scd, List subNetworks, SCL icd) throws ScdException {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
CommunicationAdapter communicationAdapter;
if (!subNetworks.isEmpty()) {
communicationAdapter = sclRootAdapter.getCommunicationAdapter(true);
-
for (SubNetworkDTO subNetworkDTO : subNetworks) {
String snName = subNetworkDTO.getName();
String snType = subNetworkDTO.getType();
for (ConnectedApDTO accessPoint : subNetworkDTO.getConnectedAPs()) {
- String iedName = accessPoint.getIedName();
- String apName = accessPoint.getApName();
+ String iedName = accessPoint.iedName();
+ String apName = accessPoint.apName();
communicationAdapter.addSubnetwork(snName, snType, iedName, apName);
Optional subNetworkAdapter = communicationAdapter.getSubnetworkByName(snName);
@@ -196,12 +182,9 @@ public static Optional addSubnetworks(SCL scd, SetidEnum from DataTypeTemplate of SCL file
*
- * @param scd SCL file in which EnumType should be found
- * @param idEnum ID of EnumType for which values are retrieved
+ * @param scd SCL file in which EnumType should be found
+ * @param idEnum ID of EnumType for which values are retrieved
* @return list of couple EnumType value and it's order
- * @throws ScdException throws when unkonown EnumType
+ * @throws ScdException throws when unknown EnumType
*/
- public static Set> getEnumTypeElements(SCL scd, String idEnum) throws ScdException {
+ public static Set getEnumTypeValues(SCL scd, String idEnum) throws ScdException {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
DataTypeTemplateAdapter dataTypeTemplateAdapter = sclRootAdapter.getDataTypeTemplateAdapter();
EnumTypeAdapter enumTypeAdapter = dataTypeTemplateAdapter.getEnumTypeAdapterById(idEnum)
.orElseThrow(() -> new ScdException("Unknown EnumType Id: " + idEnum));
return enumTypeAdapter.getCurrentElem().getEnumVal().stream()
- .map(tEnumVal -> Pair.of(tEnumVal.getOrd(), tEnumVal.getValue()))
+ .map(tEnumVal -> new EnumValDTO(tEnumVal.getOrd(), tEnumVal.getValue()))
.collect(Collectors.toSet());
}
@@ -483,20 +466,19 @@ public static Set> getEnumTypeElements(SCL scd, String idE
* import connectedAP and rename ConnectedAP/@iedName in Communication node in SCD file
*
*
- * @param scdRootAdapter adapter object related to SCL file in which content of STD files are imported
- * @param stds list of STD files contenting datas to import into SCD
- * @param comMap couple of Subnetwork name and possible corresponding ConnectAP names
- * @return updated SCD file as SclRootAdapter
- * @throws ScdException throws when inconsistency between Substation of SCL content and gien STD files as :
- *
- * - ICD_SYSTEM_VERSION_UUID in IED/Private of STD is not present in COMPAS-ICDHeader in Substation/../LNode of SCL
- * - There are several STD files corresponding to ICD_SYSTEM_VERSION_UUID of COMPAS-ICDHeader in Substation/../LNode of SCL
- * - There is no STD file found corresponding to COMPAS-ICDHeader in Substation/../LNode of SCL
- * - COMPAS-ICDHeader is not the same in Substation/../LNode of SCL and in IED/Private of STD
- * - COMPAS_ICDHEADER in Substation/../LNode of SCL not found in IED/Private of STD
- *
+ * @param scd SCL object in which content of STD files are imported
+ * @param stds list of STD files contenting datas to import into SCD
+ * @param subNetworkTypes couple of Subnetwork name and possible corresponding ConnectedAP names
+ * @throws ScdException throws when inconsistency between Substation of SCL content and gien STD files as :
+ *
+ * - ICD_SYSTEM_VERSION_UUID in IED/Private of STD is not present in COMPAS-ICDHeader in Substation/../LNode of SCL
+ * - There are several STD files corresponding to ICD_SYSTEM_VERSION_UUID of COMPAS-ICDHeader in Substation/../LNode of SCL
+ * - There is no STD file found corresponding to COMPAS-ICDHeader in Substation/../LNode of SCL
+ * - COMPAS-ICDHeader is not the same in Substation/../LNode of SCL and in IED/Private of STD
+ * - COMPAS_ICDHEADER in Substation/../LNode of SCL not found in IED/Private of STD
+ *
*/
- public static SclRootAdapter importSTDElementsInSCD(@NonNull SclRootAdapter scdRootAdapter, Set stds, Map, List> comMap) throws ScdException {
+ public static void importSTDElementsInSCD(SCL scd, List stds, List subNetworkTypes) throws ScdException {
//Check SCD and STD compatibilities
Map mapICDSystemVersionUuidAndSTDFile = PrivateService.createMapICDSystemVersionUuidAndSTDFile(stds);
@@ -504,7 +486,8 @@ public static SclRootAdapter importSTDElementsInSCD(@NonNull SclRootAdapter scdR
// List all Private and remove duplicated one with same iedName
// For each Private.ICDSystemVersionUUID and Private.iedName find STD File
List iedNamesUsed = new ArrayList<>();
- PrivateService.streamIcdHeaders(scdRootAdapter)
+ SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
+ PrivateService.streamIcdHeaders(scd)
.forEach(icdHeader -> {
if (!iedNamesUsed.contains(icdHeader.getIedName())) {
String iedName = icdHeader.getIedName();
@@ -523,12 +506,11 @@ public static SclRootAdapter importSTDElementsInSCD(@NonNull SclRootAdapter scdR
scdRootAdapter.addIED(std, iedName);
//import connectedAP and rename ConnectedAP/@iedName
- CommunicationAdapter comAdapter = stdRootAdapter.getCommunicationAdapter(false);
- Set subNetworkDTOSet = SubNetworkDTO.createDefaultSubnetwork(iedName, comAdapter, comMap);
- addSubnetworks(scdRootAdapter.getCurrentElem(), subNetworkDTOSet, Optional.of(std));
+ TCommunication communication = stdRootAdapter.getCurrentElem().getCommunication();
+ List subNetworkDTOSet = SubNetworkDTO.createDefaultSubnetwork(iedName, communication, subNetworkTypes);
+ addSubnetworks(scdRootAdapter.getCurrentElem(), subNetworkDTOSet, std);
}
});
- return scdRootAdapter;
}
@@ -560,73 +542,65 @@ public static void removeAllControlBlocksAndDatasetsAndExtRefSrcBindings(final S
* Activate used LDevice and Deactivate unused LDevice in {@link TLNode TLNode }
*
* @param scd SCL file for which LDevice should be activated or deactivated
- * @return SclReport Object that contain SCL file and set of errors
+ * @return list of encountered errors
*/
- public static SclReport updateLDeviceStatus(SCL scd) {
+ public static List updateLDeviceStatus(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
SubstationAdapter substationAdapter = sclRootAdapter.getSubstationAdapter();
final List> iedNameLdInstList = substationAdapter.getIedAndLDeviceNamesForLN0FromLNode();
- List errors = sclRootAdapter.streamIEDAdapters()
+ return sclRootAdapter.streamIEDAdapters()
.flatMap(IEDAdapter::streamLDeviceAdapters)
.map(LDeviceAdapter::getLN0Adapter)
.map(ln0Adapter -> ln0Adapter.updateLDeviceStatus(iedNameLdInstList))
.flatMap(Optional::stream)
.toList();
- SclReport sclReport = new SclReport();
- sclReport.getSclReportItems().addAll(errors);
- sclReport.setSclRootAdapter(sclRootAdapter);
- return sclReport;
}
/**
* Checks Control Blocks, DataSets and FCDA number limitation into Access Points
*
* @param scd SCL file for which LDevice should be activated or deactivated
- * @return SclReport Object that contain SCL file and set of errors
+ * @return list of encountered errors
*/
- public static SclReport analyzeDataGroups(SCL scd) {
+ public static List analyzeDataGroups(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- List sclReportItems = sclRootAdapter.streamIEDAdapters()
+ return sclRootAdapter.streamIEDAdapters()
.map(iedAdapter -> {
List list = new ArrayList<>();
list.addAll(iedAdapter.checkDataGroupCoherence());
list.addAll(iedAdapter.checkBindingDataGroupCoherence());
return list;
}).flatMap(Collection::stream).toList();
-
- return new SclReport(sclRootAdapter, sclReportItems);
}
/**
* Update DAIs of DO InRef in all LN0 of the SCD using matching ExtRef information.
*
* @param scd SCL file for which DOs InRef should be updated with matching ExtRef information
- * @return SclReport Object that contain SCL file and set of errors
+ * @return list of encountered errors
*/
- public static SclReport updateDoInRef(SCL scd) {
+ public static List updateDoInRef(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- List sclReportItems = sclRootAdapter.streamIEDAdapters()
+ return sclRootAdapter.streamIEDAdapters()
.flatMap(IEDAdapter::streamLDeviceAdapters)
.map(LDeviceAdapter::getLN0Adapter)
.map(LN0Adapter::updateDoInRef)
.flatMap(List::stream)
.toList();
- return new SclReport(sclRootAdapter, sclReportItems);
}
/**
* Update and/or create Monitoring LNs (LSVS and LGOS) for bound GOOSE and SMV Control Blocks
*
* @param scd SCL file for which LNs (LSVS and LGOS) should be updated and/or created in each LDevice LDSUIED with matching ExtRef information
- * @return SclReport Object that contain SCL file and set of errors
+ * @return list of encountered errors
*/
- public static SclReport manageMonitoringLns(SCL scd) {
+ public static List manageMonitoringLns(SCL scd) {
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- List sclReportItems = sclRootAdapter.streamIEDAdapters()
+ return sclRootAdapter.streamIEDAdapters()
.filter(iedAdapter -> !iedAdapter.getName().contains(IED_TEST_NAME))
.map(IEDAdapter::manageMonitoringLns)
.flatMap(List::stream)
.toList();
- return new SclReport(sclRootAdapter, sclReportItems);
}
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SubstationService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SubstationService.java
index ab7cd032e..8e92407dd 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SubstationService.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/SubstationService.java
@@ -33,7 +33,7 @@
public final class SubstationService {
/**
- * Private Controlller, should not be instanced
+ * Private Controller, should not be instanced
*/
private SubstationService() {
throw new UnsupportedOperationException("This service class cannot be instantiated");
@@ -43,29 +43,23 @@ private SubstationService() {
* Adds or Updates Substation section in SCL
* @param scd SCL file in which Substation should be added/updated
* @param ssd SCL file from which Substation should be copied
- * @return SclRootAdapter object as SCD file
* @throws ScdException throws when SCD contents already another Substation, or with different name, or contents
* more than one Substation
*/
- public static SclRootAdapter addSubstation(@NonNull SCL scd, @NonNull SCL ssd) throws ScdException {
- SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
- SclRootAdapter ssdRootAdapter = new SclRootAdapter(ssd);
- if (scdRootAdapter.getCurrentElem().getSubstation().size() > 1) {
- throw new ScdException(String.format("SCD file must have 0 or 1 Substation, but got %d",
- scdRootAdapter.getCurrentElem().getSubstation().size()));
+ public static void addSubstation(@NonNull SCL scd, @NonNull SCL ssd) throws ScdException {
+ if (scd.getSubstation().size() > 1) {
+ throw new ScdException(String.format("SCD file must have 0 or 1 Substation, but got %d", scd.getSubstation().size()));
}
- if (ssdRootAdapter.getCurrentElem().getSubstation().size() != 1) {
- throw new ScdException(String.format("SSD file must have exactly 1 Substation, but got %d",
- ssdRootAdapter.getCurrentElem().getSubstation().size()));
+ if (ssd.getSubstation().size() != 1) {
+ throw new ScdException(String.format("SSD file must have exactly 1 Substation, but got %d", ssd.getSubstation().size()));
}
- TSubstation ssdTSubstation = ssdRootAdapter.currentElem.getSubstation().get(0);
- if (scdRootAdapter.getCurrentElem().getSubstation().isEmpty()) {
- scdRootAdapter.getCurrentElem().getSubstation().add(ssdTSubstation);
- return scdRootAdapter;
+ TSubstation ssdTSubstation = ssd.getSubstation().get(0);
+ if (scd.getSubstation().isEmpty()) {
+ scd.getSubstation().add(ssdTSubstation);
} else {
- TSubstation scdTSubstation = scdRootAdapter.currentElem.getSubstation().get(0);
+ TSubstation scdTSubstation = scd.getSubstation().get(0);
if (scdTSubstation.getName().equalsIgnoreCase(ssdTSubstation.getName())) {
- SubstationAdapter scdSubstationAdapter = scdRootAdapter.getSubstationAdapter(scdTSubstation.getName());
+ SubstationAdapter scdSubstationAdapter = new SclRootAdapter(scd).getSubstationAdapter(scdTSubstation.getName());
for (TVoltageLevel tvl : ssdTSubstation.getVoltageLevel()) {
updateVoltageLevel(scdSubstationAdapter, tvl);
}
@@ -73,7 +67,6 @@ public static SclRootAdapter addSubstation(@NonNull SCL scd, @NonNull SCL ssd) t
throw new ScdException("SCD file must have only one Substation and the Substation name from SSD file is" +
" different from the one in SCD file. The files are rejected.");
}
- return scdRootAdapter;
}
/**
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapter.java
index f2fcfb0e9..3569f4ef6 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapter.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapter.java
@@ -73,19 +73,17 @@ public String getApName() {
/**
* Copies Address and PhysicalConnection nodes from ICD file
- * @param icd ICD file
+ * @param icd ICD object
* @see Issue !76
* Copies Address and PhysicalConnection nodes from ICD file
*/
- public void copyAddressAndPhysConnFromIcd(Optional icd) {
- if (icd.isPresent() && icd.get().getCommunication() != null) {
- icd.stream()
- .map(SCL::getCommunication)
+ public void copyAddressAndPhysConnFromIcd(SCL icd) {
+ if (icd != null && icd.getCommunication() != null) {
+ icd.getCommunication().getSubNetwork().stream()
+ .flatMap(tSubNetwork -> tSubNetwork.getConnectedAP().stream())
+ .filter(connectedAP -> connectedAP.getApName().equals(currentElem.getApName()))
.findFirst()
- .flatMap(com -> com.getSubNetwork().stream()
- .flatMap(subNet -> subNet.getConnectedAP().stream()
- .filter(connAP -> connAP.getApName().equals(currentElem.getApName())))
- .findFirst()).ifPresent(connectedAP -> {
+ .ifPresent(connectedAP -> {
currentElem.setAddress(connectedAP.getAddress());
currentElem.getPhysConn().addAll(connectedAP.getPhysConn());
});
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java
index 6b00ec4d8..bc54fe6bf 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapter.java
@@ -90,7 +90,7 @@ public List checkFCDALimitations() {
.map(abstractLNAdapter -> abstractLNAdapter.getCurrentElem().getDataSet())
.flatMap(Collection::stream)
.filter(tDataSet -> tDataSet.getFCDA().size() > max)
- .map(tDataSet -> SclReportItem.fatal(getXPath(), String.format("There are too much FCDA for the DataSet %s for the LDevice %s"
+ .map(tDataSet -> SclReportItem.error(getXPath(), String.format("There are too much FCDA for the DataSet %s for the LDevice %s"
+ " in IED %s: %d > %d max", tDataSet.getName(), lDeviceAdapter.getInst(), parentAdapter.getName(),
tDataSet.getFCDA().size(), max))
).toList()
@@ -106,7 +106,7 @@ public List checkFCDALimitations() {
public Optional checkControlsLimitation(ServicesConfigEnum servicesConfigEnum) {
long max = getMaxInstanceAuthorized(servicesConfigEnum);
long value = getNumberOfItems(servicesConfigEnum);
- return max == MAX_OCCURRENCE_NO_LIMIT_VALUE || value <= max ? Optional.empty() : Optional.of(SclReportItem.fatal(getXPath(),
+ return max == MAX_OCCURRENCE_NO_LIMIT_VALUE || value <= max ? Optional.empty() : Optional.of(SclReportItem.error(getXPath(),
String.format("There are too much %ss for the IED %s: %d > %d max", servicesConfigEnum.getDisplayName(), parentAdapter.getName(), value, max)));
}
@@ -212,7 +212,7 @@ public Optional checkLimitationForBoundIedFcdas(List tEx
.size();
return value <= max ? Optional.empty() :
- Optional.of(SclReportItem.fatal(getParentAdapter().getXPath(),
+ Optional.of(SclReportItem.error(getParentAdapter().getXPath(),
"The Client IED %s subscribes to too much FCDA: %d > %d max".formatted(getParentAdapter().getName(), value, max)));
}
@@ -256,7 +256,7 @@ private List checkExtRefWithoutServiceType(List tExtRefs
return tExtRefs.stream()
.filter(tExtRef -> !tExtRef.isSetServiceType())
.map(tExtRef ->
- SclReportItem.fatal("%s/Inputs/ExtRef[%s]".formatted(xPath,
+ SclReportItem.error("%s/Inputs/ExtRef[%s]".formatted(xPath,
Utils.xpathAttributeFilter("desc", tExtRef.getDesc())),
"ExtRef is missing ServiceType attribute"))
.toList();
@@ -288,7 +288,7 @@ private Optional checkLimitationForOneControlType(Set tE
long max = getMaxInstanceAuthorizedForBoundIED(servicesConfigEnum);
long value = tExtRefs.size();
return max == AccessPointAdapter.MAX_OCCURRENCE_NO_LIMIT_VALUE || value <= max ? Optional.empty() :
- Optional.of(SclReportItem.fatal(getParentAdapter().getXPath(),
+ Optional.of(SclReportItem.error(getParentAdapter().getXPath(),
"The Client IED %s subscribes to too much %ss: %d > %d max".formatted(getParentAdapter().getName(), servicesConfigEnum.getDisplayName(),
value, max)));
}
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java
index 485db7cfa..e932bd816 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapter.java
@@ -181,7 +181,7 @@ private Optional validateExtRefSource(TExtRef extRef, IEDAdapter
case ON -> null;
};
} catch (IllegalArgumentException e) {
- return SclReportItem.fatal(extRefXPath(extRef.getDesc()), String.format(MESSAGE_SOURCE_LDEVICE_STATUS_NEITHER_ON_NOR_OFF, sourceLDevice.getXPath()));
+ return SclReportItem.error(extRefXPath(extRef.getDesc()), String.format(MESSAGE_SOURCE_LDEVICE_STATUS_NEITHER_ON_NOR_OFF, sourceLDevice.getXPath()));
}
});
}
@@ -211,7 +211,7 @@ private Optional warningReportItem(TExtRef extRef, String message
}
private Optional fatalReportItem(TExtRef extRef, String message) {
- return Optional.of(SclReportItem.fatal(extRefXPath(extRef.getDesc()), message));
+ return Optional.of(SclReportItem.error(extRefXPath(extRef.getDesc()), message));
}
private String extRefXPath(String extRefDesc) {
diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java
index 88fde33bd..a30e2fc57 100644
--- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java
+++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapter.java
@@ -493,9 +493,9 @@ public List getExtRefBayReferenceForActifLDEPF(fi
List extRefBayReferenceList = new ArrayList<>();
IEDAdapter parentIedAdapter = getParentAdapter();
if (parentIedAdapter.getPrivateCompasBay().isEmpty()) {
- sclReportItems.add(SclReportItem.fatal(getXPath(), "The IED has no Private Bay"));
+ sclReportItems.add(SclReportItem.error(getXPath(), "The IED has no Private Bay"));
if (parentIedAdapter.getCompasICDHeader().isEmpty()) {
- sclReportItems.add(SclReportItem.fatal(getXPath(), "The IED has no Private compas:ICDHeader"));
+ sclReportItems.add(SclReportItem.error(getXPath(), "The IED has no Private compas:ICDHeader"));
}
return Collections.emptyList();
}
@@ -504,7 +504,7 @@ public List getExtRefBayReferenceForActifLDEPF(fi
if (LdeviceStatus.ON.equals(s)) {
extRefBayReferenceList.addAll(getLN0Adapter().getInputsAdapter().getCurrentElem().getExtRef().stream().map(extRef -> new ExtRefInfo.ExtRefBayReference(parentIedAdapter.getName(), parentIedAdapter.getPrivateCompasBay().get(), extRef)).toList());
}
- }, () -> 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)));
+ }, () -> 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)));
return extRefBayReferenceList;
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTOTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTOTest.java
index c4e5fba9f..cdab91e20 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTOTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ConnectedApDTOTest.java
@@ -20,14 +20,14 @@ void testConstruction(){
Mockito.when(connectedAPAdapter.getApName()).thenReturn(DTO.AP_NAME);
Mockito.when(connectedAPAdapter.getIedName()).thenReturn(DTO.HOLDER_IED_NAME);
- ConnectedApDTO connectedApDTO = new ConnectedApDTO(connectedAPAdapter);
+ ConnectedApDTO connectedApDTO = ConnectedApDTO.from(connectedAPAdapter);
- assertEquals(DTO.HOLDER_IED_NAME, connectedApDTO.getIedName());
- assertEquals(DTO.AP_NAME, connectedApDTO.getApName());
+ assertEquals(DTO.HOLDER_IED_NAME, connectedApDTO.iedName());
+ assertEquals(DTO.AP_NAME, connectedApDTO.apName());
connectedApDTO = ConnectedApDTO.from(connectedAPAdapter);
- assertEquals(DTO.HOLDER_IED_NAME, connectedApDTO.getIedName());
- assertEquals(DTO.AP_NAME, connectedApDTO.getApName());
+ assertEquals(DTO.HOLDER_IED_NAME, connectedApDTO.iedName());
+ assertEquals(DTO.AP_NAME, connectedApDTO.apName());
}
}
\ No newline at end of file
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ControlBlockNetworkSettingsTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ControlBlockNetworkSettingsTest.java
index 237d7e5f2..abd09200f 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ControlBlockNetworkSettingsTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/ControlBlockNetworkSettingsTest.java
@@ -117,8 +117,7 @@ void constructor_when_unsupported_cbType_should_throw_exception() {
void getNetworkSettings_should_return_settings_for_bay_internal_controlBlock() {
//Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_controlblock_network_configuration.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
+ ControlBlockAdapter controlBlockAdapter = findControlBlock(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
//When
SettingsOrError settingsOrError = controlBlockNetworkSettings.getNetworkSettings(controlBlockAdapter);
@@ -139,8 +138,7 @@ void getNetworkSettings_should_return_settings_for_bay_internal_controlBlock() {
void getNetworkSettings_should_return_settings_for_bay_external_controlBlock() {
//Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_controlblock_network_configuration.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter, "IED_NAME3", "LD_INST31", "CB_LD_INST31_GSE", ControlBlockEnum.GSE);
+ ControlBlockAdapter controlBlockAdapter = findControlBlock(scd, "IED_NAME3", "LD_INST31", "CB_LD_INST31_GSE", ControlBlockEnum.GSE);
//When
SettingsOrError settingsOrError = controlBlockNetworkSettings.getNetworkSettings(controlBlockAdapter);
@@ -161,8 +159,7 @@ void getNetworkSettings_should_return_settings_for_bay_external_controlBlock() {
void getNetworkSettings_should_return_vlanId_null_when_column_contains_none() {
//Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_controlblock_network_configuration.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter, "IED_NAME2", "LD_INST21", "CB_LD_INST21_SVI", ControlBlockEnum.SAMPLED_VALUE);
+ ControlBlockAdapter controlBlockAdapter = findControlBlock(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_SVI", ControlBlockEnum.SAMPLED_VALUE);
//When
SettingsOrError settingsOrError = controlBlockNetworkSettings.getNetworkSettings(controlBlockAdapter);
@@ -179,8 +176,8 @@ void getNetworkSettings_should_return_null_when_row_not_found_in_csv_file() {
//Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_controlblock_network_configuration.xml");
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- findIed(sclRootAdapter, "IED_NAME2").getCompasSystemVersion().get().setMainSystemVersion("99.99");
- ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
+ findIed(sclRootAdapter.getCurrentElem(), "IED_NAME2").getCompasSystemVersion().get().setMainSystemVersion("99.99");
+ ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter.getCurrentElem(), "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
//When
SettingsOrError settingsOrError = controlBlockNetworkSettings.getNetworkSettings(controlBlockAdapter);
@@ -196,8 +193,8 @@ void getNetworkSettings_should_return_null_when_missing_ied_private(PrivateEnum
//Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_controlblock_network_configuration.xml");
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- PrivateService.removePrivates(findIed(sclRootAdapter, "IED_NAME2").getCurrentElem(), missingPrivate);
- ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
+ PrivateService.removePrivates(findIed(sclRootAdapter.getCurrentElem(), "IED_NAME2").getCurrentElem(), missingPrivate);
+ ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter.getCurrentElem(), "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
//When
SettingsOrError settingsOrError = controlBlockNetworkSettings.getNetworkSettings(controlBlockAdapter);
@@ -212,9 +209,8 @@ void getNetworkSettings_should_return_null_when_missing_ied_private(PrivateEnum
void getNetworkSettings_should_return_null_when_missing_ied_private_attributes(Consumer transformIedPrivate) {
//Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_controlblock_network_configuration.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- ControlBlockAdapter controlBlockAdapter = findControlBlock(sclRootAdapter, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
- IEDAdapter iedAdapter = findIed(sclRootAdapter, "IED_NAME2");
+ ControlBlockAdapter controlBlockAdapter = findControlBlock(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", ControlBlockEnum.GSE);
+ IEDAdapter iedAdapter = findIed(scd, "IED_NAME2");
transformIedPrivate.accept(iedAdapter);
//When
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DTO.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DTO.java
index a31c47d99..7193c0129 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DTO.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/DTO.java
@@ -4,13 +4,10 @@
package org.lfenergy.compas.sct.commons.dto;
-import org.apache.commons.lang3.tuple.Pair;
import org.lfenergy.compas.scl2007b4.model.*;
import java.time.LocalDateTime;
-import java.util.Arrays;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
public class DTO {
@@ -20,15 +17,6 @@ public class DTO {
public static final String AP_NAME = "AP_NAME";
public static final String AP_NAME_2 = "AP_NAME_2";
- public static ConnectedApDTO createCapDTO() {
-
- ConnectedApDTO cap = new ConnectedApDTO();
- cap.setApName(AP_NAME);
- cap.setIedName(HOLDER_IED_NAME);
-
- return cap;
- }
-
/*-----------------------------------------------*/
/* ExtRefInfo */
/*-----------------------------------------------*/
@@ -313,5 +301,7 @@ public static HeaderDTO.HistoryItem createHeaderItem(String now) {
return historyItem;
}
- public static final Map, List> comMap = Map.of(Pair.of("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString()), Arrays.asList("PROCESS_AP", "TOTO_AP_GE"), Pair.of("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.IP.toString()), Arrays.asList("ADMIN_AP", "TATA_AP_EFFACEC"));
+ public static final List SUB_NETWORK_TYPES = List.of(
+ new SubNetworkTypeDTO("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString(), List.of("PROCESS_AP", "TOTO_AP_GE")),
+ new SubNetworkTypeDTO("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString(), List.of("ADMIN_AP", "TATA_AP_EFFACEC")));
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTOTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTOTest.java
index e9471bc07..ffd5623bd 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTOTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/SubNetworkDTOTest.java
@@ -4,20 +4,19 @@
package org.lfenergy.compas.sct.commons.dto;
-import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.Test;
-import org.lfenergy.compas.sct.commons.scl.com.CommunicationAdapter;
+import org.lfenergy.compas.scl2007b4.model.TCommunication;
+import org.lfenergy.compas.scl2007b4.model.TConnectedAP;
+import org.lfenergy.compas.scl2007b4.model.TSubNetwork;
import org.lfenergy.compas.sct.commons.scl.com.ConnectedAPAdapter;
import org.lfenergy.compas.sct.commons.scl.com.SubNetworkAdapter;
import org.mockito.Mockito;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.when;
class SubNetworkDTOTest {
@@ -35,11 +34,11 @@ void testConstructor(){
void testFrom(){
SubNetworkAdapter subNetworkAdapter = Mockito.mock(SubNetworkAdapter.class);
ConnectedAPAdapter connectedAPAdapter = Mockito.mock(ConnectedAPAdapter.class);
- Mockito.when(subNetworkAdapter.getConnectedAPAdapters()).thenReturn(List.of(connectedAPAdapter));
- Mockito.when(subNetworkAdapter.getName()).thenReturn("sName");
- Mockito.when(subNetworkAdapter.getType()).thenReturn(SubNetworkDTO.SubnetworkType.IP.toString());
- Mockito.when(connectedAPAdapter.getApName()).thenReturn(DTO.AP_NAME);
- Mockito.when(connectedAPAdapter.getIedName()).thenReturn(DTO.HOLDER_IED_NAME);
+ when(subNetworkAdapter.getConnectedAPAdapters()).thenReturn(List.of(connectedAPAdapter));
+ when(subNetworkAdapter.getName()).thenReturn("sName");
+ when(subNetworkAdapter.getType()).thenReturn(SubNetworkDTO.SubnetworkType.IP.toString());
+ when(connectedAPAdapter.getApName()).thenReturn(DTO.AP_NAME);
+ when(connectedAPAdapter.getIedName()).thenReturn(DTO.HOLDER_IED_NAME);
SubNetworkDTO subNetworkDTO = SubNetworkDTO.from(subNetworkAdapter);
assertEquals("sName",subNetworkDTO.getName());
@@ -49,23 +48,23 @@ void testFrom(){
}
@Test
- void testCreateDefaultSubnetwork() {
- CommunicationAdapter comAdapter = Mockito.mock(CommunicationAdapter.class);
- SubNetworkAdapter subNetworkAdapter = Mockito.mock(SubNetworkAdapter.class);
- ConnectedAPAdapter connectedAPAdapter = Mockito.mock(ConnectedAPAdapter.class);
-
- Mockito.when(comAdapter.getSubNetworkAdapters()).thenReturn(List.of(subNetworkAdapter));
- Mockito.when(subNetworkAdapter.getConnectedAPAdapters()).thenReturn(List.of(connectedAPAdapter));
- Mockito.when(subNetworkAdapter.getName()).thenReturn("sName");
- Mockito.when(subNetworkAdapter.getType()).thenReturn(SubNetworkDTO.SubnetworkType.IP.toString());
- Mockito.when(connectedAPAdapter.getApName()).thenReturn("PROCESS_AP");
- Mockito.when(connectedAPAdapter.getIedName()).thenReturn("IEDName");
-
- final Map, List> comMap = Map.of(
- Pair.of("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString()), Arrays.asList("PROCESS_AP", "TOTO_AP_GE"),
- Pair.of("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.IP.toString()), Arrays.asList("ADMIN_AP","TATA_AP_EFFACEC"));
-
- Set subNetworkDTOS = SubNetworkDTO.createDefaultSubnetwork("IEDName", comAdapter, comMap);
+ void createDefaultSubnetwork_should_return_filtered_subnetwork_list() {
+ //When
+ TCommunication communication = Mockito.mock(TCommunication.class);
+ TSubNetwork subNetwork1 = new TSubNetwork();
+ subNetwork1.setName("sName");
+ subNetwork1.setName(SubNetworkDTO.SubnetworkType.IP.toString());
+ TConnectedAP connectedAP1 = new TConnectedAP();
+ connectedAP1.setApName("PROCESS_AP");
+ connectedAP1.setIedName("IEDName");
+ subNetwork1.getConnectedAP().add(connectedAP1);
+ when(communication.getSubNetwork()).thenReturn(List.of(subNetwork1));
+ List subNetworkTypes =List.of(
+ new SubNetworkTypeDTO("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString(), List.of("PROCESS_AP", "TOTO_AP_GE")),
+ new SubNetworkTypeDTO("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.IP.toString(), List.of("ADMIN_AP", "TATA_AP_EFFACEC")));
+ //When
+ List subNetworkDTOS = SubNetworkDTO.createDefaultSubnetwork("IEDName", communication, subNetworkTypes);
+ //Then
assertThat(subNetworkDTOS).hasSize(2);
SubNetworkDTO expectedSubNetwork = subNetworkDTOS.stream().filter(subNetworkDTO -> !subNetworkDTO.getConnectedAPs().isEmpty()).findFirst().orElse(new SubNetworkDTO());
assertThat(expectedSubNetwork.getConnectedAPs()).hasSize(1);
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ExtRefServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ExtRefServiceTest.java
index f95985f8b..a30628ff8 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ExtRefServiceTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ExtRefServiceTest.java
@@ -56,12 +56,12 @@ void updateAllExtRefIedNames_should_update_iedName_and_ExtRefIedName() {
// Given : An ExtRef with a matching compas:Flow
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_success.xml");
// When
- SclReport sclReport = ExtRefService.updateAllExtRefIedNames(scd);
+ ExtRefService.updateAllExtRefIedNames(scd);
// Then
- TExtRef extRef = findExtRef(sclReport, "IED_NAME1", "LD_INST11", "STAT_LDSUIED_LPDO 1 Sortie_13_BOOLEAN_18_stVal_1");
+ TExtRef extRef = findExtRef(scd, "IED_NAME1", "LD_INST11", "STAT_LDSUIED_LPDO 1 Sortie_13_BOOLEAN_18_stVal_1");
assertThat(extRef.getIedName()).isEqualTo("IED_NAME2");
- TInputs inputs = findLDevice(sclReport, "IED_NAME1", "LD_INST11")
+ TInputs inputs = findLDevice(scd, "IED_NAME1", "LD_INST11")
.getLN0Adapter()
.getCurrentElem()
.getInputs();
@@ -75,10 +75,10 @@ void updateAllExtRefIedNames_should_return_success_status() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_success.xml");
// When
- SclReport sclReport = ExtRefService.updateAllExtRefIedNames(scd);
+ List sclReportItems = ExtRefService.updateAllExtRefIedNames(scd);
// Then
- assertThat(sclReport.isSuccess())
- .overridingErrorMessage(String.valueOf(sclReport.getSclReportItems()))
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError))
+ .overridingErrorMessage(String.valueOf(sclReportItems))
.isTrue();
}
@@ -87,11 +87,11 @@ void updateAllExtRefIedNames_should_return_success_status() {
void updateAllExtRefIedNames_should_report_errors(String testCase, SCL scl, SclReportItem... errors) {
// Given : scl parameter
// When
- SclReport sclReport = ExtRefService.updateAllExtRefIedNames(scl);
+ List sclReportItems = ExtRefService.updateAllExtRefIedNames(scl);
// Then : the sclReport should report all errors described in the comments in the SCD file
- assertThat(sclReport).isNotNull();
- assertThat(sclReport.isSuccess()).isFalse();
- assertThat(sclReport.getSclReportItems()).containsExactlyInAnyOrder(errors);
+ assertThat(sclReportItems).isNotNull();
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse();
+ assertThat(sclReportItems).containsExactlyInAnyOrder(errors);
}
public static Stream updateAllExtRefIedNamesErrors() {
@@ -100,18 +100,18 @@ public static Stream updateAllExtRefIedNamesErrors() {
"Errors on ExtRefs",
SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml"),
new SclReportItem[]{
- SclReportItem.fatal(
+ SclReportItem.error(
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
"/LN0/Inputs/ExtRef[@desc=\"No matching compas:Flow\"]",
"The signal ExtRef has no matching compas:Flow Private"),
- SclReportItem.fatal(
+ SclReportItem.error(
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
"/LN0/Inputs/ExtRef[@desc=\"Matching two compas:Flow\"]",
"The signal ExtRef has more than one matching compas:Flow Private"),
- SclReportItem.fatal(
+ SclReportItem.error(
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST13\"]",
"The Ldevice status test does not exist. It should be among [on, off]"),
- SclReportItem.fatal(
+ SclReportItem.error(
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST14\"]",
"The LDevice status is undefined"),
SclReportItem.warning(
@@ -131,12 +131,12 @@ public static Stream updateAllExtRefIedNamesErrors() {
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
"/LN0/Inputs/ExtRef[@desc=\"Source LDevice is off for this ExtRef\"]",
"The signal ExtRef source LDevice /SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST22\"] status is off"),
- SclReportItem.fatal(
+ SclReportItem.error(
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
"/LN0/Inputs/ExtRef[@desc=\"Source LDevice is undefined for this ExtRef\"]",
"The signal ExtRef source LDevice /SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST23\"] status is " +
"undefined"),
- SclReportItem.fatal(
+ SclReportItem.error(
"/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]" +
"/LN0/Inputs/ExtRef[@desc=\"Source LDevice is neither on nor off for this ExtRef\"]",
"The signal ExtRef source LDevice /SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST24\"] " +
@@ -146,12 +146,12 @@ public static Stream updateAllExtRefIedNamesErrors() {
"Errors on IEDs",
SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_ied_errors.xml"),
new SclReportItem[]{
- SclReportItem.fatal(
+ SclReportItem.error(
"/SCL/IED[@name=\"IED_NAME1\"], /SCL/IED[@name=\"IED_NAME2\"]",
"/IED/Private/compas:ICDHeader[@ICDSystemVersionUUID] must be unique but the same ICDSystemVersionUUID was found on several IED."),
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME3\"]", "IED has no Private COMPAS-ICDHeader element"),
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME4\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute"),
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME5\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute")
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME3\"]", "IED has no Private COMPAS-ICDHeader element"),
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME4\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute"),
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME5\"]", "IED private COMPAS-ICDHeader as no icdSystemVersionUUID or iedName attribute")
})
);
}
@@ -161,14 +161,14 @@ void updateAllExtRefIedNames_when_not_bindable_should_clear_binding() {
// Given : see comments in SCD file
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
// When
- SclReport sclReport = ExtRefService.updateAllExtRefIedNames(scd);
+ ExtRefService.updateAllExtRefIedNames(scd);
// Then
- assertExtRefIsNotBound(findExtRef(sclReport, "IED_NAME1", "LD_INST12", "ExtRef target LDevice status is off"));
- assertExtRefIsNotBound(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "Match compas:Flow but FlowStatus is INACTIVE"));
- assertExtRefIsNotBound(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "ExtRef does not match any ICDSystemVersionUUID"));
- assertExtRefIsNotBound(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "ExtRefldinst does not match any LDevice inst in source IED"));
- assertExtRefIsNotBound(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "ExtRef does not match any LN in source LDevice"));
- assertExtRefIsNotBound(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "Source LDevice is off for this ExtRef"));
+ assertExtRefIsNotBound(findExtRef(scd, "IED_NAME1", "LD_INST12", "ExtRef target LDevice status is off"));
+ assertExtRefIsNotBound(findExtRef(scd, "IED_NAME1", "LD_INST11", "Match compas:Flow but FlowStatus is INACTIVE"));
+ assertExtRefIsNotBound(findExtRef(scd, "IED_NAME1", "LD_INST11", "ExtRef does not match any ICDSystemVersionUUID"));
+ assertExtRefIsNotBound(findExtRef(scd, "IED_NAME1", "LD_INST11", "ExtRefldinst does not match any LDevice inst in source IED"));
+ assertExtRefIsNotBound(findExtRef(scd, "IED_NAME1", "LD_INST11", "ExtRef does not match any LN in source LDevice"));
+ assertExtRefIsNotBound(findExtRef(scd, "IED_NAME1", "LD_INST11", "Source LDevice is off for this ExtRef"));
}
@Test
@@ -176,10 +176,10 @@ void updateAllExtRefIedNames_when_lDevice_off_should_remove_binding() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
// When
- SclReport sclReport = ExtRefService.updateAllExtRefIedNames(scd);
+ List sclReportItems = ExtRefService.updateAllExtRefIedNames(scd);
// Then
- assertThat(sclReport).isNotNull();
- LDeviceAdapter lDeviceAdapter = findLDeviceByLdName(sclReport.getSclRootAdapter(), "IED_NAME1LD_INST12");
+ assertThat(sclReportItems).isNotNull();
+ LDeviceAdapter lDeviceAdapter = findLDeviceByLdName(scd, "IED_NAME1LD_INST12");
assertThat(lDeviceAdapter.getLDeviceStatus()).hasValue("off");
assertThat(lDeviceAdapter.getLN0Adapter().getInputsAdapter().getCurrentElem().getExtRef())
.allSatisfy(this::assertExtRefIsNotBound);
@@ -190,10 +190,10 @@ void updateAllExtRefIedNames_when_FlowStatus_INACTIVE_should_remove_binding() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
// When
- SclReport sclReport = ExtRefService.updateAllExtRefIedNames(scd);
+ List sclReportItems = ExtRefService.updateAllExtRefIedNames(scd);
// Then
- assertThat(sclReport).isNotNull();
- LDeviceAdapter lDeviceAdapter = findLDeviceByLdName(sclReport.getSclRootAdapter(), "IED_NAME1LD_INST11");
+ assertThat(sclReportItems).isNotNull();
+ LDeviceAdapter lDeviceAdapter = findLDeviceByLdName(scd, "IED_NAME1LD_INST11");
assertThat(lDeviceAdapter.getLDeviceStatus()).hasValue("on");
Optional optionalTExtRef = lDeviceAdapter.getCurrentElem().getLN0().getInputs().getExtRef().stream()
.filter(tExtRef -> "Match compas:Flow but FlowStatus is INACTIVE".equals(tExtRef.getDesc()))
@@ -208,21 +208,21 @@ void createDataSetAndControlBlocks_should_create_DataSet() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
// When
- SclReport sclReport = ExtRefService.createDataSetAndControlBlocks(scd);
+ List sclReportItems = ExtRefService.createDataSetAndControlBlocks(scd);
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- assertThat(streamAllDataSets(sclReport.getSclRootAdapter())).hasSize(6);
+ assertThat(sclReportItems).isEmpty();
+ assertThat(streamAllDataSets(scd)).hasSize(6);
// Check dataSet names
- findDataSet(sclReport, "IED_NAME2", "LD_INST21", "DS_LD_INST21_CYCI");
- findDataSet(sclReport, "IED_NAME2", "LD_INST21", "DS_LD_INST21_DQCI");
- findDataSet(sclReport, "IED_NAME2", "LD_INST21", "DS_LD_INST21_GMI");
- findDataSet(sclReport, "IED_NAME2", "LD_INST21", "DS_LD_INST21_SVI");
- findDataSet(sclReport, "IED_NAME3", "LD_INST31", "DS_LD_INST31_GSE");
- findDataSet(sclReport, "IED_NAME2", "LD_INST21", "DS_LD_INST21_GSI");
+ findDataSet(scd, "IED_NAME2", "LD_INST21", "DS_LD_INST21_CYCI");
+ findDataSet(scd, "IED_NAME2", "LD_INST21", "DS_LD_INST21_DQCI");
+ findDataSet(scd, "IED_NAME2", "LD_INST21", "DS_LD_INST21_GMI");
+ findDataSet(scd, "IED_NAME2", "LD_INST21", "DS_LD_INST21_SVI");
+ findDataSet(scd, "IED_NAME3", "LD_INST31", "DS_LD_INST31_GSE");
+ findDataSet(scd, "IED_NAME2", "LD_INST21", "DS_LD_INST21_GSI");
// Check one DataSet content
- DataSetAdapter aDataSet = findDataSet(sclReport.getSclRootAdapter(), "IED_NAME2", "LD_INST21", "DS_LD_INST21_GSI");
+ DataSetAdapter aDataSet = findDataSet(scd, "IED_NAME2", "LD_INST21", "DS_LD_INST21_GSI");
assertThat(aDataSet.getCurrentElem().getFCDA()).hasSize(4);
assertThat(aDataSet.getCurrentElem().getFCDA().stream().map(FCDARecord::toFCDARecord))
.containsExactly(
@@ -239,20 +239,20 @@ void createDataSetAndControlBlocks_should_create_ControlBlocks() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
// When
- SclReport sclReport = ExtRefService.createDataSetAndControlBlocks(scd);
+ List sclReportItems = ExtRefService.createDataSetAndControlBlocks(scd);
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
+ assertThat(sclReportItems).isEmpty();
// Check ControlBlock names, id and datSet
- assertControlBlockExists(sclReport, "IED_NAME2", "LD_INST21", "CB_LD_INST21_CYCI", "DS_LD_INST21_CYCI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_CYCI", REPORT);
- assertControlBlockExists(sclReport, "IED_NAME2", "LD_INST21", "CB_LD_INST21_DQCI", "DS_LD_INST21_DQCI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_DQCI", REPORT);
- assertControlBlockExists(sclReport, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GMI", "DS_LD_INST21_GMI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_GMI", GSE);
- assertControlBlockExists(sclReport, "IED_NAME2", "LD_INST21", "CB_LD_INST21_SVI", "DS_LD_INST21_SVI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_SVI", SAMPLED_VALUE);
- assertControlBlockExists(sclReport, "IED_NAME3", "LD_INST31", "CB_LD_INST31_GSE", "DS_LD_INST31_GSE", "IED_NAME3LD_INST31/LLN0.CB_LD_INST31_GSE", GSE);
- assertControlBlockExists(sclReport, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", "DS_LD_INST21_GSI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_GSI", GSE);
+ assertControlBlockExists(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_CYCI", "DS_LD_INST21_CYCI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_CYCI", REPORT);
+ assertControlBlockExists(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_DQCI", "DS_LD_INST21_DQCI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_DQCI", REPORT);
+ assertControlBlockExists(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GMI", "DS_LD_INST21_GMI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_GMI", GSE);
+ assertControlBlockExists(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_SVI", "DS_LD_INST21_SVI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_SVI", SAMPLED_VALUE);
+ assertControlBlockExists(scd, "IED_NAME3", "LD_INST31", "CB_LD_INST31_GSE", "DS_LD_INST31_GSE", "IED_NAME3LD_INST31/LLN0.CB_LD_INST31_GSE", GSE);
+ assertControlBlockExists(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_GSI", "DS_LD_INST21_GSI", "IED_NAME2LD_INST21/LLN0.CB_LD_INST21_GSI", GSE);
// Check one ControlBlock content (ReportControl with sourceDA.fc=MX)
- TReportControl tReportControl = findControlBlock(sclReport.getSclRootAdapter(), "IED_NAME2", "LD_INST21", "CB_LD_INST21_CYCI", TReportControl.class);
+ TReportControl tReportControl = findControlBlock(scd, "IED_NAME2", "LD_INST21", "CB_LD_INST21_CYCI", TReportControl.class);
assertThat(tReportControl).extracting(TReportControl::getConfRev, TReportControl::isBuffered, TReportControl::getBufTime, TReportControl::isIndexed,
TControlWithTriggerOpt::getIntgPd)
.containsExactly(1L, true, 0L, true, 60000L);
@@ -272,26 +272,26 @@ void createDataSetAndControlBlocks_should_set_ExtRef_srcXXX_attributes() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
// When
- SclReport sclReport = ExtRefService.createDataSetAndControlBlocks(scd);
+ List sclReportItems = ExtRefService.createDataSetAndControlBlocks(scd);
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
+ assertThat(sclReportItems).isEmpty();
// assert all ExtRef.srcPrefix srcLNClass srcLNInst are not set
- assertThat(streamAllExtRef(sclReport.getSclRootAdapter()))
+ assertThat(streamAllExtRef(scd))
.extracting(TExtRef::getSrcPrefix, TExtRef::isSetSrcLNClass, TExtRef::getSrcLNInst)
.containsOnly(Tuple.tuple(null, false, null));
// check some ExtRef
- assertThat(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "test bay internal"))
+ assertThat(findExtRef(scd, "IED_NAME1", "LD_INST11", "test bay internal"))
.extracting(TExtRef::getSrcCBName, TExtRef::getSrcLDInst)
.containsExactly("CB_LD_INST21_GSI", "LD_INST21");
- assertThat(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "test bay external"))
+ assertThat(findExtRef(scd, "IED_NAME1", "LD_INST11", "test bay external"))
.extracting(TExtRef::getSrcCBName, TExtRef::getSrcLDInst)
.containsExactly("CB_LD_INST31_GSE", "LD_INST31");
- assertThat(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "test ServiceType is SMV, no daName and DO contains ST and MX, but only ST is FCDA candidate"))
+ assertThat(findExtRef(scd, "IED_NAME1", "LD_INST11", "test ServiceType is SMV, no daName and DO contains ST and MX, but only ST is FCDA candidate"))
.extracting(TExtRef::getSrcCBName, TExtRef::getSrcLDInst)
.containsExactly("CB_LD_INST21_SVI", "LD_INST21");
- assertThat(findExtRef(sclReport, "IED_NAME1", "LD_INST11", "test ServiceType is Report_daReportMX_1"))
+ assertThat(findExtRef(scd, "IED_NAME1", "LD_INST11", "test ServiceType is Report_daReportMX_1"))
.extracting(TExtRef::getSrcCBName, TExtRef::getSrcLDInst)
.containsExactly("CB_LD_INST21_CYCI", "LD_INST21");
}
@@ -301,15 +301,15 @@ void createDataSetAndControlBlocks_when_targetIedName_is_provided_should_succeed
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
// When
- SclReport sclReport = ExtRefService.createDataSetAndControlBlocks(scd, "IED_NAME1");
+ List sclReportItems = ExtRefService.createDataSetAndControlBlocks(scd, "IED_NAME1");
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- assertThat(streamAllDataSets(sclReport.getSclRootAdapter())).hasSize(6);
- List ln0s = streamAllLn0Adapters(sclReport.getSclRootAdapter()).map(SclElementAdapter::getCurrentElem).toList();
+ assertThat(sclReportItems).isEmpty();
+ assertThat(streamAllDataSets(scd)).hasSize(6);
+ List ln0s = streamAllLn0Adapters(scd).map(SclElementAdapter::getCurrentElem).toList();
assertThat(ln0s).flatMap(TLN0::getGSEControl).hasSize(3);
assertThat(ln0s).flatMap(TLN0::getSampledValueControl).hasSize(1);
assertThat(ln0s).flatMap(TLN0::getReportControl).hasSize(2);
- MarshallerWrapper.assertValidateXmlSchema(sclReport.getSclRootAdapter().getCurrentElem());
+ MarshallerWrapper.assertValidateXmlSchema(scd);
}
@Test
@@ -317,10 +317,10 @@ void createDataSetAndControlBlocks_when_targetIedName_is_provided_and_no_ext_ref
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
// When
- SclReport sclReport = ExtRefService.createDataSetAndControlBlocks(scd, "IED_NAME2");
+ List sclReportItems = ExtRefService.createDataSetAndControlBlocks(scd, "IED_NAME2");
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- assertThat(streamAllDataSets(sclReport.getSclRootAdapter())).isEmpty();
+ assertThat(sclReportItems).isEmpty();
+ assertThat(streamAllDataSets(scd)).isEmpty();
}
@Test
@@ -338,9 +338,9 @@ void createDataSetAndControlBlocks_when_targetIedName_and_targetLDeviceInst_is_p
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
// When
- SclReport sclReport = ExtRefService.createDataSetAndControlBlocks(scd, "IED_NAME1", "LD_INST11");
+ List sclReportItems = ExtRefService.createDataSetAndControlBlocks(scd, "IED_NAME1", "LD_INST11");
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
+ assertThat(sclReportItems).isEmpty();
}
@Test
@@ -393,12 +393,11 @@ private void assertExtRefIsNotBound(TExtRef extRef) {
void updateAllSourceDataSetsAndControlBlocks_should_sort_FCDA_inside_DataSet_and_avoid_duplicates() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success_test_fcda_sort.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
// When
- SclReport sclReport = ExtRefService.createDataSetAndControlBlocks(scd);
+ List sclReportItems = ExtRefService.createDataSetAndControlBlocks(scd);
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- DataSetAdapter dataSetAdapter = findDataSet(sclRootAdapter, "IED_NAME2", "LD_INST21", "DS_LD_INST21_GSI");
+ assertThat(sclReportItems).isEmpty();
+ DataSetAdapter dataSetAdapter = findDataSet(scd, "IED_NAME2", "LD_INST21", "DS_LD_INST21_GSI");
assertThat(dataSetAdapter.getCurrentElem().getFCDA())
.map(TFCDA::getLnInst, TFCDA::getDoName)
.containsExactly(
@@ -419,10 +418,10 @@ void configureNetworkForAllControlBlocks_should_create_GSE_and_SMV_elements() {
ControlBlockNetworkSettings controlBlockNetworkSettings = controlBlockAdapter -> new SettingsOrError(new Settings(0x1D6, (byte) 4, minTime, maxTime), null);
// When
- SclReport sclReport = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, RANGES_PER_CB_TYPE);
+ List sclReportItems = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, RANGES_PER_CB_TYPE);
// Then
- assertThat(sclReport.isSuccess()).isTrue();
- TConnectedAP connectedAP = sclReport.getSclRootAdapter().findConnectedApAdapter("IED_NAME2", "AP_NAME").get().getCurrentElem();
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
+ TConnectedAP connectedAP = new SclRootAdapter(scd).findConnectedApAdapter("IED_NAME2", "AP_NAME").get().getCurrentElem();
TGSE gse = connectedAP.getGSE().stream()
.filter(tgse -> "CB_LD_INST21_GSI".equals(tgse.getCbName()))
.findFirst().get();
@@ -461,9 +460,9 @@ void configureNetworkForAllControlBlocks_should_create_GSE_with_incremental_appi
TDurationInMilliSec maxTime = newDurationInMilliSec(2000);
ControlBlockNetworkSettings controlBlockNetworkSettings = controlBlockAdapter -> new SettingsOrError(new Settings(0x1D6, (byte) 4, minTime, maxTime), null);
// When
- SclReport sclReport = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, RANGES_PER_CB_TYPE);
+ List sclReportItems = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, RANGES_PER_CB_TYPE);
// Then
- assertThat(sclReport.isSuccess()).isTrue();
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
assertThat(streamAllConnectedApGseP(scd, "APPID"))
.containsExactlyInAnyOrder("0009", "000A", "000B");
assertThat(streamAllConnectedApGseP(scd, "MAC-Address"))
@@ -478,11 +477,11 @@ void configureNetworkForAllControlBlocks_should_fail_when_no_settings_for_this_c
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_controlblock_network_configuration.xml");
// When
- SclReport sclReport = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType);
+ List sclReportItems = ExtRefService.configureNetworkForAllControlBlocks(scd, controlBlockNetworkSettings, rangesPerCbType);
// Then
- assertThat(sclReport.isSuccess()).isFalse();
- assertThat(sclReport.getSclReportItems())
- .extracting(SclReportItem::getMessage, SclReportItem::getXpath)
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse();
+ assertThat(sclReportItems)
+ .extracting(SclReportItem::message, SclReportItem::xpath)
.contains(Tuple.tuple(expectedMessage,
"/SCL/IED[@name=\"IED_NAME2\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST21\"]/LN0/GSEControl[@name=\"CB_LD_INST21_GMI\"]"));
}
@@ -522,7 +521,7 @@ void filterDuplicatedExtRefs_should_remove_duplicated_extrefs() {
List tExtRefList = List.of(tExtRef, tExtRefLnClass, createExtRefExample("CB", TServiceType.GOOSE),
createExtRefExample("CB", TServiceType.GOOSE));
// When
- List result = filterDuplicatedExtRefs(tExtRefList);
+ List result = ExtRefService.filterDuplicatedExtRefs(tExtRefList);
// Then
assertThat(result).hasSizeLessThan(tExtRefList.size())
.hasSize(2);
@@ -571,21 +570,21 @@ void manageBindingForLDEPF_should_return_noReportAndExtRefUpdateSuccessfully_whe
.build();
// When
- SclReport sclReport = ExtRefService.manageBindingForLDEPF(scd, settingLDEPFCsvHelper);
+ List sclReportItems = ExtRefService.manageBindingForLDEPF(scd, settingLDEPFCsvHelper);
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- TExtRef extRef1 = findExtRef(sclReport, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
+ assertThat(sclReportItems).isEmpty();
+ TExtRef extRef1 = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
assertThat(extRef1.getIedName()).isEqualTo("IED_NAME1");
- TExtRef extRef2 = findExtRef(sclReport, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
+ TExtRef extRef2 = findExtRef(scd, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
assertThat(extRef2.getIedName()).isEqualTo("IED_NAME2");
- TExtRef extRef3 = findExtRef(sclReport, "IED_NAME3", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
+ TExtRef extRef3 = findExtRef(scd, "IED_NAME3", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
assertThat(extRef3.getIedName()).isEqualTo("IED_NAME1");
assertExtRefIsBoundAccordingTOLDEPF(extRef1, expectedSettingData);
assertExtRefIsBoundAccordingTOLDEPF(extRef2, expectedSettingData);
assertExtRefIsBoundAccordingTOLDEPF(extRef3, expectedSettingData);
- AbstractLNAdapter> lnRbdr = findLn(sclReport.getSclRootAdapter(), "IED_NAME1", "LDEPF", "RBDR", "1", "");
+ AbstractLNAdapter> lnRbdr = findLn(scd, "IED_NAME1", "LDEPF", "RBDR", "1", "");
assertThat(getDaiValue(lnRbdr, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("MR.PX1");
@@ -599,7 +598,7 @@ void manageBindingForLDEPF_should_return_noReportAndExtRefUpdateSuccessfully_whe
.isNotEqualTo("setSrcRef_old_val")
.isEqualTo("IED_NAME1LDPX/PTRC0.Str.general");
- AbstractLNAdapter> lnBrbdr = findLn(sclReport.getSclRootAdapter(), "IED_NAME1", "LDEPF", "RBDR", "1", "b");
+ AbstractLNAdapter> lnBrbdr = findLn(scd, "IED_NAME1", "LDEPF", "RBDR", "1", "b");
assertThat(getDaiValue(lnBrbdr, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("MR.PX1");
@@ -624,15 +623,15 @@ void manageBindingForLDEPF_should_return_no_report_when_extRef_withDifferentIedT
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_extref_with_BCU_BPU.xml");
SettingLDEPFCsvHelper settingLDEPFCsvHelper = new SettingLDEPFCsvHelper(reader);
// When
- SclReport sclReport = ExtRefService.manageBindingForLDEPF(scd, settingLDEPFCsvHelper);
+ List sclReportItems = ExtRefService.manageBindingForLDEPF(scd, settingLDEPFCsvHelper);
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- SclTestMarshaller.assertIsMarshallable(sclReport.getSclRootAdapter().getCurrentElem());
- TExtRef extRef1 = findExtRef(sclReport, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
+ assertThat(sclReportItems).isEmpty();
+ SclTestMarshaller.assertIsMarshallable(new SclRootAdapter(scd).getCurrentElem());
+ TExtRef extRef1 = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
assertThat(extRef1.getIedName()).isEqualTo("IED_NAME1");
assertExtRefIsBoundAccordingTOLDEPF(extRef1, getLDEPFSettingByDigitalNum(settingLDEPFCsvHelper.getSettings(), 1));
- AbstractLNAdapter> lnRbdr = findLn(sclReport.getSclRootAdapter(), "IED_NAME1", "LDEPF", "RBDR", "1", "");
+ AbstractLNAdapter> lnRbdr = findLn(scd, "IED_NAME1", "LDEPF", "RBDR", "1", "");
assertThat(getDaiValue(lnRbdr, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("MR.PX1");
@@ -646,7 +645,7 @@ void manageBindingForLDEPF_should_return_no_report_when_extRef_withDifferentIedT
.isNotEqualTo("setSrcRef_old_val")
.isEqualTo("IED_NAME1LDPX/PTRC0.Str.general");
- AbstractLNAdapter> lnBrbdr = findLn(sclReport.getSclRootAdapter(), "IED_NAME1", "LDEPF", "RBDR", "1", "b");
+ AbstractLNAdapter> lnBrbdr = findLn(scd, "IED_NAME1", "LDEPF", "RBDR", "1", "b");
assertThat(getDaiValue(lnBrbdr, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("MR.PX1");
@@ -660,11 +659,11 @@ void manageBindingForLDEPF_should_return_no_report_when_extRef_withDifferentIedT
.isNotEqualTo("setSrcRef_old_val")
.isEqualTo("IED_NAME1LDPX/PTRC0.Str.q");
- TExtRef extRef2 = findExtRef(sclReport, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 15_1_BOOLEEN_1_general_1");
+ TExtRef extRef2 = findExtRef(scd, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 15_1_BOOLEEN_1_general_1");
assertThat(extRef2.getIedName()).isEqualTo("IED_NAME2");
assertExtRefIsBoundAccordingTOLDEPF(extRef2, getLDEPFSettingByDigitalNum(settingLDEPFCsvHelper.getSettings(), 15));
- AbstractLNAdapter> lnRbdr2 = findLn(sclReport.getSclRootAdapter(), "IED_NAME2", "LDEPF", "RBDR", "15", "");
+ AbstractLNAdapter> lnRbdr2 = findLn(scd, "IED_NAME2", "LDEPF", "RBDR", "15", "");
assertThat(getDaiValue(lnRbdr2, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("MR.PX2");
@@ -678,7 +677,7 @@ void manageBindingForLDEPF_should_return_no_report_when_extRef_withDifferentIedT
.isNotEqualTo("setSrcRef_old_val")
.isEqualTo("IED_NAME2LDPX/PTRC0.Str.general");
- AbstractLNAdapter> lnBrbdr2 = findLn(sclReport.getSclRootAdapter(), "IED_NAME2", "LDEPF", "RBDR", "15", "b");
+ AbstractLNAdapter> lnBrbdr2 = findLn(scd, "IED_NAME2", "LDEPF", "RBDR", "15", "b");
assertThat(getDaiValue(lnBrbdr2, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("MR.PX2");
@@ -702,20 +701,20 @@ void manageBindingForLDEPF_should_return_report_when_manyIedSourceFound() {
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_manyIedSources_in_same_bay.xml");
ILDEPFSettings settings = new SettingLDEPFCsvHelper(reader);
// When
- SclReport sclReport = ExtRefService.manageBindingForLDEPF(scd, settings);
+ List sclReportItems = ExtRefService.manageBindingForLDEPF(scd, settings);
// Then
- assertThat(sclReport.getSclReportItems()).hasSize(2)
- .extracting(SclReportItem::getMessage)
+ assertThat(sclReportItems).hasSize(2)
+ .extracting(SclReportItem::message)
.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",
"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"));
- TExtRef extRef1 = findExtRef(sclReport, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
+ TExtRef extRef1 = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
assertThat(extRef1.isSetIedName()).isTrue();
- TExtRef extRef2 = findExtRef(sclReport, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
+ TExtRef extRef2 = findExtRef(scd, "IED_NAME2", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
assertThat(extRef2.isSetIedName()).isFalse();
- TExtRef extRef3 = findExtRef(sclReport, "IED_NAME3", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
+ TExtRef extRef3 = findExtRef(scd, "IED_NAME3", "LDEPF", "DYN_LDEPF_DIGITAL CHANNEL 1_1_BOOLEEN_1_general_1");
assertThat(extRef3.isSetIedName()).isFalse();
- AbstractLNAdapter> lnRbdr = findLn(sclReport.getSclRootAdapter(), "IED_NAME2", "LDEPF", "RBDR", "1", "");
+ AbstractLNAdapter> lnRbdr = findLn(scd, "IED_NAME2", "LDEPF", "RBDR", "1", "");
assertThat(getDaiValue(lnRbdr, CHNUM1_DO_NAME, DU_DA_NAME))
.isEqualTo("dU_old_val");
assertThat(getDaiValue(lnRbdr, LEVMOD_DO_NAME, SETVAL_DA_NAME))
@@ -725,7 +724,7 @@ void manageBindingForLDEPF_should_return_report_when_manyIedSourceFound() {
assertThat(getDaiValue(lnRbdr, SRCREF_DO_NAME, SETSRCREF_DA_NAME))
.isEqualTo("setSrcRef_old_val");
- AbstractLNAdapter> lnBrbdr = findLn(sclReport.getSclRootAdapter(), "IED_NAME2", "LDEPF", "RBDR", "1", "b");
+ AbstractLNAdapter> lnBrbdr = findLn(scd, "IED_NAME2", "LDEPF", "RBDR", "1", "b");
assertThat(getDaiValue(lnBrbdr, CHNUM1_DO_NAME, DU_DA_NAME))
.isEqualTo("dU_old_val");
assertThat(getDaiValue(lnBrbdr, LEVMOD_DO_NAME, SETVAL_DA_NAME))
@@ -744,15 +743,15 @@ void manageBindingForLDEPF_should_return_no_report_when_extRefInFlowKindInternal
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ldepf/scd_ldepf_dataTypeTemplateValid.xml");
SettingLDEPFCsvHelper settingLDEPFCsvHelper = new SettingLDEPFCsvHelper(reader);
// When
- SclReport sclReport = ExtRefService.manageBindingForLDEPF(scd, settingLDEPFCsvHelper);
+ List sclReportItems = ExtRefService.manageBindingForLDEPF(scd, settingLDEPFCsvHelper);
// Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- SclTestMarshaller.assertIsMarshallable(sclReport.getSclRootAdapter().getCurrentElem());
- TExtRef extRefBindInternally = findExtRef(sclReport, "IED_NAME1", "LDEPF", "DYN_LDEPF_ANALOG CHANNEL 1_1_AnalogueValue_1_instMag_1");
+ assertThat(sclReportItems).isEmpty();
+ SclTestMarshaller.assertIsMarshallable(scd);
+ TExtRef extRefBindInternally = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_ANALOG CHANNEL 1_1_AnalogueValue_1_instMag_1");
assertThat(extRefBindInternally.getIedName()).isEqualTo("IED_NAME1");
assertExtRefIsBoundAccordingTOLDEPF(extRefBindInternally, getLDEPFSettingByAnalogNum(settingLDEPFCsvHelper.getSettings(), 1));
- AbstractLNAdapter> lnRadr = findLn(sclReport.getSclRootAdapter(), "IED_NAME1", "LDEPF", "RADR", "1", "");
+ AbstractLNAdapter> lnRadr = findLn(scd, "IED_NAME1", "LDEPF", "RADR", "1", "");
assertThat(getDaiValue(lnRadr, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("V0");
@@ -766,7 +765,7 @@ void manageBindingForLDEPF_should_return_no_report_when_extRefInFlowKindInternal
.isNotEqualTo("setSrcRef_old_val")
.isEqualTo("IED_NAME1LDTM1/U01ATVTR11.VolSv.instMag");
- AbstractLNAdapter> lnAradr = findLn(sclReport.getSclRootAdapter(), "IED_NAME1", "LDEPF", "RADR", "1", "a");
+ AbstractLNAdapter> lnAradr = findLn(scd, "IED_NAME1", "LDEPF", "RADR", "1", "a");
assertThat(getDaiValue(lnAradr, CHNUM1_DO_NAME, DU_DA_NAME))
.isNotEqualTo("dU_old_val")
.isEqualTo("V0");
@@ -780,7 +779,7 @@ void manageBindingForLDEPF_should_return_no_report_when_extRefInFlowKindInternal
.isNotEqualTo("setSrcRef_old_val")
.isEqualTo("IED_NAME1LDTM1/U01ATVTR11.VolSv.q");
- TExtRef extRefBindExternally = findExtRef(sclReport, "IED_NAME1", "LDEPF", "DYN_LDEPF_ANALOG CHANNEL 10_1_AnalogueValue_1_cVal_1");
+ TExtRef extRefBindExternally = findExtRef(scd, "IED_NAME1", "LDEPF", "DYN_LDEPF_ANALOG CHANNEL 10_1_AnalogueValue_1_cVal_1");
assertThat(extRefBindExternally.getIedName()).isEqualTo("IED_NAME2");
assertExtRefIsBoundAccordingTOLDEPF(extRefBindExternally, getLDEPFSettingByAnalogNum(settingLDEPFCsvHelper.getSettings(), 10));
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/HmiServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/HmiServiceTest.java
index b65eb60d1..5cf61c0b4 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/HmiServiceTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/HmiServiceTest.java
@@ -30,14 +30,13 @@ void createAllIhmReportControlBlocks_with_fc_ST_should_create_dataset_and_contro
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
// Then
// Check DataSet is created
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- DataSetAdapter dataSet = findDataSet(sclRootAdapter, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
+ DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
.usingRecursiveComparison().isEqualTo(fcda);
// Check ControlBlock is created
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IedName1", "LdInst11");
+ LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
- TReportControl reportControl = findControlBlock(sclRootAdapter, "IedName1", "LdInst11", "CB_LDINST11_DQPO", TReportControl.class);
+ TReportControl reportControl = findControlBlock(scd, "IedName1", "LdInst11", "CB_LDINST11_DQPO", TReportControl.class);
assertThat(reportControl).extracting(TReportControl::getRptID, TControl::getDatSet, TReportControl::getConfRev, TReportControl::isBuffered, TReportControl::getBufTime, TReportControl::isIndexed,
TControlWithTriggerOpt::getIntgPd)
.containsExactly("IedName1LdInst11/LLN0.CB_LDINST11_DQPO", "DS_LDINST11_DQPO", 1L, true, 0L, true, 60000L);
@@ -57,15 +56,14 @@ void createAllIhmReportControlBlocks_with_fc_MX_should_create_dataset_and_contro
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
// Then
// Check DataSet is created
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- DataSetAdapter dataSet = findDataSet(sclRootAdapter, "IedName1", "LdInst11", "DS_LDINST11_CYPO");
+ DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_CYPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
.usingRecursiveComparison().isEqualTo(fcda);
// Check ControlBlock is created
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IedName1", "LdInst11");
+ LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
- TReportControl reportControl = findControlBlock(sclRootAdapter, "IedName1", "LdInst11", "CB_LDINST11_CYPO", TReportControl.class);
+ TReportControl reportControl = findControlBlock(scd, "IedName1", "LdInst11", "CB_LDINST11_CYPO", TReportControl.class);
assertThat(reportControl).extracting(TReportControl::getRptID, TControl::getDatSet, TReportControl::getConfRev, TReportControl::isBuffered, TReportControl::getBufTime, TReportControl::isIndexed,
TControlWithTriggerOpt::getIntgPd)
.containsExactly("IedName1LdInst11/LLN0.CB_LDINST11_CYPO", "DS_LDINST11_CYPO", 1L, true, 0L, true, 2000L);
@@ -85,14 +83,13 @@ void createAllIhmReportControlBlocks_with_FCDA_on_ln0_should_create_dataset_and_
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
// Then
// Check DataSet is created
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- DataSetAdapter dataSet = findDataSet(sclRootAdapter, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
+ DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
.usingRecursiveComparison().isEqualTo(fcda);
// Check ControlBlock is created
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IedName1", "LdInst11");
+ LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
- TReportControl reportControl = findControlBlock(sclRootAdapter, "IedName1", "LdInst11", "CB_LDINST11_DQPO", TReportControl.class);
+ TReportControl reportControl = findControlBlock(scd, "IedName1", "LdInst11", "CB_LDINST11_DQPO", TReportControl.class);
assertThat(reportControl).extracting(TReportControl::getRptID, TControl::getDatSet, TReportControl::getConfRev, TReportControl::isBuffered, TReportControl::getBufTime, TReportControl::isIndexed,
TControlWithTriggerOpt::getIntgPd)
.containsExactly("IedName1LdInst11/LLN0.CB_LDINST11_DQPO", "DS_LDINST11_DQPO", 1L, true, 0L, true, 60000L);
@@ -107,21 +104,20 @@ void createAllIhmReportControlBlocks_with_FCDA_on_ln0_should_create_dataset_and_
void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_missing_should_create_dataset_and_controlblock() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LNAdapter ln = findLn(sclRootAdapter, "IedName1", "LdInst11", "ANCR", "1", null);
+ LNAdapter ln = findLn(scd, "IedName1", "LdInst11", "ANCR", "1", null);
ln.getCurrentElem().unsetDOI();
TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
// When
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
// Then
// Check DataSet is created
- DataSetAdapter dataSet = findDataSet(sclRootAdapter, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
+ DataSetAdapter dataSet = findDataSet(scd, "IedName1", "LdInst11", "DS_LDINST11_DQPO");
assertThat(dataSet.getCurrentElem().getFCDA()).hasSize(1).first()
.usingRecursiveComparison().isEqualTo(fcda);
// Check ControlBlock is created
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IedName1", "LdInst11");
+ LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
assertThat(ln0.getTControlsByType(TReportControl.class)).hasSize(1);
- TReportControl reportControl = findControlBlock(sclRootAdapter, "IedName1", "LdInst11", "CB_LDINST11_DQPO", TReportControl.class);
+ TReportControl reportControl = findControlBlock(scd, "IedName1", "LdInst11", "CB_LDINST11_DQPO", TReportControl.class);
assertThat(reportControl).extracting(TReportControl::getRptID, TControl::getDatSet, TReportControl::getConfRev, TReportControl::isBuffered, TReportControl::getBufTime, TReportControl::isIndexed,
TControlWithTriggerOpt::getIntgPd)
.containsExactly("IedName1LdInst11/LLN0.CB_LDINST11_DQPO", "DS_LDINST11_DQPO", 1L, true, 0L, true, 60000L);
@@ -131,48 +127,45 @@ void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_missing_sh
void createAllIhmReportControlBlocks_when_lDevice_ON_but_LN_Mod_StVal_OFF_should_not_create_dataset() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LNAdapter ln = findLn(sclRootAdapter, "IedName1", "LdInst11", "ANCR", "1", null);
+ LNAdapter ln = findLn(scd, "IedName1", "LdInst11", "ANCR", "1", null);
ln.getDOIAdapterByName(CommonConstants.MOD_DO_NAME).getDataAdapterByName(CommonConstants.STVAL_DA_NAME).setVal("off");
assertThat(ln.getDaiModStValValue()).hasValue("off");
TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
// When
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
// Then
- assertThat(streamAllDataSets(sclRootAdapter)).isEmpty();
- assertThat(streamAllControlBlocks(sclRootAdapter, TReportControl.class)).isEmpty();
+ assertThat(streamAllDataSets(scd)).isEmpty();
+ assertThat(streamAllControlBlocks(scd, TReportControl.class)).isEmpty();
}
@Test
void createAllIhmReportControlBlocks_when_lDevice_OFF_should_not_create_dataset() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IedName1", "LdInst11");
+ LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
ln0.getDOIAdapterByName(CommonConstants.MOD_DO_NAME).getDataAdapterByName(CommonConstants.STVAL_DA_NAME).setVal("off");
- assertThat(findLDevice(sclRootAdapter, "IedName1", "LdInst11").getLDeviceStatus()).hasValue(LdeviceStatus.OFF.getValue());
+ assertThat(findLDevice(scd, "IedName1", "LdInst11").getLDeviceStatus()).hasValue(LdeviceStatus.OFF.getValue());
TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
// When
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
// Then
- assertThat(streamAllDataSets(sclRootAdapter)).isEmpty();
- assertThat(streamAllControlBlocks(sclRootAdapter, TReportControl.class)).isEmpty();
+ assertThat(streamAllDataSets(scd)).isEmpty();
+ assertThat(streamAllControlBlocks(scd, TReportControl.class)).isEmpty();
}
@Test
void createAllIhmReportControlBlocks_when_LDevice_has_no_status_should_not_create_dataset() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-hmi-create-report-cb/scd_create_dataset_and_controlblocks_for_hmi.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IedName1", "LdInst11");
+ LN0Adapter ln0 = findLn0(scd, "IedName1", "LdInst11");
ln0.getDOIAdapterByName(CommonConstants.MOD_DO_NAME).getDataAdapterByName(CommonConstants.STVAL_DA_NAME).getCurrentElem().unsetVal();
- assertThat(findLDevice(sclRootAdapter, "IedName1", "LdInst11").getLDeviceStatus()).isEmpty();
+ assertThat(findLDevice(scd, "IedName1", "LdInst11").getLDeviceStatus()).isEmpty();
TFCDA fcda = newFcda("LdInst11", "ANCR", "1", null, "DoName1", null, TFCEnum.ST);
// When
HmiService.createAllHmiReportControlBlocks(scd, List.of(fcda));
// Then
- assertThat(streamAllDataSets(sclRootAdapter)).isEmpty();
- assertThat(streamAllControlBlocks(sclRootAdapter, TReportControl.class)).isEmpty();
+ assertThat(streamAllDataSets(scd)).isEmpty();
+ assertThat(streamAllControlBlocks(scd, TReportControl.class)).isEmpty();
}
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/PrivateServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/PrivateServiceTest.java
index 73d82e4d4..cbee0d90c 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/PrivateServiceTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/PrivateServiceTest.java
@@ -274,7 +274,7 @@ void createMapICDSystemVersionUuidAndSTDFile_Should_return_empty_map_when_no_ICD
scl1.getIED().add(tied1);
//When
- Map stringSCLMap = PrivateService.createMapICDSystemVersionUuidAndSTDFile(Set.of(scl1));
+ Map stringSCLMap = PrivateService.createMapICDSystemVersionUuidAndSTDFile(List.of(scl1));
//Then
assertThat(stringSCLMap.keySet()).isEmpty();
@@ -307,7 +307,7 @@ void createMapICDSystemVersionUuidAndSTDFile_Should_return_map_with_two_lines()
scl3.getIED().add(tied3);
//When
- Map stringSCLMap = PrivateService.createMapICDSystemVersionUuidAndSTDFile(Set.of(scl1,scl2,scl3));
+ Map stringSCLMap = PrivateService.createMapICDSystemVersionUuidAndSTDFile(List.of(scl1,scl2,scl3));
//Then
assertThat(stringSCLMap.keySet()).hasSize(2).containsExactly("UUID-1", "UUID-2");
@@ -327,11 +327,9 @@ void checkSTDCorrespondanceWithLNodeCompasICDHeadershoul_throw_scdEception(){
TPrivate tPrivate1 = PrivateService.createPrivate(compasICDHeader1);
TPrivate tPrivate2 = PrivateService.createPrivate(compasICDHeader2);
-
PrivateService.PrivateLinkedToSTDs privateLinkedToSTDs1 = new PrivateService.PrivateLinkedToSTDs(tPrivate1,Collections.singletonList(new SCL()));
PrivateService.PrivateLinkedToSTDs privateLinkedToSTDs2 = new PrivateService.PrivateLinkedToSTDs(tPrivate2, Arrays.asList(new SCL(), new SCL()));
-
Map stringSCLMap = new HashMap<>();
stringSCLMap.put("UUID-1", privateLinkedToSTDs1);
stringSCLMap.put("UUID-2", privateLinkedToSTDs2);
@@ -353,11 +351,9 @@ void checkSTDCorrespondanceWithLNodeCompasICDHeader_should_pass(){
TPrivate tPrivate1 = PrivateService.createPrivate(compasICDHeader1);
TPrivate tPrivate2 = PrivateService.createPrivate(compasICDHeader2);
-
PrivateService.PrivateLinkedToSTDs privateLinkedToSTDs1 = new PrivateService.PrivateLinkedToSTDs(tPrivate1,Collections.singletonList(new SCL()));
PrivateService.PrivateLinkedToSTDs privateLinkedToSTDs2 = new PrivateService.PrivateLinkedToSTDs(tPrivate2, Collections.singletonList(new SCL()));
-
Map stringSCLMap = new HashMap<>();
stringSCLMap.put("UUID-1", privateLinkedToSTDs1);
stringSCLMap.put("UUID-2", privateLinkedToSTDs2);
@@ -414,9 +410,7 @@ void createMapIEDNameAndPrivate_should_return_map_of_three_items() {
scl.getSubstation().add(tSubstation);
//When
- SclRootAdapter sclRootAdapter = SclService.initScl(Optional.empty(), "hv", "hr");
- sclRootAdapter.setCurrentElem(scl);
- Stream tPrivateStream = PrivateService.streamIcdHeaders(sclRootAdapter);
+ Stream tPrivateStream = PrivateService.streamIcdHeaders(scl);
//Then
assertThat(tPrivateStream.toList())
@@ -445,9 +439,7 @@ void createMapIEDNameAndPrivate_should_return_empty_map_when_no_compasicdheader_
scl.getSubstation().add(tSubstation);
//When
- SclRootAdapter sclRootAdapter = SclService.initScl(Optional.empty(), "hv", "hr");
- sclRootAdapter.setCurrentElem(scl);
- Stream tPrivateStream = PrivateService.streamIcdHeaders(sclRootAdapter);
+ Stream tPrivateStream = PrivateService.streamIcdHeaders(scl);
//Then
assertThat(tPrivateStream.toList()).isEmpty();
@@ -531,7 +523,7 @@ void copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate() {
}
@Test
- void gettCompasICDHeaders_should_return_ICDHeaders() {
+ void getCompasICDHeaders_should_return_ICDHeaders() {
//Given
TIED tied = createTIED();
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SclServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SclServiceTest.java
index a2ae0464c..54d598e9a 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SclServiceTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SclServiceTest.java
@@ -115,8 +115,8 @@ void testAddIED() {
assertNull(sclRootAdapter.getCurrentElem().getDataTypeTemplates());
SCL icd = SclTestMarshaller.getSCLFromFile("/scl-srv-import-ieds/ied_1_test.xml");
- IEDAdapter iedAdapter = assertDoesNotThrow(() -> SclService.addIED(scd, "IED_NAME1", icd));
- assertEquals("IED_NAME1", iedAdapter.getName());
+ assertDoesNotThrow(() -> SclService.addIED(scd, "IED_NAME1", icd));
+ assertEquals("IED_NAME1", scd.getIED().get(0).getName());
assertNotNull(sclRootAdapter.getCurrentElem().getDataTypeTemplates());
assertIsMarshallable(scd);
@@ -134,12 +134,10 @@ void testAddSubnetworks() {
SubNetworkDTO subNetworkDTO = new SubNetworkDTO();
subNetworkDTO.setName("sName1");
subNetworkDTO.setType("IP");
- ConnectedApDTO connectedApDTO = new ConnectedApDTO();
- connectedApDTO.setApName("AP_NAME");
- connectedApDTO.setIedName("IED_NAME1");
+ ConnectedApDTO connectedApDTO = new ConnectedApDTO("IED_NAME1", "AP_NAME");
subNetworkDTO.addConnectedAP(connectedApDTO);
- assertDoesNotThrow(() -> SclService.addSubnetworks(scd, Set.of(subNetworkDTO), Optional.of(icd)).get());
+ assertDoesNotThrow(() -> SclService.addSubnetworks(scd, List.of(subNetworkDTO), icd));
assertIsMarshallable(scd);
}
@@ -152,7 +150,7 @@ void testAddSubnetworksWithoutCommunicationTagInIcd() {
assertDoesNotThrow(() -> SclService.addIED(scd, "IED_NAME1", icd));
- assertDoesNotThrow(() -> SclService.addSubnetworks(scd, new HashSet<>(), Optional.of(icd)));
+ assertDoesNotThrow(() -> SclService.addSubnetworks(scd, List.of(), icd));
String marshalledScd = assertIsMarshallable(scd);
assertThat(marshalledScd).doesNotContain(" SclService.addIED(scd, "IED_NAME1", icd));
- Set subNetworkDTOSet = new HashSet<>(SclService.getSubnetwork(icd));
- assertDoesNotThrow(() -> SclService.addSubnetworks(scd, subNetworkDTOSet, Optional.of(icd)).get());
+ List subNetworkDTOSet = SclService.getSubnetwork(icd);
+ assertDoesNotThrow(() -> SclService.addSubnetworks(scd, subNetworkDTOSet, icd));
String marshalledScd = assertIsMarshallable(scd);
assertThat(marshalledScd).contains("", "PhysConn");
@@ -182,8 +180,8 @@ void testAddSubnetworksWithoutImportingIcdAddressAndPhysConn() {
assertDoesNotThrow(() -> SclService.addIED(scd, "IED_NAME1", icd));
- Set subNetworkDTOSet = new HashSet<>(SclService.getSubnetwork(icd));
- assertDoesNotThrow(() -> SclService.addSubnetworks(scd, subNetworkDTOSet, Optional.empty()).get());
+ List subNetworkDTOSet = SclService.getSubnetwork(icd);
+ assertDoesNotThrow(() -> SclService.addSubnetworks(scd, subNetworkDTOSet, null));
String marshalledScd = assertIsMarshallable(scd);
assertThat(marshalledScd).doesNotContain("", "PhysConn");
@@ -201,12 +199,10 @@ void testGetSubnetwork() {
SubNetworkDTO subNetworkDTO = new SubNetworkDTO();
subNetworkDTO.setName("sName1");
subNetworkDTO.setType("IP");
- ConnectedApDTO connectedApDTO = new ConnectedApDTO();
- connectedApDTO.setApName("AP_NAME");
- connectedApDTO.setIedName("IED_NAME1");
+ ConnectedApDTO connectedApDTO = new ConnectedApDTO("IED_NAME1", "AP_NAME");
subNetworkDTO.addConnectedAP(connectedApDTO);
- assertDoesNotThrow(() -> SclService.addSubnetworks(scd, Set.of(subNetworkDTO), Optional.of(icd)).get());
+ assertDoesNotThrow(() -> SclService.addSubnetworks(scd, List.of(subNetworkDTO), icd));
List subNetworkDTOS = assertDoesNotThrow(() -> SclService.getSubnetwork(scd));
assertEquals(1, subNetworkDTOS.size());
@@ -731,43 +727,33 @@ void getDAI_should_filter_updatable_DA_with_sGroup_Val_without_ConfSg() {
}
@Test
- void testInitScl() {
- SclRootAdapter sclRootAdapter = assertDoesNotThrow(
- () -> SclService.initScl(Optional.empty(), "hVersion", "hRevision")
- );
- assertIsMarshallable(sclRootAdapter.getCurrentElem());
- }
-
- @Test
- void testInitScl_With_hId_shouldNotThrowError() {
- UUID hid = UUID.randomUUID();
- SclRootAdapter sclRootAdapter = assertDoesNotThrow(
- () -> SclService.initScl(Optional.of(hid), "hVersion", "hRevision")
- );
- assertIsMarshallable(sclRootAdapter.getCurrentElem());
+ void testInitScl_With_headerId_shouldNotThrowError() {
+ UUID headerId = UUID.randomUUID();
+ SCL scd = assertDoesNotThrow(() -> SclService.initScl(headerId, "hVersion", "hRevision"));
+ assertIsMarshallable(scd);
}
@Test
- void testInitScl_Create_Private_SCL_FILETYPE() {
- UUID hid = UUID.randomUUID();
- SclRootAdapter rootAdapter = assertDoesNotThrow(
- () -> SclService.initScl(Optional.of(hid), "hVersion", "hRevision")
- );
- assertThat(rootAdapter.getCurrentElem().getPrivate()).isNotEmpty();
- assertThat(rootAdapter.getCurrentElem().getPrivate().get(0).getType()).isEqualTo(COMPAS_SCL_FILE_TYPE.getPrivateType());
- assertIsMarshallable(rootAdapter.getCurrentElem());
+ void initScl_should_create_Private_SCL_FILETYPE() {
+ // Given
+ UUID headerId = UUID.randomUUID();
+ // When Then
+ SCL scd = assertDoesNotThrow(() -> SclService.initScl(headerId, "hVersion", "hRevision"));
+ assertThat(scd.getPrivate()).isNotEmpty();
+ assertThat(scd.getPrivate().get(0).getType()).isEqualTo(COMPAS_SCL_FILE_TYPE.getPrivateType());
+ assertIsMarshallable(scd);
}
@Test
- void testUpdateHeader() {
-
- SclRootAdapter sclRootAdapter = assertDoesNotThrow(
- () -> SclService.initScl(Optional.empty(), "hVersion", "hRevision")
- );
- UUID hId = UUID.fromString(sclRootAdapter.getHeaderAdapter().getHeaderId());
+ void updateHeader_should_update_header_tag() {
+ //Given
+ SCL scd = assertDoesNotThrow(() -> SclService.initScl(UUID.randomUUID(), "hVersion", "hRevision"));
+ UUID hId = UUID.fromString(scd.getHeader().getId());
HeaderDTO headerDTO = DTO.createHeaderDTO(hId);
- SclService.updateHeader(sclRootAdapter.getCurrentElem(), headerDTO);
- assertIsMarshallable(sclRootAdapter.getCurrentElem());
+ //When
+ SclService.updateHeader(scd, headerDTO);
+ //Then
+ assertIsMarshallable(scd);
}
@Test
@@ -792,13 +778,10 @@ void testUpdateDAI() {
}
@Test
- void testGetEnumTypeElements() {
+ void testGetEnumTypeValues() {
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-srv-import-ieds/ied_1_test.xml");
- assertThrows(ScdException.class, () -> SclService.getEnumTypeElements(scd, "unknwnID"));
-
- var enumList = assertDoesNotThrow(
- () -> SclService.getEnumTypeElements(scd, "RecCycModKind")
- );
+ assertThrows(ScdException.class, () -> SclService.getEnumTypeValues(scd, "unknwnID"));
+ var enumList = assertDoesNotThrow(() -> SclService.getEnumTypeValues(scd, "RecCycModKind"));
assertFalse(enumList.isEmpty());
}
@@ -806,12 +789,11 @@ void testGetEnumTypeElements() {
void testImportSTDElementsInSCD() {
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd.xml");
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
- SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
- SclRootAdapter expectedScdAdapter = assertDoesNotThrow(() -> SclService.importSTDElementsInSCD(scdRootAdapter, Set.of(std), DTO.comMap));
- assertThat(expectedScdAdapter.getCurrentElem().getIED()).hasSize(1);
- assertThat(expectedScdAdapter.getCurrentElem().getDataTypeTemplates()).hasNoNullFieldsOrProperties();
- assertThat(expectedScdAdapter.getCurrentElem().getCommunication().getSubNetwork()).hasSize(2);
+ assertDoesNotThrow(() -> SclService.importSTDElementsInSCD(scd, List.of(std), DTO.SUB_NETWORK_TYPES));
+ assertThat(scd.getIED()).hasSize(1);
+ assertThat(scd.getDataTypeTemplates()).hasNoNullFieldsOrProperties();
+ assertThat(scd.getCommunication().getSubNetwork()).hasSize(2);
assertIsMarshallable(scd);
}
@@ -823,12 +805,12 @@ void testImportSTDElementsInSCD_with_Multiple_STD() {
SCL std2 = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std_SITESITE1SCU2.xml");
SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
- SclRootAdapter expectedScdAdapter = assertDoesNotThrow(() -> SclService.importSTDElementsInSCD(scdRootAdapter, Set.of(std0, std1, std2), DTO.comMap));
- assertThat(expectedScdAdapter.getCurrentElem().getIED()).hasSize(3);
- assertThat(expectedScdAdapter.getCurrentElem().getDataTypeTemplates()).hasNoNullFieldsOrProperties();
- assertThat(expectedScdAdapter.getCurrentElem().getCommunication().getSubNetwork()).hasSize(2);
- assertThat(expectedScdAdapter.getCurrentElem().getCommunication().getSubNetwork().get(0).getConnectedAP()).hasSizeBetween(1, 3);
- assertThat(expectedScdAdapter.getCurrentElem().getCommunication().getSubNetwork().get(1).getConnectedAP()).hasSizeBetween(1, 3);
+ assertDoesNotThrow(() -> SclService.importSTDElementsInSCD(scd, List.of(std0, std1, std2), DTO.SUB_NETWORK_TYPES));
+ assertThat(scd.getIED()).hasSize(3);
+ assertThat(scd.getDataTypeTemplates()).hasNoNullFieldsOrProperties();
+ assertThat(scd.getCommunication().getSubNetwork()).hasSize(2);
+ assertThat(scd.getCommunication().getSubNetwork().get(0).getConnectedAP()).hasSizeBetween(1, 3);
+ assertThat(scd.getCommunication().getSubNetwork().get(1).getConnectedAP()).hasSizeBetween(1, 3);
assertIsMarshallable(scd);
}
@@ -838,10 +820,9 @@ void testImportSTDElementsInSCD_Several_STD_Match_Compas_ICDHeader() {
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd.xml");
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
SCL std1 = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
- SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
//When Then
- Set stds = Set.of(std, std1);
- assertThrows(ScdException.class, () -> SclService.importSTDElementsInSCD(scdRootAdapter, stds, DTO.comMap));
+ List stds = List.of(std, std1);
+ assertThrows(ScdException.class, () -> SclService.importSTDElementsInSCD(scd, stds, DTO.SUB_NETWORK_TYPES));
assertIsMarshallable(scd);
}
@@ -850,9 +831,8 @@ void test_importSTDElementsInSCD_should_not_throw_exception_when_SCD_file_contai
//Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd_with_same_compas_icd_header_in_different_functions.xml");
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
- SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
//When Then
- assertDoesNotThrow(() -> SclService.importSTDElementsInSCD(scdRootAdapter, Set.of(std), DTO.comMap));
+ assertDoesNotThrow(() -> SclService.importSTDElementsInSCD(scd, List.of(std), DTO.SUB_NETWORK_TYPES));
assertIsMarshallable(scd);
}
@@ -863,8 +843,7 @@ void testImportSTDElementsInSCD_Compas_ICDHeader_Not_Match() {
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std_with_same_ICDSystemVersionUUID.xml");
SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
//When Then
- Set stds = Set.of(std);
- assertThrows(ScdException.class, () -> SclService.importSTDElementsInSCD(scdRootAdapter, stds, DTO.comMap));
+ assertThrows(ScdException.class, () -> SclService.importSTDElementsInSCD(scd, List.of(std), DTO.SUB_NETWORK_TYPES));
assertIsMarshallable(scd);
}
@@ -875,7 +854,7 @@ void testImportSTDElementsInSCD_No_STD_Match() {
SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
//When Then
Set stds = new HashSet<>();
- assertThrows(ScdException.class, () -> SclService.importSTDElementsInSCD(scdRootAdapter, stds, DTO.comMap));
+ assertThrows(ScdException.class, () -> SclService.importSTDElementsInSCD(scd, List.of(), DTO.SUB_NETWORK_TYPES));
assertIsMarshallable(scd);
}
@@ -951,63 +930,63 @@ void updateLDeviceStatus_shouldReturnReportWithError_MissingRequiredObject(Strin
assertEquals("off", getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue());
String before = MarshallerWrapper.marshall(scl);
// When
- SclReport sclReport = SclService.updateLDeviceStatus(scl);
+ List sclReportItems = SclService.updateLDeviceStatus(scl);
// Then
- String after = MarshallerWrapper.marshall(sclReport.getSclRootAdapter().getCurrentElem());
- assertFalse(sclReport.isSuccess());
- assertThat(sclReport.getSclReportItems())
+ String after = MarshallerWrapper.marshall(scl);
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse();
+ assertThat(sclReportItems)
.hasSize(1)
- .extracting(SclReportItem::getMessage, SclReportItem::getXpath)
+ .extracting(SclReportItem::message, SclReportItem::xpath)
.containsExactly(errors);
- assertEquals("off", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName1", "LDSUIED").get().getValue());
- assertEquals(before, after);
+ assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off");
+ assertThat(before).isEqualTo(after);
}
@ParameterizedTest(name = "{0}")
@MethodSource("sclProviderBasedLDeviceStatus")
void updateLDeviceStatus_shouldReturnReportWithError_WhenLDeviceStatusActiveOrUntestedOrInactive(String testCase, SCL scl, Tuple... errors) {
// Given
- assertEquals("off", getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue());
- assertEquals("on", getLDeviceStatusValue(scl, "IedName2", "LDSUIED").get().getValue());
- assertFalse(getLDeviceStatusValue(scl, "IedName3", "LDSUIED").isPresent());
+ assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off");
+ assertThat(getLDeviceStatusValue(scl, "IedName2", "LDSUIED").get().getValue()).isEqualTo("on");
+ assertThat(getLDeviceStatusValue(scl, "IedName3", "LDSUIED")).isEmpty();
String before = MarshallerWrapper.marshall(scl);
// When
- SclReport sclReport = SclService.updateLDeviceStatus(scl);
+ List sclReportItems = SclService.updateLDeviceStatus(scl);
// Then
- String after = MarshallerWrapper.marshall(sclReport.getSclRootAdapter().getCurrentElem());
- assertFalse(sclReport.isSuccess());
- assertThat(sclReport.getSclReportItems())
+ String after = MarshallerWrapper.marshall(scl);
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse();
+ assertThat(sclReportItems)
.hasSize(3)
- .extracting(SclReportItem::getMessage, SclReportItem::getXpath)
+ .extracting(SclReportItem::message, SclReportItem::xpath)
.containsExactly(errors);
- assertEquals("off", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName1", "LDSUIED").get().getValue());
- assertEquals("on", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName2", "LDSUIED").get().getValue());
- assertFalse(getLDeviceStatusValue(scl, "IedName3", "LDSUIED").isPresent());
- assertEquals(before, after);
+ assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off");
+ assertThat(getLDeviceStatusValue(scl, "IedName2", "LDSUIED").get().getValue()).isEqualTo("on");
+ assertThat(getLDeviceStatusValue(scl, "IedName3", "LDSUIED")).isEmpty();
+ assertThat(before).isEqualTo(after);
}
@Test
void updateLDeviceStatus_shouldReturnReportWithError_WhenAllLDeviceInactive_Test2() {
// Given
SCL scl = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test2_LD_STATUS_INACTIVE.scd");
- assertEquals("off", getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue());
- assertEquals("on", getLDeviceStatusValue(scl, "IedName2", "LDSUIED").get().getValue());
- assertFalse(getLDeviceStatusValue(scl, "IedName3", "LDSUIED").isPresent());
+ assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off");
+ assertThat(getLDeviceStatusValue(scl, "IedName2", "LDSUIED").get().getValue()).isEqualTo("on");
+ assertThat(getLDeviceStatusValue(scl, "IedName3", "LDSUIED")).isEmpty();
// When
- SclReport sclReport = SclService.updateLDeviceStatus(scl);
+ List sclReportItems = SclService.updateLDeviceStatus(scl);
// Then
- assertFalse(sclReport.isSuccess());
- assertThat(sclReport.getSclReportItems())
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse();
+ assertThat(sclReportItems)
.hasSize(2)
- .extracting(SclReportItem::getMessage, SclReportItem::getXpath)
+ .extracting(SclReportItem::message, SclReportItem::xpath)
.containsExactly(Tuple.tuple("The LDevice cannot be set to 'off' but has not been selected into SSD.",
"/SCL/IED[@name=\"IedName1\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0"),
Tuple.tuple("The LDevice is not qualified into STD but has been selected into SSD.",
"/SCL/IED[@name=\"IedName2\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0"));
- assertEquals("off", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName1", "LDSUIED").get().getValue());
- assertEquals("on", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName2", "LDSUIED").get().getValue());
- assertTrue(getLDeviceStatusValue(scl, "IedName3", "LDSUIED").isPresent());
- assertEquals("off", getLDeviceStatusValue(scl, "IedName3", "LDSUIED").get().getValue());
+ assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off");
+ assertThat(getLDeviceStatusValue(scl, "IedName2", "LDSUIED").get().getValue()).isEqualTo("on");
+ assertThat(getLDeviceStatusValue(scl, "IedName3", "LDSUIED")).isPresent();
+ assertThat(getLDeviceStatusValue(scl, "IedName3", "LDSUIED").get().getValue()).isEqualTo("off");
}
@@ -1015,26 +994,22 @@ void updateLDeviceStatus_shouldReturnReportWithError_WhenAllLDeviceInactive_Test
void updateLDeviceStatus_shouldReturnUpdatedFile() {
// Given
SCL givenScl = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_Template.scd");
- assertTrue(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED").isPresent());
- assertEquals("off", getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED").get().getValue());
-
- assertTrue(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED").isPresent());
- assertEquals("on", getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED").get().getValue());
-
- assertFalse(getLDeviceStatusValue(givenScl, "IedName3", "LDSUIED").isPresent());
+ assertThat(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED")).isPresent();
+ assertThat(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off");
+ assertThat(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED")).isPresent();
+ assertThat(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED").get().getValue()).isEqualTo("on");
+ assertThat(getLDeviceStatusValue(givenScl, "IedName3", "LDSUIED")).isEmpty();
// When
- SclReport sclReport = SclService.updateLDeviceStatus(givenScl);
+ List sclReportItems = SclService.updateLDeviceStatus(givenScl);
// Then
- assertTrue(sclReport.isSuccess());
- assertTrue(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName1", "LDSUIED").isPresent());
- assertEquals("on", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName1", "LDSUIED").get().getValue());
-
- assertTrue(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName2", "LDSUIED").isPresent());
- assertEquals("off", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName2", "LDSUIED").get().getValue());
-
- assertTrue(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName3", "LDSUIED").isPresent());
- assertEquals("off", getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName3", "LDSUIED").get().getValue());
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
+ assertThat(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED")).isPresent();
+ assertThat(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("on");
+ assertThat(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED")).isPresent();
+ assertThat(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED").get().getValue()).isEqualTo("off");
+ assertThat(getLDeviceStatusValue(givenScl, "IedName3", "LDSUIED")).isPresent();
+ assertThat(getLDeviceStatusValue(givenScl, "IedName3", "LDSUIED").get().getValue()).isEqualTo("off");
}
@Test
@@ -1056,29 +1031,28 @@ void updateLDeviceStatus_shouldReturnUpdatedFile_when_DAI_Mod_DO_stVal_whatever_
assertThat(getLDeviceStatusValue(givenScl, "IedName5", "LDSUIED"))
.map(TVal::getValue)
.hasValue("on");
-
// When
- SclReport sclReport = SclService.updateLDeviceStatus(givenScl);
+ List sclReportItems = SclService.updateLDeviceStatus(givenScl);
// Then
- assertThat(sclReport.isSuccess()).isTrue();
- assertThat(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName1", "LDSUIED"))
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
+ assertThat(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED"))
.map(TVal::getValue)
.hasValue("on");
- assertThat(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName2", "LDSUIED"))
+ assertThat(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED"))
.map(TVal::getValue)
.hasValue("off");
- assertThat(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName3", "LDSUIED"))
+ assertThat(getLDeviceStatusValue(givenScl, "IedName3", "LDSUIED"))
.map(TVal::getValue)
.hasValue("off");
- assertThat(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName4", "LDSUIED"))
+ assertThat(getLDeviceStatusValue(givenScl, "IedName4", "LDSUIED"))
.map(TVal::getValue)
.hasValue("off");
- assertThat(getLDeviceStatusValue(sclReport.getSclRootAdapter().getCurrentElem(), "IedName5", "LDSUIED"))
+ assertThat(getLDeviceStatusValue(givenScl, "IedName5", "LDSUIED"))
.map(TVal::getValue)
.hasValue("off");
}
@@ -1101,15 +1075,15 @@ void updateDoInRef_shouldReturnUpdatedFile(String testName, String ldInst, Strin
SCL givenScl = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_issue_231_test_ok.xml");
// When
- SclReport sclReport = SclService.updateDoInRef(givenScl);
+ List sclReportItems = SclService.updateDoInRef(givenScl);
// Then
- assertThat(sclReport.isSuccess()).isTrue();
- SclTestMarshaller.assertIsMarshallable(sclReport.getSclRootAdapter().currentElem);
- assertThat(getValFromDaiName(sclReport.getSclRootAdapter().getCurrentElem(), "IED_NAME1", ldInst, doName, daName)
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
+ SclTestMarshaller.assertIsMarshallable(givenScl);
+ assertThat(getValFromDaiName(givenScl, "IED_NAME1", ldInst, doName, daName)
.map(TVal::getValue))
.hasValue(expected);
- assertIsMarshallable(sclReport.getSclRootAdapter().getCurrentElem());
+ assertIsMarshallable(givenScl);
}
@ParameterizedTest(name = "{0}")
@@ -1125,11 +1099,11 @@ void updateDoInRef_should_not_update_DAI(String testName, String ldInst, String
SCL givenScl = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_issue_231_test_ok.xml");
// When
- SclReport sclReport = SclService.updateDoInRef(givenScl);
+ List sclReportItems = SclService.updateDoInRef(givenScl);
// Then
- assertThat(sclReport.isSuccess()).isTrue();
- assertThat(getValFromDaiName(sclReport.getSclRootAdapter().getCurrentElem(), "IED_NAME1", ldInst, doName, daName)).isNotPresent();
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
+ assertThat(getValFromDaiName(givenScl, "IED_NAME1", ldInst, doName, daName)).isNotPresent();
}
@Test
@@ -1138,12 +1112,11 @@ void updateDoInRef_shouldReturnReportWithError_when_ExtRef_not_coherent() {
SCL givenScl = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_issue_231_test_ko.xml");
// When
- SclReport sclReport = SclService.updateDoInRef(givenScl);
+ List sclReportItems = SclService.updateDoInRef(givenScl);
// Then
- assertThat(sclReport.isSuccess()).isTrue();
- assertThat(sclReport.getSclReportItems()).isNotEmpty();
- assertThat(sclReport.getSclReportItems()).hasSize(4);
+ assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue();
+ assertThat(sclReportItems).hasSize(4);
}
private Optional getValFromDaiName(SCL scl, String iedName, String ldInst, String doiName, String daiName) {
@@ -1173,9 +1146,9 @@ void analyzeDataGroups_should_success() {
iedAdapter1.getCurrentElem().getAccessPoint().get(0).getServices().getClientServices().setMaxSMV(2L);
iedAdapter1.getCurrentElem().getAccessPoint().get(0).getServices().getClientServices().setMaxReports(1L);
// When
- SclReport sclReport = SclService.analyzeDataGroups(scd);
+ List sclReportItems = SclService.analyzeDataGroups(scd);
//Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
+ assertThat(sclReportItems).isEmpty();
}
@@ -1192,10 +1165,10 @@ void analyzeDataGroups_should_return_errors_messages() {
iedAdapter.getCurrentElem().getAccessPoint().get(0).getServices().getGOOSE().setMax(2L);
iedAdapter.getCurrentElem().getAccessPoint().get(0).getServices().getConfReportControl().setMax(0L);
// When
- SclReport sclReport = SclService.analyzeDataGroups(scd);
+ List sclReportItems = SclService.analyzeDataGroups(scd);
//Then
- assertThat(sclReport.getSclReportItems()).hasSize(11)
- .extracting(SclReportItem::getMessage)
+ assertThat(sclReportItems).hasSize(11)
+ .extracting(SclReportItem::message)
.containsExactlyInAnyOrder(
"The Client IED IED_NAME1 subscribes to too much FCDA: 9 > 8 max",
"The Client IED IED_NAME1 subscribes to too much GOOSE Control Blocks: 3 > 2 max",
@@ -1215,16 +1188,16 @@ void manageMonitoringLns_should_update_and_create_lsvs_and_goose() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/monitoring_lns/scd_monitoring_lsvs_lgos.xml");
// When
- SclReport sclReport = SclService.manageMonitoringLns(scd);
+ List sclReportItems = SclService.manageMonitoringLns(scd);
//Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
- LDeviceAdapter lDeviceAdapter = sclReport.getSclRootAdapter().getIEDAdapterByName("IED_NAME1").getLDeviceAdapterByLdInst(LD_SUIED);
+ assertThat(sclReportItems).isEmpty();
+ LDeviceAdapter lDeviceAdapter = new SclRootAdapter(scd).getIEDAdapterByName("IED_NAME1").getLDeviceAdapterByLdInst(LD_SUIED);
assertThat(lDeviceAdapter.getLNAdapters())
.hasSize(4)
.extracting(LNAdapter::getLNClass, LNAdapter::getLNInst).containsExactlyInAnyOrder(
Tuple.tuple("LGOS", "1"), Tuple.tuple("LGOS", "2"),
Tuple.tuple("LSVS", "1"), Tuple.tuple("LSVS", "2"));
- SclTestMarshaller.assertIsMarshallable(sclReport.getSclRootAdapter().currentElem);
+ SclTestMarshaller.assertIsMarshallable(scd);
}
@Test
@@ -1237,15 +1210,15 @@ void manageMonitoringLns_should_not_update_and_not_create_lsvs_and_goose_when_no
LDeviceAdapter lDeviceAdapter21 = sclRootAdapter.getIEDAdapterByName("IED_NAME1").getLDeviceAdapterByLdInst("LD_INST21");
lDeviceAdapter21.getLN0Adapter().getCurrentElem().setInputs(null);
// When
- SclReport sclReport = SclService.manageMonitoringLns(scd);
+ List sclReportItems = SclService.manageMonitoringLns(scd);
//Then
- assertThat(sclReport.getSclReportItems()).isEmpty();
+ assertThat(sclReportItems).isEmpty();
LDeviceAdapter lDeviceAdapter = sclRootAdapter.getIEDAdapterByName("IED_NAME1").getLDeviceAdapterByLdInst(LD_SUIED);
assertThat(lDeviceAdapter.getLNAdapters())
.hasSize(2)
.extracting(LNAdapter::getLNClass, LNAdapter::getLNInst).containsExactlyInAnyOrder(
Tuple.tuple("LGOS", "3"), Tuple.tuple("LSVS", "9"));
- SclTestMarshaller.assertIsMarshallable(sclReport.getSclRootAdapter().currentElem);
+ SclTestMarshaller.assertIsMarshallable(scd);
}
@Test
@@ -1259,18 +1232,18 @@ void manageMonitoringLns_should_not_update_and_not_create_lsvs_and_goose_when_da
getDAIAdapters(lDeviceAdapter, "LSVS", "SvCBRef", "setSrcRef")
.forEach(daiAdapter -> daiAdapter.getCurrentElem().setValImport(false));
// When
- SclReport sclReport = SclService.manageMonitoringLns(scd);
+ List sclReportItems = SclService.manageMonitoringLns(scd);
//Then
- assertThat(sclReport.getSclReportItems())
+ assertThat(sclReportItems)
.isNotEmpty()
.hasSize(2)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactly("The DAI cannot be updated", "The DAI cannot be updated");
assertThat(lDeviceAdapter.getLNAdapters())
.hasSize(2)
.extracting(LNAdapter::getLNClass, LNAdapter::getLNInst).containsExactlyInAnyOrder(
Tuple.tuple("LGOS", "3"), Tuple.tuple("LSVS", "9"));
- SclTestMarshaller.assertIsMarshallable(sclReport.getSclRootAdapter().currentElem);
+ SclTestMarshaller.assertIsMarshallable(scd);
}
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SubstationServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SubstationServiceTest.java
index 16d46ef35..1c6d9bbee 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SubstationServiceTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/SubstationServiceTest.java
@@ -7,49 +7,49 @@
import org.junit.jupiter.api.Test;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TSubstation;
+import org.lfenergy.compas.scl2007b4.model.TVoltageLevel;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller.assertIsMarshallable;
class SubstationServiceTest {
@Test
- void addSubstation_when_SCD_has_no_substation_should_succeed() throws Exception {
+ void addSubstation_when_SCD_has_no_substation_should_succeed() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-root-test-schema-conf/add_ied_test.xml");
- SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
- SclRootAdapter ssdRootAdapter = new SclRootAdapter(ssd);
+ assertThat(scd.getSubstation().size()).isZero();
// When
- SclRootAdapter resultScdAdapter = SubstationService.addSubstation(scd, ssd);
+ SubstationService.addSubstation(scd, ssd);
// Then
- assertNotEquals(scdRootAdapter, resultScdAdapter);
- assertEquals(resultScdAdapter.getCurrentElem().getSubstation(), ssdRootAdapter.getCurrentElem().getSubstation());
assertIsMarshallable(scd);
+ assertThat(scd.getSubstation().size()).isNotZero();
+ assertThat(scd.getSubstation()).isEqualTo(ssd.getSubstation());
}
@Test
- void addSubstation_when_SCD_has_a_substation_should_succeed() throws Exception {
+ void addSubstation_when_SCD_has_a_substation_should_succeed() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/scd_with_substation.xml");
- SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
- SclRootAdapter ssdRootAdapter = new SclRootAdapter(ssd);
- TSubstation ssdSubstation = ssdRootAdapter.getCurrentElem().getSubstation().get(0);
+ TSubstation scdSubstation = scd.getSubstation().get(0);
+ TSubstation ssdSubstation = ssd.getSubstation().get(0);
+ assertThat(scdSubstation.getVoltageLevel().stream().map(TVoltageLevel::getBay).count()).isEqualTo(1);
// When
- SclRootAdapter resultScdAdapter = SubstationService.addSubstation(scd, ssd);
+ SubstationService.addSubstation(scd, ssd);
// Then
- TSubstation resultSubstation = resultScdAdapter.getCurrentElem().getSubstation().get(0);
- assertNotEquals(scdRootAdapter, resultScdAdapter);
- assertEquals(ssdSubstation.getName(), resultSubstation.getName());
- assertEquals(ssdSubstation.getVoltageLevel().size(), resultSubstation.getVoltageLevel().size());
assertIsMarshallable(scd);
+ assertThat(scdSubstation.getName()).isEqualTo(ssdSubstation.getName());
+ assertThat(scd.getSubstation().size()).isEqualTo(ssd.getSubstation().size());
+ assertThat(scdSubstation.getVoltageLevel().stream().map(TVoltageLevel::getBay).count()).isEqualTo(2);
}
@Test
- void addSubstation_when_SSD_with_multiple_Substations_should_throw_exception() throws Exception {
+ void addSubstation_when_SSD_with_multiple_Substations_should_throw_exception() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-root-test-schema-conf/add_ied_test.xml");
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd_with_2_substations.xml");
@@ -59,7 +59,7 @@ void addSubstation_when_SSD_with_multiple_Substations_should_throw_exception() t
}
@Test
- void addSubstation_when_SSD_with_no_substation_should_throw_exception() throws Exception {
+ void addSubstation_when_SSD_with_no_substation_should_throw_exception() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-root-test-schema-conf/add_ied_test.xml");
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd_without_substations.xml");
@@ -69,7 +69,7 @@ void addSubstation_when_SSD_with_no_substation_should_throw_exception() throws E
}
@Test
- void addSubstation_when_substations_names_differ_should_throw_exception() throws Exception {
+ void addSubstation_when_substations_names_differ_should_throw_exception() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/scd_with_substation_name_different.xml");
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapterTest.java
index 987b8b268..522ecd2c4 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/com/ConnectedAPAdapterTest.java
@@ -64,10 +64,9 @@ void testCopyAddressAndPhysConnFromIcd_withFilledCommunication() {
SCL icd = SclTestMarshaller.getSCLFromFile("/scl-srv-import-ieds/ied_with_filled_communication.xml");
SclRootAdapter icdRootAdapter = new SclRootAdapter(icd);
- Optional opIcd = Optional.of(icdRootAdapter.getCurrentElem());
// WHEN
- connectedAPAdapter.copyAddressAndPhysConnFromIcd(opIcd);
+ connectedAPAdapter.copyAddressAndPhysConnFromIcd(icdRootAdapter.getCurrentElem());
// THEN
assertThat(connectedAPAdapter.getCurrentElem().getAddress()).isNotNull();
@@ -81,10 +80,9 @@ void testCopyAddressAndPhysConnFromIcd_withEmptyIcd() {
ConnectedAPAdapter connectedAPAdapter = assertDoesNotThrow(
() -> subNetworkAdapter.getConnectedAPAdapter(DTO.HOLDER_IED_NAME, DTO.AP_NAME)
);
- Optional opIcd = Optional.empty();
// WHEN
- connectedAPAdapter.copyAddressAndPhysConnFromIcd(opIcd);
+ connectedAPAdapter.copyAddressAndPhysConnFromIcd(null);
// THEN
assertThat(connectedAPAdapter.getCurrentElem().getAddress()).isNull();
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapterTest.java
index 4f0e805a7..9afe7d472 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/AccessPointAdapterTest.java
@@ -91,7 +91,7 @@ void checkFCDALimitations_should_fail_with_one_error_messages() {
List sclReportItems = accessPointAdapter.checkFCDALimitations();
//Then
assertThat(sclReportItems).hasSize(1)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactlyInAnyOrder("There are too much FCDA for the DataSet dataset6 for the LDevice LD_INST21 in IED IED_NAME: 3 > 2 max");
}
@Test
@@ -103,7 +103,7 @@ void checkFCDALimitations_should_fail_with_four_error_messages() {
List sclReportItems = accessPointAdapter.checkFCDALimitations();
//Then
assertThat(sclReportItems).hasSize(4)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactlyInAnyOrder("There are too much FCDA for the DataSet dataset3 for the LDevice LD_INST21 in IED IED_NAME: 2 > 1 max",
"There are too much FCDA for the DataSet dataset6 for the LDevice LD_INST21 in IED IED_NAME: 3 > 1 max",
"There are too much FCDA for the DataSet dataset6 for the LDevice LD_INST22 in IED IED_NAME: 2 > 1 max",
@@ -120,7 +120,7 @@ void checkControlsLimitation_should_fail_for_dataset_with_one_error_messages() {
Optional sclReportItem = accessPointAdapter.checkControlsLimitation(ServicesConfigEnum.DATASET);
//Then
assertThat(sclReportItem).isPresent()
- .get().extracting(SclReportItem::getMessage).isEqualTo("There are too much DataSets for the IED IED_NAME: 6 > 5 max");
+ .get().extracting(SclReportItem::message).isEqualTo("There are too much DataSets for the IED IED_NAME: 6 > 5 max");
}
@Test
@@ -132,7 +132,7 @@ void checkControlsLimitation_should_fail_for_smv_with_one_error_messages() {
Optional sclReportItem = accessPointAdapter.checkControlsLimitation(ServicesConfigEnum.SMV);
//Then
assertThat(sclReportItem).isPresent()
- .get().extracting(SclReportItem::getMessage).isEqualTo("There are too much SMV Control Blocks for the IED IED_NAME: 3 > 2 max");
+ .get().extracting(SclReportItem::message).isEqualTo("There are too much SMV Control Blocks for the IED IED_NAME: 3 > 2 max");
}
@Test
@@ -144,7 +144,7 @@ void checkControlsLimitation_should_fail_for_goose_with_one_error_messages() {
Optional sclReportItem = accessPointAdapter.checkControlsLimitation(ServicesConfigEnum.GSE);
//Then
assertThat(sclReportItem).isPresent()
- .get().extracting(SclReportItem::getMessage).isEqualTo("There are too much GOOSE Control Blocks for the IED IED_NAME: 3 > 2 max");
+ .get().extracting(SclReportItem::message).isEqualTo("There are too much GOOSE Control Blocks for the IED IED_NAME: 3 > 2 max");
}
@Test
@@ -156,7 +156,7 @@ void checkControlsLimitation_should_fail_for_report_with_one_error_messages() {
Optional sclReportItem = accessPointAdapter.checkControlsLimitation(ServicesConfigEnum.REPORT);
//Then
assertThat(sclReportItem).isPresent()
- .get().extracting(SclReportItem::getMessage).isEqualTo("There are too much Report Control Blocks for the IED IED_NAME: 1 > 0 max");
+ .get().extracting(SclReportItem::message).isEqualTo("There are too much Report Control Blocks for the IED IED_NAME: 1 > 0 max");
}
public static AccessPointAdapter provideAPForCheckLimitationForIED() {
@@ -242,7 +242,7 @@ void checkLimitationForBoundIEDFCDAs_should_fail_one_error_message() {
//Then
assertThat(sclReportItem).isPresent()
.get()
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.isEqualTo("The Client IED IED_NAME1 subscribes to too much FCDA: 9 > 4 max");
}
@@ -259,7 +259,7 @@ void checkLimitationForBoundIEDControls_should_fail_three_error_messages() {
//Then
assertThat(sclReportItems).hasSize(3)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactlyInAnyOrder("The Client IED IED_NAME1 subscribes to too much GOOSE Control Blocks: 3 > 2 max",
"The Client IED IED_NAME1 subscribes to too much SMV Control Blocks: 2 > 1 max",
"The Client IED IED_NAME1 subscribes to too much Report Control Blocks: 1 > 0 max");
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java
index 5e7abdcf8..7ce9234c4 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/ControlBlockAdapterTest.java
@@ -40,11 +40,10 @@ void getName_should_return_name(){
void addTargetIfNotExists_should_add_target(){
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST11");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST11");
ln0.createDataSetIfNotExists("datSet", ControlBlockEnum.GSE);
ControlBlockAdapter controlBlockAdapter = ln0.createControlBlockIfNotExists("cbName", "cbId", "datSet", ControlBlockEnum.GSE);
- LNAdapter targetLn = findLn(sclRootAdapter, "IED_NAME2", "LD_INST21", "ANCR", "1", "prefix");
+ LNAdapter targetLn = findLn(scd, "IED_NAME2", "LD_INST21", "ANCR", "1", "prefix");
// When
controlBlockAdapter.addTargetIfNotExists(targetLn);
@@ -65,8 +64,7 @@ void configureNetwork_should_add_GSE_element() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
TConnectedAP connectedAP = SclHelper.addConnectedAp(scd, "SUB_NETWORK_NAME", "AP_NAME", "IED_NAME1");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST11");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST11");
ln0.createDataSetIfNotExists("datSet", ControlBlockEnum.GSE);
ControlBlockAdapter controlBlockAdapter = ln0.createControlBlockIfNotExists("cbName", "cbId", "datSet", ControlBlockEnum.GSE);
// When
@@ -95,8 +93,7 @@ void configureNetwork_should_add_SMV_element() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
TConnectedAP connectedAP = SclHelper.addConnectedAp(scd, "SUB_NETWORK_NAME", "AP_NAME", "IED_NAME1");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST11");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST11");
ln0.createDataSetIfNotExists("datSet", ControlBlockEnum.SAMPLED_VALUE);
ControlBlockAdapter controlBlockAdapter = ln0.createControlBlockIfNotExists("cbName", "cbId", "datSet", ControlBlockEnum.SAMPLED_VALUE);
// When
@@ -120,8 +117,7 @@ void configureNetwork_when_connectApNotFound_should_return_sclReportItem() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
SclHelper.addConnectedAp(scd, "SUB_NETWORK_NAME", "AP_NAME", "IED_NAME2"); // ConnectedAp for IED_NAME2 instead of IED_NAME1
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST11");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST11");
ln0.createDataSetIfNotExists("datSet", ControlBlockEnum.SAMPLED_VALUE);
ControlBlockAdapter controlBlockAdapter = ln0.createControlBlockIfNotExists("cbName", "cbId", "datSet", ControlBlockEnum.SAMPLED_VALUE);
// When
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java
index e1454f31b..0ba358149 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/DOIAdapterTest.java
@@ -462,7 +462,7 @@ void updateDaiFromExtRef_should_return_warning_report_when_none_ExtRef_endin_wit
// Then
assertThat(sclReportItems)
.isNotEmpty()
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.contains("The DOI /DOI[@name=\"Do\"] can't be bound with an ExtRef");
assertThat(doiAdapter.getDataAdapterByName(SETSRCREF_DA_NAME)).isNotNull();
assertThat(getDaiValOfDoi(doiAdapter, SETSRCREF_DA_NAME)).isNotPresent();
@@ -500,7 +500,7 @@ void updateDaiFromExtRef_should_return_filled_ReportItem_when_no_ExtRef_in_LNode
assertThat(sclReportItems)
.isNotEmpty();
assertThat(sclReportItems)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.contains("The DOI /DOI[@name=\"Do\"] can't be bound with an ExtRef");
}
@@ -624,7 +624,7 @@ void updateDai_should_not_update_value_and_return_warning_message_when_dai_is_no
// Then
assertThat(sclReportItems).isPresent()
- .get().extracting(SclReportItem::getMessage)
+ .get().extracting(SclReportItem::message)
.isEqualTo("The DAI setSrcRef cannot be updated");
assertThat(getDaiValOfDoi(doiAdapter, SETSRCREF_DA_NAME)).isPresent()
.get().extracting(TVal::getValue)
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java
index a24685dd6..29de7b98b 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/IEDAdapterTest.java
@@ -232,7 +232,7 @@ void checkDataGroupCoherence_should_fail_five_error_message() {
List sclReportItems = iedAdapter.checkDataGroupCoherence();
//Then
assertThat(sclReportItems)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactlyInAnyOrder("There are too much FCDA for the DataSet dataset6 for the LDevice LD_INST21 in IED IED_NAME: 3 > 2 max",
"There are too much DataSets for the IED IED_NAME: 6 > 5 max",
"There are too much Report Control Blocks for the IED IED_NAME: 1 > 0 max",
@@ -263,7 +263,7 @@ void checkBindingDataGroupCoherence_should_fail_five_error_message() {
List sclReportItems = iedAdapter.checkBindingDataGroupCoherence();
//Then
assertThat(sclReportItems).hasSize(4)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactlyInAnyOrder("The Client IED IED_NAME1 subscribes to too much FCDA: 9 > 8 max",
"The Client IED IED_NAME1 subscribes to too much Report Control Blocks: 1 > 0 max",
"The Client IED IED_NAME1 subscribes to too much SMV Control Blocks: 2 > 1 max",
@@ -344,7 +344,7 @@ void manageMonitoringLns_should_not_create_ln_when_no_init_ln(String testCase, M
List sclReportItems = iedAdapter.manageMonitoringLns();
// Then
assertThat(sclReportItems).isNotEmpty()
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactly("There is no LN " + lnClassEnum.value() + " present in LDevice");
assertThat(lDeviceAdapter.getLNAdapters()).isEmpty();
}
@@ -388,7 +388,7 @@ void manageMonitoringLns_should_not_update_ln_when_one_extRef_and_dai_not_updata
// Then
LDeviceAdapter lDeviceAdapter = iedAdapter.getLDeviceAdapterByLdInst(LD_SUIED);
assertThat(sclReportItems).isNotEmpty()
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactly("The DAI cannot be updated");
assertThat(lDeviceAdapter.getLNAdapters())
.hasSize(1);
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java
index b8ff373e4..f6323b99c 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/InputsAdapterTest.java
@@ -56,13 +56,12 @@ void elementXPath_should_succeed() {
void updateAllSourceDataSetsAndControlBlocks_should_report_Target_Ied_missing_Private_compasBay_errors() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_ied_errors.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- InputsAdapter inputsAdapter = findInputs(sclRootAdapter, "IED_NAME1", "LD_INST11");
+ InputsAdapter inputsAdapter = findInputs(scd, "IED_NAME1", "LD_INST11");
// When
List sclReportItems = inputsAdapter.updateAllSourceDataSetsAndControlBlocks();
// Then
assertThat(sclReportItems).containsExactly(
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME1\"]",
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME1\"]",
"IED is missing Private/compas:Bay@UUID attribute")
);
}
@@ -71,13 +70,12 @@ void updateAllSourceDataSetsAndControlBlocks_should_report_Target_Ied_missing_Pr
void updateAllSourceDataSetsAndControlBlocks_should_report_Source_Ied_missing_Private_compasBay_errors() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_ied_errors.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- InputsAdapter inputsAdapter = findInputs(sclRootAdapter, "IED_NAME3", "LD_INST31");
+ InputsAdapter inputsAdapter = findInputs(scd, "IED_NAME3", "LD_INST31");
// When
List sclReportItems = inputsAdapter.updateAllSourceDataSetsAndControlBlocks();
// Then
assertThat(sclReportItems).containsExactly(
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME3\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST31\"]/LN0/Inputs/ExtRef[@desc=\"Source IED is " +
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME3\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST31\"]/LN0/Inputs/ExtRef[@desc=\"Source IED is " +
"missing compas:Bay @UUID\"]",
"Source IED is missing Private/compas:Bay@UUID attribute")
);
@@ -87,19 +85,18 @@ void updateAllSourceDataSetsAndControlBlocks_should_report_Source_Ied_missing_Pr
void updateAllSourceDataSetsAndControlBlocks_should_report_ExtRef_attribute_missing() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_extref_errors.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- InputsAdapter inputsAdapter = findInputs(sclRootAdapter, "IED_NAME1", "LD_INST11");
+ InputsAdapter inputsAdapter = findInputs(scd, "IED_NAME1", "LD_INST11");
// When
List sclReportItems = inputsAdapter.updateAllSourceDataSetsAndControlBlocks();
// Then
assertThat(sclReportItems).containsExactlyInAnyOrder(
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]/LN0/Inputs/" +
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]/LN0/Inputs/" +
"ExtRef[@desc=\"ExtRef is missing ServiceType attribute\"]",
"The signal ExtRef is missing ServiceType attribute"),
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]/LN0/Inputs/" +
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]/LN0/Inputs/" +
"ExtRef[@desc=\"ExtRef is ServiceType Poll\"]",
"The signal ExtRef ServiceType attribute is unexpected : POLL"),
- SclReportItem.fatal("/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]/LN0/Inputs/" +
+ SclReportItem.error("/SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"LD_INST11\"]/LN0/Inputs/" +
"ExtRef[@desc=\"ExtRef is ServiceType Report with malformed desc attribute\"]",
"ExtRef.serviceType=Report but ExtRef.desc attribute is malformed")
);
@@ -109,8 +106,7 @@ void updateAllSourceDataSetsAndControlBlocks_should_report_ExtRef_attribute_miss
void updateAllSourceDataSetsAndControlBlocks_should_succeed() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-create-dataset-and-controlblocks/scd_create_dataset_and_controlblocks_success.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- InputsAdapter inputsAdapter = findInputs(sclRootAdapter, "IED_NAME1", "LD_INST11");
+ InputsAdapter inputsAdapter = findInputs(scd, "IED_NAME1", "LD_INST11");
// When
List sclReportItems = inputsAdapter.updateAllSourceDataSetsAndControlBlocks();
// Then
@@ -137,7 +133,7 @@ void updateAllSourceDataSetsAndControlBlocks_should_create_dataset_and_fcda_for_
List sclReportItems = inputsAdapter.updateAllSourceDataSetsAndControlBlocks();
// Then
assertThat(sclReportItems).isEmpty();
- DataSetAdapter dataSet = findDataSet(sclRootAdapter, expectedSourceIedName, expectedSourceLDeviceInst, expectedDataSetName);
+ DataSetAdapter dataSet = findDataSet(scd, expectedSourceIedName, expectedSourceLDeviceInst, expectedDataSetName);
assertThat(dataSet.getCurrentElem().getFCDA())
.extracting(TFCDA::getLdInst)
.containsOnly(expectedSourceLDeviceInst);
@@ -234,13 +230,13 @@ void updateAllSourceDataSetsAndControlBlocks_when_AccessPoint_does_not_have_data
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
InputsAdapter inputsAdapter = keepOnlyThisExtRef(sclRootAdapter, "test bay internal");
TExtRef extRef = inputsAdapter.getCurrentElem().getExtRef().get(0);
- LDeviceAdapter sourceLDevice = findLDevice(sclRootAdapter, extRef.getIedName(), extRef.getLdInst());
+ LDeviceAdapter sourceLDevice = findLDevice(sclRootAdapter.getCurrentElem(), extRef.getIedName(), extRef.getLdInst());
sourceLDevice.getAccessPoint().setServices(new TServices());
// When
List sclReportItems = inputsAdapter.updateAllSourceDataSetsAndControlBlocks();
// Then
assertThat(sclReportItems).hasSize(1)
- .first().extracting(SclReportItem::getMessage).asString()
+ .first().extracting(SclReportItem::message).asString()
.startsWith("Could not create DataSet or ControlBlock for this ExtRef : IED/AccessPoint does not have capability to create DataSet of type GSE");
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapterTest.java
index 6a0735fed..2868d52a1 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LDeviceAdapterTest.java
@@ -485,7 +485,7 @@ void manageMonitoringLns_should_not_create_ln_when_no_init_ln(String testCase, M
// Then
assertThat(sclReportItem).isPresent();
assertThat(sclReportItem.get())
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.isEqualTo("There is no LN " + lnClassEnum.value() + " present in LDevice");
assertThat(lDeviceAdapter.getLNAdapters()).isEmpty();
}
@@ -526,7 +526,7 @@ void manageMonitoringLns_should_not_update_ln_when_one_extRef_and_dai_not_updata
// Then
assertThat(sclReportItem).isPresent();
assertThat(sclReportItem.get())
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.isEqualTo("The DAI cannot be updated");
assertThat(lDeviceAdapter.getLNAdapters())
.hasSize(1);
@@ -589,7 +589,7 @@ void getExtRefBayReferenceForActifLDEPF_should_return_fatal_errors_when_NoPrivat
assertThat(extRefBayReferences).isEmpty();
assertThat(sclReportItems).hasSize(2);
assertThat(sclReportItems)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.contains("The IED has no Private Bay", "The IED has no Private compas:ICDHeader");
}
@@ -606,7 +606,7 @@ void getExtRefBayReferenceForActifLDEPF_should_return_fatal_errors_when_DOI_Mod_
assertThat(extRefBayReferences).isEmpty();
assertThat(sclReportItems).hasSize(1);
assertThat(sclReportItems)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactly("There is no DOI@name=" + MOD_DO_TYPE_NAME + "/DAI@name=" + STVAL_DA_TYPE_NAME + "/Val for LDevice@inst" + LDEVICE_LDEPF);
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java
index 7632cba4a..366c2d64e 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LN0AdapterTest.java
@@ -651,7 +651,7 @@ private static Stream provideControlBlocks() {
void getTControlsByType_should_return_LN0_list_of_controls_for_this_class(Class extends TControl> tControlClass, Function> getter) {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
- LN0Adapter ln0Adapter = findLn0(new SclRootAdapter(scd), "IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "LDSUIED");
+ LN0Adapter ln0Adapter = findLn0(scd, "IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "LDSUIED");
// When
List extends TControl> controlList = ln0Adapter.getTControlsByType(tControlClass);
// Then
@@ -682,8 +682,7 @@ void elementXPath() {
void getLnStatus_should_return_ModStValValue() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST13");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST13");
// When
Optional lnStatus = ln0.getDaiModStValValue();
// Then
@@ -694,8 +693,7 @@ void getLnStatus_should_return_ModStValValue() {
void getLnStatus_should_return_empty_Optional() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-extref-iedname/scd_set_extref_iedname_with_extref_errors.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter ln0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_INST14");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST14");
// When
Optional lnStatus = ln0.getDaiModStValValue();
// Then
@@ -706,7 +704,7 @@ void getLnStatus_should_return_empty_Optional() {
void createDataSetIfNotExists_should_create_dataSet() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
- LN0Adapter ln0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", "LD_INST11");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST11");
assertThat(ln0.getCurrentElem().getDataSet()).isEmpty();
// When
DataSetAdapter newDataSet = ln0.createDataSetIfNotExists("newDataSet", ControlBlockEnum.GSE);
@@ -722,7 +720,7 @@ void createDataSetIfNotExists_should_create_dataSet() {
void createDataSetIfNotExists_when_dataset_exists_should_not_create_dataset() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
- LN0Adapter ln0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", "LD_INST12");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME1", "LD_INST12");
assertThat(ln0.getCurrentElem().getDataSet()).hasSize(1);
// When
DataSetAdapter newDataSet = ln0.createDataSetIfNotExists("existingDataSet", ControlBlockEnum.GSE);
@@ -738,7 +736,7 @@ void createDataSetIfNotExists_when_dataset_exists_should_not_create_dataset() {
void createDataSetIfNotExists_when_ied_does_not_have_creation_capabilities_should_throw_exception() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
- LN0Adapter ln0 = findLn0(new SclRootAdapter(scd), "IED_NAME2", "LD_INST21");
+ LN0Adapter ln0 = findLn0(scd, "IED_NAME2", "LD_INST21");
// When & Then
assertThatThrownBy(() -> ln0.createDataSetIfNotExists("existingDataSet", ControlBlockEnum.GSE))
.isInstanceOf(ScdException.class);
@@ -748,7 +746,7 @@ void createDataSetIfNotExists_when_ied_does_not_have_creation_capabilities_shoul
void createControlBlockIfNotExists_should_create_GSEControl() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
- LN0Adapter sourceLn0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", "LD_INST11");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_INST11");
assertThat(sourceLn0.getCurrentElem().getDataSet()).isEmpty();
final String NEW_DATASET_NAME = "newDataSet";
final String NEW_CB_NAME = "newControlBlock";
@@ -769,7 +767,7 @@ void createControlBlockIfNotExists_should_create_GSEControl() {
void createControlBlockIfNotExists_should_create_SampledValueControl() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
- LN0Adapter sourceLn0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", "LD_INST11");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_INST11");
assertThat(sourceLn0.getCurrentElem().getDataSet()).isEmpty();
final String NEW_DATASET_NAME = "newDataSet";
final String NEW_CB_NAME = "newControlBlock";
@@ -797,7 +795,7 @@ void createControlBlockIfNotExists_should_create_SampledValueControl() {
void createControlBlockIfNotExists_should_create_ReportControl() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-ln-adapter/scd_with_ln.xml");
- LN0Adapter sourceLn0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", "LD_INST11");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_INST11");
assertThat(sourceLn0.getCurrentElem().getDataSet()).isEmpty();
final String NEW_DATASET_NAME = "newDataSet";
@@ -925,14 +923,14 @@ void getFCDAs_should_throw_Exception_when_DataSet_not_present() {
void updateDoInRef_should_return_error_message(String testName, String ldInst, String doiName) {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_test.xml");
- LN0Adapter sourceLn0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", ldInst);
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", ldInst);
// When
List sclReportItems = sourceLn0.updateDoInRef();
// Then
assertThat(sclReportItems).hasSize(1)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactly("The DOI /SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"" + ldInst + "\"]/LN0/DOI[@name=\"" + doiName + "\"] can't be bound with an ExtRef");
}
@@ -940,14 +938,14 @@ void updateDoInRef_should_return_error_message(String testName, String ldInst, S
void updateDoInRef_should_return_error_message_when_no_Val_in_DAI_purpose() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_test.xml");
- LN0Adapter sourceLn0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", "LD_Without_Val_in_DAI_purpose");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_Without_Val_in_DAI_purpose");
// When
List sclReportItems = sourceLn0.updateDoInRef();
// Then
assertThat(sclReportItems).hasSize(1)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactly("The DOI /SCL/IED[@name=\"IED_NAME1\"]/AccessPoint/Server/LDevice[@inst=\"" + "LD_Without_Val_in_DAI_purpose" + "\"]/LN0 can't be bound with an ExtRef");
}
@@ -955,7 +953,7 @@ void updateDoInRef_should_return_error_message_when_no_Val_in_DAI_purpose() {
void updateDoInRef_should_not_treat_LN0_when_DAI_name_purpose_not_compliant() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_test.xml");
- LN0Adapter sourceLn0 = findLn0(new SclRootAdapter(scd), "IED_NAME1", "LD_Without_purpose");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_Without_purpose");
// When
List sclReportItems = sourceLn0.updateDoInRef();
@@ -970,8 +968,7 @@ void updateDoInRef_should_not_treat_LN0_when_DAI_name_purpose_not_compliant() {
void updateDoInRef_should_update_setSrcRef_and_not_setSrcCB_when_one_ExtRef_desc_matches() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_test.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter sourceLn0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_WITH_1_InRef_without_cbName");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_WITH_1_InRef_without_cbName");
String doiNameInRef = "InRef7";
List daiValList = sourceLn0.getDOIAdapterByName(doiNameInRef).getDataAdapterByName(SETSRCREF_DA_NAME).getCurrentElem().getVal();
String originalSetSrcCB = getDaiValue(sourceLn0, doiNameInRef, SETSRCCB_DA_NAME);
@@ -996,8 +993,7 @@ void updateDoInRef_should_update_setSrcRef_and_not_setSrcCB_when_one_ExtRef_desc
void updateDoInRef_should_update_setSrcRef_and_setSrcCB_when_one_ExtRef_desc_matches() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_test.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter sourceLn0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_WITH_1_InRef");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_WITH_1_InRef");
String doiNameInRef = "InRef2";
String originalSetSrcCB = getDaiValue(sourceLn0, doiNameInRef, SETSRCCB_DA_NAME);
String expectedSrcRef = "IED_NAME1LD_WITH_1_InRef/PRANCR1.Do11.sdo11";
@@ -1022,8 +1018,7 @@ void updateDoInRef_should_update_setSrcRef_and_setSrcCB_when_one_ExtRef_desc_mat
void updateDoInRef_should_update_setSrcRef_and_setSrcCB_and_setTstRef_and_setTstCB_when_ExtRef_desc_matches() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_test.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter sourceLn0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_WITH_3_InRef");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_WITH_3_InRef");
String doiNameInRef = "InRef3";
String originalSetSrcCB = getDaiValue(sourceLn0, doiNameInRef, SETSRCCB_DA_NAME);
String expectedSrcRef = "IED_NAME1LD_WITH_3_InRef/PRANCR1.Do11.sdo11";
@@ -1059,8 +1054,7 @@ void updateDoInRef_should_update_setSrcRef_and_setSrcCB_and_setTstRef_and_setTst
void updateDoInRef_should_not_update_setSrcRef_and_setSrcCB_and_setTstRef_and_setTstCB_when_ExtRef_desc_matches_and_dais_not_updatable() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-test-update-inref/scd_update_inref_test.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter sourceLn0 = findLn0(sclRootAdapter, "IED_NAME1", "LD_WITH_3_InRef");
+ LN0Adapter sourceLn0 = findLn0(scd, "IED_NAME1", "LD_WITH_3_InRef");
String doiNameInRef = "InRef3";
findDai(sourceLn0, "InRef3" + "." + SETSRCREF_DA_NAME).update(0L, "OLD_VAL");
findDai(sourceLn0, "InRef3" + "." + SETTSTREF_DA_NAME).update(0L, "OLD_VAL");
@@ -1085,7 +1079,7 @@ void updateDoInRef_should_not_update_setSrcRef_and_setSrcCB_and_setTstRef_and_se
assertThat(finalSetTstCB).isEqualTo(expectedVal);
assertThat(sclReportItems)
.hasSize(4)
- .extracting(SclReportItem::getMessage)
+ .extracting(SclReportItem::message)
.containsExactly("The DAI setSrcRef cannot be updated", "The DAI setSrcCB cannot be updated",
"The DAI setTstRef cannot be updated", "The DAI setTstCB cannot be updated");
}
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterTest.java
index 8025bca31..63851eb22 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterTest.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ied/LNAdapterTest.java
@@ -461,8 +461,7 @@ void updateDAI_should_throw_ScdException_when_DataAttributeRef_is_empty() {
// Given
DataAttributeRef dataAttributeRef = new DataAttributeRef();
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
- LN0Adapter lnAdapter = findLn0(sclRootAdapter, "IED_NAME", "LD_INS1");
+ LN0Adapter lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
// When Then
assertThatThrownBy(() -> lnAdapter.updateDAI(dataAttributeRef))
@@ -474,7 +473,7 @@ void updateDAI_should_throw_ScdException_when_DataAttributeRef_is_empty() {
void updateDAI_should_throw_ScdException_when_DataAttributeRef_DA_name_is_not_defined() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
DataAttributeRef dataAttributeRef = createDataAttributeRef(DO_TYPE_NAME, null);
// When Then
@@ -487,7 +486,7 @@ void updateDAI_should_throw_ScdException_when_DataAttributeRef_DA_name_is_not_de
void updateDAI_should_throw_ScdException_when_DataAttributeRef_DO_name_is_not_defined() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
DataAttributeRef dataAttributeRef = createDataAttributeRef(null, DA_TYPE_NAME);
// When Then
@@ -500,7 +499,7 @@ void updateDAI_should_throw_ScdException_when_DataAttributeRef_DO_name_is_not_de
void updateDAI_should_not_update_DAI_Val_when_DTT_Fc_not_allowed_to_update() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
DataAttributeRef dataAttributeRef = DataAttributeRef.copyFrom(RDDT_DO_SDO1_D_ANTREF_BDA1_BDA2_BDA3);
dataAttributeRef.setFc(TFCEnum.BL);
final String OLD_VALUE = "Completed-diff";
@@ -521,7 +520,7 @@ void updateDAI_should_not_update_DAI_Val_when_DTT_Fc_not_allowed_to_update() {
void updateDAI_should_update_DOI_SDI_DAI_that_exists_when_data_updatable() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
assertThat(RDDT_DO_SDO1_D_ANTREF_BDA1_BDA2_BDA3.isUpdatable()).isTrue();
// When
@@ -537,7 +536,7 @@ void updateDAI_should_update_DOI_SDI_DAI_that_exists_when_data_updatable() {
void updateDAI_should_update_DOI_DAI_that_exists_when_data_updatable() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
assertThat(DATA_ATTRIBUTE_REF_DO_DA2.isUpdatable()).isTrue();
// When
@@ -553,7 +552,7 @@ void updateDAI_should_update_DOI_DAI_that_exists_when_data_updatable() {
void updateDAI_should_create_DOI_SDI_DAI_elements_with_new_value_when_data_updatable() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS2");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS2");
assertThat(lnAdapter.getCurrentElem().getDOI()).isEmpty();
// When
@@ -569,7 +568,7 @@ void updateDAI_should_create_DOI_SDI_DAI_elements_with_new_value_when_data_updat
void updateDAI_should_create_DOI_DAI_elements_with_new_value_when_data_updatable() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS2");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS2");
DataAttributeRef dataAttributeRef = DATA_ATTRIBUTE_REF_DO_DA2;
assertThat(lnAdapter.getCurrentElem().getDOI()).isEmpty();
@@ -606,7 +605,7 @@ void updateDAI_should_not_update_DAI_values_when_not_updatable() {
void updateDAI_when_nothing_instantiated_should_create_DOI_and_DAI() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
lnAdapter.getCurrentElem().getDOI().clear();
assertThat(lnAdapter.getCurrentElem().getDOI()).isEmpty();
@@ -624,7 +623,7 @@ void updateDAI_when_nothing_instantiated_should_create_DOI_and_DAI() {
void updateDAI_when_only_DOI_instantiated_should_create_DOI() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
lnAdapter.getDOIAdapterByName(DATA_ATTRIBUTE_REF_DO_DA2.getDoRef()).getSDIOrDAI().clear();
assertThat(findDoiOrSdi(lnAdapter, DATA_ATTRIBUTE_REF_DO_DA2.getDoName().getName()).getSDIOrDAI()).isEmpty();
@@ -642,7 +641,7 @@ void updateDAI_when_only_DOI_instantiated_should_create_DOI() {
void updateDAI_when_already_instantiated_should_do_nothing() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
assertThat(findDai(lnAdapter, DATA_ATTRIBUTE_REF_DO_DA2.getDataAttributes())).isNotNull();
// When
@@ -659,7 +658,7 @@ void updateDAI_when_already_instantiated_should_do_nothing() {
void updateDAI_with_SDO_and_BDA_when_no_elements_instantiated_should_create_SDI_DAI() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
lnAdapter.getCurrentElem().getDOI().clear();
assertThat(lnAdapter.getCurrentElem().getDOI()).isEmpty();
@@ -677,7 +676,7 @@ void updateDAI_with_SDO_and_BDA_when_no_elements_instantiated_should_create_SDI_
void updateDAI_with_SDO_and_BDA_when_only_DOI_is_instantiated_should_create_DOI_SDI_DAI() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
lnAdapter.getDOIAdapterByName(DO_TYPE_NAME.getName()).getCurrentElem().getSDIOrDAI().clear();
assertThat(findDoiOrSdi(lnAdapter, DO_TYPE_NAME.getName()).getSDIOrDAI()).isEmpty();
@@ -696,7 +695,7 @@ void updateDAI_with_SDO_and_BDA_when_only_DOI_is_instantiated_should_create_DOI_
void updateDAI_with_SDO_and_BDA_when_some_SDI_instantiated_should_create_missing_SDI_DAI(int numberOfSdi) {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
String refOfExistingSDIs = String.join(".", Arrays.asList(DATA_TYPE_REF.split("\\.")).subList(0, numberOfSdi + 1));
findDoiOrSdi(lnAdapter, refOfExistingSDIs).getSDIOrDAI().clear();
assertThat(findDoiOrSdi(lnAdapter, refOfExistingSDIs).getSDIOrDAI()).isEmpty();
@@ -715,7 +714,7 @@ void updateDAI_with_SDO_and_BDA_when_some_SDI_instantiated_should_create_missing
void updateDAI_with_SDO_and_BDA_when_only_DAI_is_missing_should_create_DAI() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
AbstractDAIAdapter> daiToRemove = findDai(lnAdapter, DATA_TYPE_REF);
((IDataParentAdapter) daiToRemove.getParentAdapter()).getSDIOrDAI().clear();
assertThat(findDoiOrSdi(lnAdapter, DATA_TYPE_REF.substring(0, DATA_TYPE_REF.lastIndexOf("."))).getSDIOrDAI()).isEmpty();
@@ -734,7 +733,7 @@ void updateDAI_with_SDO_and_BDA_when_only_DAI_is_missing_should_create_DAI() {
void updateDAI_with_SDO_and_BDA_when_already_instantiated_should_do_nothing() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/ied-test-schema-conf/ied_unit_test.xml");
- AbstractLNAdapter> lnAdapter = findLn0(new SclRootAdapter(scd), "IED_NAME", "LD_INS1");
+ AbstractLNAdapter> lnAdapter = findLn0(scd, "IED_NAME", "LD_INS1");
assertThat(findDai(lnAdapter, DATA_TYPE_REF)).isNotNull();
// When
@@ -821,7 +820,7 @@ void getControlBlocks_should_find_ControlBlock_by_name() {
void getTControlsByType_should_return_list_of_report_control_blocks() {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
- LNAdapter lnAdapter = findLn(new SclRootAdapter(scd), "IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "LDSUIED", "LPAI", "1", null);
+ LNAdapter lnAdapter = findLn(scd, "IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "LDSUIED", "LPAI", "1", null);
// When
List tControlsByType = lnAdapter.getTControlsByType(TReportControl.class);
// Then
@@ -833,7 +832,7 @@ void getTControlsByType_should_return_list_of_report_control_blocks() {
void getTControlsByType_should_throw_when_unsupported_controlBlock_for_ln(Class extends TControl> tControlClass) {
// Given
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
- LNAdapter lnAdapter = findLn(new SclRootAdapter(scd), "IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "LDSUIED", "LPAI", "1", null);
+ LNAdapter lnAdapter = findLn(scd, "IED4d4fe1a8cda64cf88a5ee4176a1a0eef", "LDSUIED", "LPAI", "1", null);
// When & Then
assertThatThrownBy(() -> lnAdapter.getTControlsByType(tControlClass))
.isInstanceOf(IllegalArgumentException.class);
diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java
index a853792a8..239cce3e8 100644
--- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java
+++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/testhelpers/SclHelper.java
@@ -6,7 +6,6 @@
import org.assertj.core.api.Assertions;
import org.lfenergy.compas.scl2007b4.model.*;
-import org.lfenergy.compas.sct.commons.dto.SclReport;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.scl.ied.*;
import org.lfenergy.compas.sct.commons.util.ControlBlockEnum;
@@ -38,17 +37,17 @@ private SclHelper() {
public static final String IED_NAME_1 = "IED_NAME_1";
public static final String IED_NAME_2 = "IED_NAME_2";
- public static IEDAdapter findIed(SclRootAdapter sclRootAdapter, String iedName) {
- return sclRootAdapter.findIedAdapterByName(iedName)
+ public static IEDAdapter findIed(SCL scl, String iedName) {
+ return new SclRootAdapter(scl).findIedAdapterByName(iedName)
.orElseThrow(() -> new AssertionFailedError(String.format("IED.name=%s not found", iedName)));
}
- public static LDeviceAdapter findLDevice(SclRootAdapter sclRootAdapter, String iedName, String ldInst) {
- return findIed(sclRootAdapter, iedName).findLDeviceAdapterByLdInst(ldInst).orElseThrow(() -> new AssertionFailedError(String.format("LDevice.inst=%s not found in IED.name=%s", ldInst, iedName)));
+ public static LDeviceAdapter findLDevice(SCL scl, String iedName, String ldInst) {
+ return findIed(scl, iedName).findLDeviceAdapterByLdInst(ldInst).orElseThrow(() -> new AssertionFailedError(String.format("LDevice.inst=%s not found in IED.name=%s", ldInst, iedName)));
}
- public static InputsAdapter findInputs(SclRootAdapter sclRootAdapter, String iedName, String ldInst) {
- LDeviceAdapter lDevice = findLDevice(sclRootAdapter, iedName, ldInst);
+ public static InputsAdapter findInputs(SCL scl, String iedName, String ldInst) {
+ LDeviceAdapter lDevice = findLDevice(scl, iedName, ldInst);
if (!lDevice.hasLN0()) {
throw new AssertionFailedError(String.format("IED.name=%s, LDevice.inst=%s has no LN0 element", ldInst, iedName));
}
@@ -59,8 +58,8 @@ public static InputsAdapter findInputs(SclRootAdapter sclRootAdapter, String ied
return ln0Adapter.getInputsAdapter();
}
- public static TExtRef findExtRef(SclRootAdapter sclRootAdapter, String iedName, String ldInst, String extRefDesc) {
- return findInputs(sclRootAdapter, iedName, ldInst)
+ public static TExtRef findExtRef(SCL scl, String iedName, String ldInst, String extRefDesc) {
+ return findInputs(scl, iedName, ldInst)
.getCurrentElem()
.getExtRef()
.stream()
@@ -69,24 +68,16 @@ public static TExtRef findExtRef(SclRootAdapter sclRootAdapter, String iedName,
.orElseThrow(() -> new AssertionFailedError(String.format("ExtRef.des=%s not found in IED.name=%s,LDevice.inst=%s", extRefDesc, iedName, ldInst)));
}
- public static TExtRef findExtRef(SclReport sclReport, String iedName, String ldInst, String extRefDesc) {
- return findExtRef(sclReport.getSclRootAdapter(), iedName, ldInst, extRefDesc);
- }
-
- public static LDeviceAdapter findLDevice(SclReport sclReport, String iedName, String ldInst) {
- return findLDevice(sclReport.getSclRootAdapter(), iedName, ldInst);
- }
-
- public static LN0Adapter findLn0(SclRootAdapter sclRootAdapter, String iedName, String ldInst) {
- LDeviceAdapter lDevice = findLDevice(sclRootAdapter, iedName, ldInst);
+ public static LN0Adapter findLn0(SCL scl, String iedName, String ldInst) {
+ LDeviceAdapter lDevice = findLDevice(scl, iedName, ldInst);
if (!lDevice.hasLN0()) {
throw new AssertionFailedError(String.format("LN0 not found in IED.name=%s,LDevice.inst=%s", iedName, ldInst));
}
return lDevice.getLN0Adapter();
}
- public static LNAdapter findLn(SclRootAdapter sclRootAdapter, String iedName, String ldInst, String lnClass, String lnInst, String prefix) {
- LDeviceAdapter lDevice = findLDevice(sclRootAdapter, iedName, ldInst);
+ public static LNAdapter findLn(SCL scl, String iedName, String ldInst, String lnClass, String lnInst, String prefix) {
+ LDeviceAdapter lDevice = findLDevice(scl, iedName, ldInst);
if (!lDevice.getCurrentElem().isSetLN()) {
throw new AssertionFailedError(String.format("No LN found in IED.name=%s,LDevice.inst=%s", iedName, ldInst));
}
@@ -139,35 +130,31 @@ public static String getValue(TDAI tdai) {
}
- public static LDeviceAdapter findLDeviceByLdName(SclRootAdapter sclRootAdapter, String ldName) {
- return sclRootAdapter.streamIEDAdapters()
+ public static LDeviceAdapter findLDeviceByLdName(SCL scl, String ldName) {
+ return new SclRootAdapter(scl).streamIEDAdapters()
.flatMap(IEDAdapter::streamLDeviceAdapters)
.filter(lDeviceAdapter -> ldName.equals(lDeviceAdapter.getLdName()))
.findFirst()
.orElseThrow(() -> new AssertionFailedError("LDevice with ldName=%s not found in SCD".formatted(ldName)));
}
- public static DataSetAdapter findDataSet(SclRootAdapter sclRootAdapter, String iedName, String ldInst, String dataSetName) {
- LN0Adapter ln0 = findLn0(sclRootAdapter, iedName, ldInst);
+ public static DataSetAdapter findDataSet(SCL scl, String iedName, String ldInst, String dataSetName) {
+ LN0Adapter ln0 = findLn0(scl, iedName, ldInst);
return ln0.findDataSetByName(dataSetName)
.orElseThrow(() -> new AssertionFailedError(String.format("DataSet.name=%s not found in IED.name=%s,LDevice.inst=%s,LN0",
dataSetName, iedName, ldInst)));
}
- public static DataSetAdapter findDataSet(SclReport sclReport, String iedName, String ldInst, String dataSetName) {
- return findDataSet(sclReport.getSclRootAdapter(), iedName, ldInst, dataSetName);
- }
-
- public static ControlBlockAdapter findControlBlock(SclRootAdapter sclRootAdapter, String iedName, String ldInst, String cbName,
+ public static ControlBlockAdapter findControlBlock(SCL scl, String iedName, String ldInst, String cbName,
ControlBlockEnum controlBlockEnum) {
- LN0Adapter ln0 = findLn0(sclRootAdapter, iedName, ldInst);
+ LN0Adapter ln0 = findLn0(scl, iedName, ldInst);
return ln0.findControlBlock(cbName, controlBlockEnum)
.orElseThrow(() -> new AssertionFailedError(String.format("%s name=%s not found in IED.name=%s,LDevice.inst=%s,LN0",
controlBlockEnum.getControlBlockClass().getSimpleName(), cbName, iedName, ldInst)));
}
- public static T findControlBlock(SclRootAdapter sclRootAdapter, String iedName, String ldInst, String cbName, Class controlBlockClass) {
- LN0Adapter ln0 = findLn0(sclRootAdapter, iedName, ldInst);
+ public static T findControlBlock(SCL scl, String iedName, String ldInst, String cbName, Class controlBlockClass) {
+ LN0Adapter ln0 = findLn0(scl, iedName, ldInst);
return ln0.getTControlsByType(controlBlockClass).stream()
.filter(t -> cbName.equals(t.getName()))
.findFirst()
@@ -175,9 +162,9 @@ public static T findControlBlock(SclRootAdapter sclRootAdap
controlBlockClass.getSimpleName(), cbName, iedName, ldInst)));
}
- public static void assertControlBlockExists(SclReport sclReport, String iedName, String ldInst, String cbName,
+ public static void assertControlBlockExists(SCL scd, String iedName, String ldInst, String cbName,
String datSet, String id, ControlBlockEnum controlBlockEnum) {
- TControl controlBlock = findControlBlock(sclReport.getSclRootAdapter(), iedName, ldInst, cbName, controlBlockEnum.getControlBlockClass());
+ TControl controlBlock = findControlBlock(scd, iedName, ldInst, cbName, controlBlockEnum.getControlBlockClass());
assertThat(controlBlock.getDatSet()).isEqualTo(datSet);
assertThat(getControlBlockId(controlBlock)).isEqualTo(id);
}
@@ -195,28 +182,28 @@ private static String getControlBlockId(TControl tControl) {
throw new AssertionFailedError("Cannot get Id for ControlBlock of type " + tControl.getClass().getSimpleName());
}
- public static Stream streamAllDataSets(SclRootAdapter sclRootAdapter) {
- return streamAllLn0Adapters(sclRootAdapter)
+ public static Stream streamAllDataSets(SCL scl) {
+ return streamAllLn0Adapters(scl)
.map(ln0Adapter -> ln0Adapter.getCurrentElem().getDataSet())
.flatMap(List::stream);
}
- public static Stream streamAllControlBlocks(SclRootAdapter sclRootAdapter, Class controlBlockClass) {
- return streamAllLn0Adapters(sclRootAdapter)
+ public static Stream streamAllControlBlocks(SCL scl, Class controlBlockClass) {
+ return streamAllLn0Adapters(scl)
.map(ln0Adapter -> ln0Adapter.getTControlsByType(controlBlockClass))
.flatMap(List::stream);
}
- public static Stream streamAllLn0Adapters(SclRootAdapter sclRootAdapter) {
- return sclRootAdapter
+ public static Stream streamAllLn0Adapters(SCL scl) {
+ return new SclRootAdapter(scl)
.streamIEDAdapters()
.flatMap(IEDAdapter::streamLDeviceAdapters)
.filter(LDeviceAdapter::hasLN0)
.map(LDeviceAdapter::getLN0Adapter);
}
- public static Stream streamAllExtRef(SclRootAdapter sclRootAdapter) {
- return streamAllLn0Adapters(sclRootAdapter)
+ public static Stream streamAllExtRef(SCL scl) {
+ return streamAllLn0Adapters(scl)
.filter(AbstractLNAdapter::hasInputs)
.map(LN0Adapter::getInputsAdapter)
.map(InputsAdapter::getCurrentElem)