diff --git a/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java b/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java index 33ab8ce65..505349145 100644 --- a/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java +++ b/sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java @@ -32,7 +32,7 @@ class SclAutomationServiceIntegrationTest { private SclAutomationService sclAutomationService ; private static final SclEditor sclEditor = new SclService() ; private static final SubstationEditor substationEditor = new SubstationService(new VoltageLevelService()) ; - private static final ControlBlockEditor controlBlockEditor = new ControlBlockEditorService(new ControlService(), new LdeviceService()) ; + private static final ControlBlockEditor controlBlockEditor = new ControlBlockEditorService(new ControlService(), new LdeviceService(new LnService())); private HeaderDTO headerDTO; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesService.java index 3e6c643ab..723f16209 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesService.java @@ -149,6 +149,21 @@ public Optional findDoLinkedToDa(TDataTypeTemplates dtt, String lN )); } + @Override + public Stream getEnumValues(TDataTypeTemplates dataTypeTemplates, String lnType, DoLinkedToDaFilter doLinkedToDaFilter) { + return findDoLinkedToDa(dataTypeTemplates, lnType, doLinkedToDaFilter) + .map(DoLinkedToDa::dataAttribute) + .filter(dataAttribute -> TPredefinedBasicTypeEnum.ENUM.equals(dataAttribute.getBType())) + .map(DataAttribute::getType) + .flatMap(enumId -> + dataTypeTemplates.getEnumType().stream() + .filter(tEnumType -> tEnumType.getId().equals(enumId)) + .findFirst()) + .stream() + .flatMap(tEnumType -> tEnumType.getEnumVal().stream()) + .map(TEnumVal::getValue); + } + private Optional getDATypeByDaName(TDataTypeTemplates dtt, TDOType tdoType, String daName) { return sdoOrDAService.findDA(tdoType, tda -> tda.getName().equals(daName)) .flatMap(tda -> daTypeService.findDaType(dtt, tda.getType())); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java index e9ddd2e92..d8e914d37 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/ExtRefEditorService.java @@ -23,7 +23,10 @@ import org.lfenergy.compas.sct.commons.util.PrivateUtils; import org.lfenergy.compas.sct.commons.util.Utils; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Optional; import static org.apache.commons.lang3.StringUtils.*; import static org.lfenergy.compas.sct.commons.util.CommonConstants.*; @@ -51,7 +54,7 @@ public class ExtRefEditorService implements ExtRefEditor { * @param channel TChannel represent parameters * @return the IED sources matching the LDEPF parameters */ - private static List getIedSources(SclRootAdapter sclRootAdapter, TCompasBay compasBay, TChannel channel) { + private List getIedSources(SclRootAdapter sclRootAdapter, TCompasBay compasBay, TChannel channel) { return sclRootAdapter.streamIEDAdapters() .filter(iedAdapter -> (channel.getBayScope().equals(TCBScopeType.BAY_EXTERNAL) && iedAdapter.getPrivateCompasBay().stream().noneMatch(bay -> bay.getUUID().equals(compasBay.getUUID()))) @@ -140,8 +143,7 @@ private static boolean doesIcdHeaderMatchLDEPFChannel(IEDAdapter iedAdapter, TCh * @param channel TChannel * @return LDeviceAdapter object that matches the EPF channel */ - private static Optional getActiveSourceLDeviceByLDEPFChannel(IEDAdapter iedAdapter, TChannel channel) { - LdeviceService ldeviceService = new LdeviceService(); + private Optional getActiveSourceLDeviceByLDEPFChannel(IEDAdapter iedAdapter, TChannel channel) { return ldeviceService.findLdevice(iedAdapter.getCurrentElem(), tlDevice -> tlDevice.getInst().equals(channel.getLDInst())) .filter(tlDevice -> ldeviceService.getLdeviceStatus(tlDevice).map(ActiveStatus.ON::equals).orElse(false)) .map(tlDevice -> new LDeviceAdapter(iedAdapter, tlDevice)); @@ -271,7 +273,7 @@ public List manageBindingForLDEPF(SCL scd, EPF epf) { .findFirst().ifPresent(channel -> { List iedSources = getIedSources(sclRootAdapter, extRefBayRef.compasBay(), channel); if (iedSources.size() == 1) { - updateLDEPFExtRefBinding(extRefBayRef.extRef(), iedSources.get(0), channel); + updateLDEPFExtRefBinding(extRefBayRef.extRef(), iedSources.getFirst(), channel); LDeviceAdapter lDeviceAdapter = new LDeviceAdapter(new IEDAdapter(sclRootAdapter, tied.getName()), tlDevice); sclReportItems.addAll(updateLDEPFDos(lDeviceAdapter, extRefBayRef.extRef(), channel)); } else { diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LNodeStatusService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LNodeStatusService.java deleted file mode 100644 index af902ca3a..000000000 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LNodeStatusService.java +++ /dev/null @@ -1,103 +0,0 @@ -// SPDX-FileCopyrightText: 2024 RTE FRANCE -// -// SPDX-License-Identifier: Apache-2.0 - -package org.lfenergy.compas.sct.commons; - -import lombok.RequiredArgsConstructor; -import org.lfenergy.compas.scl2007b4.model.*; -import org.lfenergy.compas.sct.commons.domain.DataAttribute; -import org.lfenergy.compas.sct.commons.domain.DoLinkedToDa; -import org.lfenergy.compas.sct.commons.domain.DoLinkedToDaFilter; -import org.lfenergy.compas.sct.commons.dto.SclReportItem; -import org.lfenergy.compas.sct.commons.util.CommonConstants; -import org.lfenergy.compas.sct.commons.util.PrivateUtils; -import org.lfenergy.compas.sct.commons.util.SclConstructorHelper; - -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Stream; - -@RequiredArgsConstructor -public class LNodeStatusService { - - private static final String LNODE_STATUS_PRIVATE_TYPE = "COMPAS-LNodeStatus"; - private static final List LN_LNS_POSSIBLE_VALUES = List.of("off;on", "on;off", "on", "off"); - private static final List LNODE_LNS_POSSIBLE_VALUES = List.of("on", "off"); - private final LdeviceService ldeviceService; - private final LnService lnService; - private final DataTypeTemplatesService dataTypeTemplatesService; - - public List updateLnModStValBasedOnLNodeStatus(SCL scl) { - return scl.getSubstation().stream() - .flatMap(tSubstation -> tSubstation.getVoltageLevel().stream()) - .flatMap(tVoltageLevel -> tVoltageLevel.getBay().stream()) - .flatMap(tBay -> tBay.getFunction().stream()) - .flatMap(tFunction -> tFunction.getLNode().stream()) - .map(tlNode -> updateSingleLnModStValBasedOnLNodeStatus(scl, tlNode)) - .filter(Objects::nonNull) - .toList(); - } - - private SclReportItem updateSingleLnModStValBasedOnLNodeStatus(SCL scl, TLNode tlNode) { - String lNodeLNS = PrivateUtils.extractStringPrivate(tlNode, LNODE_STATUS_PRIVATE_TYPE).orElse(null); - if (lNodeLNS == null || !LNODE_LNS_POSSIBLE_VALUES.contains(lNodeLNS)) { - return SclReportItem.error(lNodePath(tlNode), "The private %s of the LNode has invalid value. Expecting one of [on, off] but got : %s".formatted(LNODE_STATUS_PRIVATE_TYPE, lNodeLNS)); - } - TAnyLN anyLn = findLn(scl, tlNode.getIedName(), tlNode.getLdInst(), tlNode.getLnClass().getFirst(), tlNode.getLnInst(), tlNode.getPrefix()).orElse(null); - if (anyLn == null) { - return SclReportItem.error(lNodePath(tlNode), "LNode in Substation section does not have a matching LN in IED section"); - } - String anyLnLNS = PrivateUtils.extractStringPrivate(anyLn, LNODE_STATUS_PRIVATE_TYPE).orElse(null); - if (anyLnLNS == null || !LN_LNS_POSSIBLE_VALUES.contains(anyLnLNS)) { - return SclReportItem.error(lnPath(tlNode), "The private %s of the LN has invalid value. Expecting one of %s but got : %s".formatted(LNODE_STATUS_PRIVATE_TYPE, LN_LNS_POSSIBLE_VALUES, anyLnLNS)); - - } - if (!anyLnLNS.contains(lNodeLNS)) { - return SclReportItem.error(lnPath(tlNode), "Cannot set DAI Mod.stVal to %s, because LN private %s is set to %s".formatted(lNodeLNS, LNODE_STATUS_PRIVATE_TYPE, anyLnLNS)); - } - TDAI daiModStVal = lnService.getDaiModStVal(anyLn).orElse(null); - if (daiModStVal == null) { - return null; // do nothing if DAI Mod.stVal is missing - } - List modStValEnumValues = getModStValEnumValues(scl.getDataTypeTemplates(), anyLn.getLnType()).toList(); - if (!modStValEnumValues.contains(lNodeLNS)) { - return SclReportItem.error(lnPath(tlNode), "Cannot set DAI Mod.stVal to '%s' because value is not in EnumType %s".formatted(lNodeLNS, modStValEnumValues)); - } - daiModStVal.getVal().clear(); - daiModStVal.getVal().add(SclConstructorHelper.newVal(lNodeLNS)); - return null; // no error - } - - private static String lnPath(TLNode tlNode) { - return "IED(%s)/LD(%s)/LN[%s,%s,%s]".formatted(tlNode.getIedName(), tlNode.getLdInst(), tlNode.getLnClass().getFirst(), tlNode.getLnInst(), tlNode.getPrefix()); - } - - private static String lNodePath(TLNode tlNode) { - return "LNode(iedName=%s, ldInst=%s, lnClass=%s, lnInst=%s, prefix=%s)".formatted(tlNode.getIedName(), tlNode.getLdInst(), tlNode.getLnClass().getFirst(), tlNode.getLnInst(), tlNode.getPrefix()); - } - - private Stream getModStValEnumValues(TDataTypeTemplates dataTypeTemplates, String lnType) { - return dataTypeTemplatesService.findDoLinkedToDa(dataTypeTemplates, lnType, DoLinkedToDaFilter.from(CommonConstants.MOD_DO_NAME, CommonConstants.STVAL_DA_NAME)) - .map(DoLinkedToDa::dataAttribute) - .filter(dataAttribute -> TPredefinedBasicTypeEnum.ENUM.equals(dataAttribute.getBType())) - .map(DataAttribute::getType) - .flatMap(enumId -> - dataTypeTemplates.getEnumType().stream() - .filter(tEnumType -> tEnumType.getId().equals(enumId)) - .findFirst()) - .stream() - .flatMap(tEnumType -> tEnumType.getEnumVal().stream()) - .map(TEnumVal::getValue); - } - - private Optional findLn(SCL scl, String iedName, String ldInst, String lnClass, String lnInst, String prefix) { - return scl.getIED().stream() - .filter(tied -> iedName.equals(tied.getName())) - .findFirst() - .flatMap(tied -> ldeviceService.findLdevice(tied, tlDevice -> ldInst.equals(tlDevice.getInst()))) - .flatMap(tlDevice -> lnService.findAnyLn(tlDevice, tAnyLN -> lnService.matchesLn(tAnyLN, lnClass, lnInst, prefix))); - - } -} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.java index f607b0d20..d2eefaf84 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LdeviceService.java @@ -4,7 +4,11 @@ package org.lfenergy.compas.sct.commons; -import org.lfenergy.compas.scl2007b4.model.*; +import lombok.RequiredArgsConstructor; +import org.lfenergy.compas.scl2007b4.model.TAccessPoint; +import org.lfenergy.compas.scl2007b4.model.TIED; +import org.lfenergy.compas.scl2007b4.model.TLDevice; +import org.lfenergy.compas.scl2007b4.model.TServer; import org.lfenergy.compas.sct.commons.util.ActiveStatus; import java.util.Objects; @@ -12,8 +16,11 @@ import java.util.function.Predicate; import java.util.stream.Stream; +@RequiredArgsConstructor public class LdeviceService { + private final LnService lnService; + public Stream getLdevices(TIED tied) { if (!tied.isSetAccessPoint()) { return Stream.empty(); @@ -40,7 +47,6 @@ public Optional findLdevice(TIED tied, Predicate ldevicePred } public Optional getLdeviceStatus(TLDevice tlDevice) { - LnService lnService = new LnService(); return lnService.getDaiModStValValue(tlDevice.getLN0()); } } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.java index 50d55c585..74aef2e46 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/LnService.java @@ -24,6 +24,8 @@ @Slf4j public class LnService implements LnEditor { + private static final DoLinkedToDaFilter DAI_FILTER_MOD_STVAL = DoLinkedToDaFilter.from(MOD_DO_NAME, STVAL_DA_NAME); + public Stream getAnylns(TLDevice tlDevice) { return Stream.concat(Stream.of(tlDevice.getLN0()), tlDevice.getLN().stream()); } @@ -73,15 +75,7 @@ public Optional getDaiModStValValue(TAnyLN tAnyLN) { } public Optional getDaiModStVal(TAnyLN tAnyLN) { - return tAnyLN - .getDOI() - .stream() - .filter(tdoi -> MOD_DO_NAME.equals(tdoi.getName())) - .flatMap(tdoi -> tdoi.getSDIOrDAI().stream()) - .filter(TDAI.class::isInstance) - .map(TDAI.class::cast) - .filter(tdai -> STVAL_DA_NAME.equals(tdai.getName())) - .findFirst(); + return getDOAndDAInstances(tAnyLN, DAI_FILTER_MOD_STVAL); } public Stream getActiveLns(TLDevice tlDevice) { diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java index 006075c87..a2aec92e2 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/SclService.java @@ -6,7 +6,6 @@ import lombok.NonNull; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.tuple.Pair; import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.api.SclEditor; import org.lfenergy.compas.sct.commons.dto.*; @@ -24,7 +23,6 @@ import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; -import org.lfenergy.compas.sct.commons.scl.sstation.SubstationAdapter; import org.lfenergy.compas.sct.commons.util.PrivateUtils; import org.lfenergy.compas.sct.commons.util.Utils; @@ -187,19 +185,6 @@ public void importSTDElementsInSCD(SCL scd, List stds) throws ScdException }); } - @Override - public List updateLDeviceStatus(SCL scd) { - SclRootAdapter sclRootAdapter = new SclRootAdapter(scd); - SubstationAdapter substationAdapter = sclRootAdapter.getSubstationAdapter(); - final List> iedNameLdInstList = substationAdapter.getIedAndLDeviceNamesForLN0FromLNode(); - return sclRootAdapter.streamIEDAdapters() - .flatMap(IEDAdapter::streamLDeviceAdapters) - .map(LDeviceAdapter::getLN0Adapter) - .map(ln0Adapter -> ln0Adapter.updateLDeviceStatus(iedNameLdInstList)) - .flatMap(Optional::stream) - .toList(); - } - @Override public List updateDoInRef(SCL scd) { SclRootAdapter sclRootAdapter = new SclRootAdapter(scd); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/DataTypeTemplateReader.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/DataTypeTemplateReader.java index 572391f71..c50434f1a 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/DataTypeTemplateReader.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/DataTypeTemplateReader.java @@ -21,4 +21,5 @@ public interface DataTypeTemplateReader { Optional findDoLinkedToDa(TDataTypeTemplates dtt, String lNodeTypeId, DoLinkedToDaFilter doLinkedToDaFilter); + Stream getEnumValues(TDataTypeTemplates dataTypeTemplates, String lnType, DoLinkedToDaFilter doLinkedToDaFilter); } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/LnEditor.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/LnEditor.java index 889433c17..84b9d6881 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/LnEditor.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/LnEditor.java @@ -8,11 +8,16 @@ import org.lfenergy.compas.scl2007b4.model.TDAI; import org.lfenergy.compas.sct.commons.domain.DoLinkedToDa; import org.lfenergy.compas.sct.commons.domain.DoLinkedToDaFilter; +import org.lfenergy.compas.sct.commons.util.ActiveStatus; import java.util.Optional; public interface LnEditor { + Optional getDaiModStValValue(TAnyLN tAnyLN); + + Optional getDaiModStVal(TAnyLN tAnyLN); + Optional getDOAndDAInstances(TAnyLN tAnyLN, DoLinkedToDaFilter doLinkedToDaFilter); void updateOrCreateDOAndDAInstances(TAnyLN tAnyLN, DoLinkedToDa doLinkedToDa); diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/SclEditor.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/SclEditor.java index 1040f0ea0..985b436f2 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/SclEditor.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/api/SclEditor.java @@ -6,7 +6,6 @@ import lombok.NonNull; import org.lfenergy.compas.scl2007b4.model.SCL; -import org.lfenergy.compas.scl2007b4.model.TLNode; import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.exception.ScdException; @@ -137,14 +136,6 @@ public interface SclEditor { */ void importSTDElementsInSCD(SCL scd, List stds) throws ScdException; - /** - * Activate used LDevice and Deactivate unused LDevice in {@link TLNode TLNode } - * - * @param scd SCL file for which LDevice should be activated or deactivated - * @return list of encountered errors - */ - List updateLDeviceStatus(SCL scd); - /** * Update DAIs of DO InRef in all LN0 of the SCD using matching ExtRef information. * diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DataObject.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DataObject.java index b18a06820..33a5e53e0 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DataObject.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DataObject.java @@ -4,7 +4,9 @@ package org.lfenergy.compas.sct.commons.domain; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.apache.commons.lang3.StringUtils; import org.lfenergy.compas.scl2007b4.model.TPredefinedCDCEnum; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaFilter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaFilter.java index dbbe8fc1a..04cdfd247 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaFilter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaFilter.java @@ -19,32 +19,33 @@ public DoLinkedToDaFilter(String doName, List sdoNames, String daName, L this.daName = StringUtils.isBlank(daName) ? null : daName; this.bdaNames = bdaNames == null ? Collections.emptyList() : List.copyOf(bdaNames); } - public DoLinkedToDaFilter(){ - this(null,null,null,null); - } public static DoLinkedToDaFilter from(String doNames, String daNames) { String doName = null; List sdoNames = null; String daName = null; List bdaNames = null; - if (StringUtils.isNotBlank(doNames)){ + if (StringUtils.isNotBlank(doNames)) { doName = doNames.split("\\.")[0]; sdoNames = Arrays.stream(doNames.split("\\.")).skip(1).toList(); } - if (StringUtils.isNotBlank(daNames)){ + if (StringUtils.isNotBlank(daNames)) { daName = daNames.split("\\.")[0]; bdaNames = Arrays.stream(daNames.split("\\.")).skip(1).toList(); } return new DoLinkedToDaFilter(doName, sdoNames, daName, bdaNames); } -public String getDoRef() { - return doName + (sdoNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", sdoNames())); -} + public String getDoRef() { + return doName + (sdoNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", sdoNames())); + } -public String getDaRef() { - return daName + (bdaNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", bdaNames())); -} + public String getDaRef() { + return daName + (bdaNames().isEmpty() ? StringUtils.EMPTY : "." + String.join(".", bdaNames())); + } + @Override + public String toString() { + return getDoRef() + "." + getDaRef(); + } } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java index 3912eb323..6d1823765 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/dto/LNodeDTO.java @@ -8,15 +8,18 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.lfenergy.compas.scl2007b4.model.*; +import org.lfenergy.compas.scl2007b4.model.SCL; +import org.lfenergy.compas.scl2007b4.model.TAnyLN; +import org.lfenergy.compas.scl2007b4.model.TExtRef; +import org.lfenergy.compas.scl2007b4.model.TLNodeType; import org.lfenergy.compas.sct.commons.DataSetService; import org.lfenergy.compas.sct.commons.ExtRefReaderService; import org.lfenergy.compas.sct.commons.LnodeTypeService; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter; import org.lfenergy.compas.sct.commons.scl.dtt.LNodeTypeAdapter; -import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; +import org.lfenergy.compas.sct.commons.scl.ln.AbstractLNAdapter; import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; import org.lfenergy.compas.sct.commons.scl.ln.LnId; import org.lfenergy.compas.sct.commons.util.Utils; diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivation.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivation.java deleted file mode 100644 index 284c3c863..000000000 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivation.java +++ /dev/null @@ -1,122 +0,0 @@ -// SPDX-FileCopyrightText: 2022 RTE FRANCE -// -// SPDX-License-Identifier: Apache-2.0 - -package org.lfenergy.compas.sct.commons.scl.ldevice; - -import lombok.Getter; -import lombok.Setter; -import org.apache.commons.lang3.tuple.Pair; -import org.lfenergy.compas.scl2007b4.model.TCompasLDeviceStatus; -import org.lfenergy.compas.sct.commons.util.ActiveStatus; - -import java.util.List; -import java.util.Set; - -/** - * Common class for all states that define if LDevice should be activated or not - * regardless of the CompasLDeviceStatus Private, Enum Values of DO 'Beh' and if it's referenced in Substation...LNode or not - */ -@Getter -@Setter -public class LDeviceActivation { - - private final List> iedNameLdInstList; - private boolean isUpdatable; - private String newVal; - private String errorMessage; - - public LDeviceActivation(List> iedNameLdInstList) { - this.iedNameLdInstList = iedNameLdInstList; - } - - /** - * checks whether LDevice status is authorized to be activated or Not - * @param iedName Ied name value which LDevice appear - * @param ldInst LDevice inst value - * @param compasLDeviceStatus Private value - * @param enumValues enum values - */ - public void checkLDeviceActivationStatus(String iedName, String ldInst, TCompasLDeviceStatus compasLDeviceStatus, Set enumValues) { - if (!enumValues.contains(ActiveStatus.ON.getValue()) && !enumValues.contains(ActiveStatus.OFF.getValue())) { - errorMessage = "The LDevice cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'."; - } - if (!enumValues.contains(ActiveStatus.ON.getValue()) && enumValues.contains(ActiveStatus.OFF.getValue())) { - if (isDeclaredInSubstation(iedName, ldInst)) { - errorMessage = "The LDevice cannot be set to 'on' but has been selected into SSD."; - } else { - isUpdatable = true; - newVal = ActiveStatus.OFF.getValue(); - } - } - if(compasLDeviceStatus.equals(TCompasLDeviceStatus.ACTIVE) || - compasLDeviceStatus.equals(TCompasLDeviceStatus.UNTESTED)){ - checkAuthorisationToActivateLDevice(iedName, ldInst, enumValues); - } - if(compasLDeviceStatus.equals(TCompasLDeviceStatus.INACTIVE)){ - checkAuthorisationToDeactivateLDevice(iedName, ldInst, enumValues); - } - } - - /** - * checks whether LDevice status is authorized to be activated when CompasLDeviceStatus Private is ACTIVE or UNTESTED - * @param iedName Ied name value which contains LDevice - * @param ldInst LDevice inst value - * @param enumValues enum values - */ - private void checkAuthorisationToActivateLDevice(String iedName, String ldInst, Set enumValues) { - if (!enumValues.contains(ActiveStatus.OFF.getValue()) && enumValues.contains(ActiveStatus.ON.getValue())) { - if (isDeclaredInSubstation(iedName, ldInst)) { - isUpdatable = true; - newVal = ActiveStatus.ON.getValue(); - } else { - errorMessage = "The LDevice cannot be set to 'off' but has not been selected into SSD."; - } - } - if (enumValues.contains(ActiveStatus.ON.getValue()) && enumValues.contains(ActiveStatus.OFF.getValue())) { - isUpdatable = true; - if (isDeclaredInSubstation(iedName, ldInst)) { - newVal = ActiveStatus.ON.getValue(); - } else { - newVal = ActiveStatus.OFF.getValue(); - } - } - - } - - /** - * checks whether LDevice Status is authorized to be deactivated when CompasLDeviceStatus Private is INACTIVE - * @param iedName Ied name value which contains LDevice - * @param ldInst LDevice inst value - * @param enumValues enum values - */ - private void checkAuthorisationToDeactivateLDevice(String iedName, String ldInst, Set enumValues) { - if (!enumValues.contains(ActiveStatus.OFF.getValue()) && enumValues.contains(ActiveStatus.ON.getValue())) { - if (isDeclaredInSubstation(iedName, ldInst)) { - errorMessage = "The LDevice is not qualified into STD but has been selected into SSD."; - } else { - errorMessage = "The LDevice cannot be set to 'off' but has not been selected into SSD."; - } - } - if (enumValues.contains(ActiveStatus.ON.getValue()) && enumValues.contains(ActiveStatus.OFF.getValue())) { - if (isDeclaredInSubstation(iedName, ldInst)) { - errorMessage = "The LDevice is not qualified into STD but has been selected into SSD."; - } else { - isUpdatable = true; - newVal = ActiveStatus.OFF.getValue(); - } - } - } - - /** - * checks whether a pair of IED name and LDevice inst are referenced in Substation...LNode list - * @param iedName Ied name value - * @param ldInst LDevice inst value - * @return Returns whether a pair of IED name and LDevice inst are referenced in Substation...LNode list - */ - private boolean isDeclaredInSubstation(String iedName, String ldInst){ - return iedNameLdInstList.contains(Pair.of(iedName, ldInst)); - } - - -} diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java index 09836f9cc..705a0fff1 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LN0Adapter.java @@ -5,18 +5,12 @@ package org.lfenergy.compas.sct.commons.scl.ln; -import org.apache.commons.lang3.tuple.Pair; import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.scl.ObjectReference; import org.lfenergy.compas.sct.commons.scl.ied.InputsAdapter; -import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceActivation; import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; -import org.lfenergy.compas.sct.commons.util.PrivateUtils; - import java.util.List; -import java.util.Optional; -import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -68,8 +62,6 @@ */ public class LN0Adapter extends AbstractLNAdapter { - public static final DoTypeName BEHAVIOUR_DO_TYPE_NAME = new DoTypeName(BEHAVIOUR_DO_NAME); - public static final DaTypeName BEHAVIOUR_DA_TYPE_NAME = getDaTypeNameForBeh(); private static final Pattern LDEFP_DIGITAL_CHANNEL_PATTERN = Pattern.compile("DYN_LDEPF_DIGITAL CHANNEL \\d+_\\d+_BOOLEAN"); /** @@ -169,58 +161,6 @@ public void removeAllControlBlocksAndDatasets() { currentElem.unsetSampledValueControl(); } - /** - * Verify and update LDevice status in parent Node - * - * @param iedNameLDeviceInstList pair of Ied name and LDevice inst attributes - * @return Set of Errors - */ - public Optional updateLDeviceStatus(List> iedNameLDeviceInstList) { - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLDeviceInstList); - final String iedName = getParentAdapter().getParentAdapter().getName(); - final String ldInst = getParentAdapter().getInst(); - DataAttributeRef daiBehFilter = new DataAttributeRef(this, BEHAVIOUR_DO_TYPE_NAME, BEHAVIOUR_DA_TYPE_NAME); - List daiBehList = getDAI(daiBehFilter, false); - if (daiBehList.isEmpty()) { - return Optional.of(buildFatalReportItem("The LDevice doesn't have a DO @name='Beh' OR its associated DA@fc='ST' AND DA@name='stVal'")); - } - Set enumValues = getEnumValues(daiBehList.getFirst().getDaName().getType()); - Optional optionalTCompasLDevice = PrivateUtils.extractCompasPrivate(getParentAdapter().getCurrentElem(), TCompasLDevice.class); - if (optionalTCompasLDevice.isEmpty()) { - return Optional.of(buildFatalReportItem("The LDevice doesn't have a Private compas:LDevice.")); - } - if (!optionalTCompasLDevice.get().isSetLDeviceStatus()) { - return Optional.of(buildFatalReportItem("The Private compas:LDevice doesn't have the attribute 'LDeviceStatus'")); - } - TCompasLDeviceStatus compasLDeviceStatus = optionalTCompasLDevice.get().getLDeviceStatus(); - Optional optionalModStVal = getDaiModStVal(); - if (optionalModStVal.isEmpty()) { - return Optional.of(buildFatalReportItem("The LDevice doesn't have a DO @name='Mod'")); - } - DataAttributeRef newDaModToSetInLN0 = optionalModStVal.get(); - String initialValue = newDaModToSetInLN0.findFirstValue().orElse(""); - lDeviceActivation.checkLDeviceActivationStatus(iedName, ldInst, compasLDeviceStatus, enumValues); - if (lDeviceActivation.isUpdatable()) { - if (!initialValue.equals(lDeviceActivation.getNewVal())) { - newDaModToSetInLN0.setVal(lDeviceActivation.getNewVal()); - updateDAI(newDaModToSetInLN0); - } - } else { - if (lDeviceActivation.getErrorMessage() != null) { - return Optional.of(buildFatalReportItem(lDeviceActivation.getErrorMessage())); - } - } - return Optional.empty(); - } - - private static DaTypeName getDaTypeNameForBeh() { - DaTypeName daTypeNameBeh = new DaTypeName(); - daTypeNameBeh.setName(STVAL_DA_NAME); - daTypeNameBeh.setBType(TPredefinedBasicTypeEnum.ENUM); - daTypeNameBeh.setFc(TFCEnum.ST); - return daTypeNameBeh; - } - /** * Update DAIs of DO InRef in all LN0 of the SCD using matching ExtRef information. * diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LnId.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LnId.java index af80a0eb3..d8aedebba 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LnId.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/ln/LnId.java @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2021 RTE FRANCE +// SPDX-FileCopyrightText: 2025 RTE FRANCE // // SPDX-License-Identifier: Apache-2.0 package org.lfenergy.compas.sct.commons.scl.ln; @@ -78,5 +78,4 @@ public static LnId from(TLNode tlNode) { } - } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapter.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapter.java index 02d9ce17c..1b68bc99f 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapter.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapter.java @@ -4,17 +4,13 @@ package org.lfenergy.compas.sct.commons.scl.sstation; -import org.apache.commons.lang3.tuple.Pair; -import org.lfenergy.compas.scl2007b4.model.TLLN0Enum; import org.lfenergy.compas.scl2007b4.model.TSubstation; import org.lfenergy.compas.sct.commons.exception.ScdException; import org.lfenergy.compas.sct.commons.scl.SclElementAdapter; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; import org.lfenergy.compas.sct.commons.util.Utils; -import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -119,18 +115,4 @@ public Stream streamVoltageLevelAdapters() { return currentElem.getVoltageLevel().stream().map(tVoltageLevel -> new VoltageLevelAdapter(this, tVoltageLevel)); } - /** - * Gets a pair of IedName and LDevice inst from Substation LNodes for LN0 type object - * @return a pair of Ied name and LDevice inst attributes - */ - public List> getIedAndLDeviceNamesForLN0FromLNode() { - return streamVoltageLevelAdapters() - .flatMap(VoltageLevelAdapter::streamBayAdapters) - .flatMap(BayAdapter::streamFunctionAdapters) - .flatMap(functionAdapter -> functionAdapter.getCurrentElem().getLNode().stream()) - .filter(tlNode -> tlNode.getLnClass().contains(TLLN0Enum.LLN_0.value())) - .map(tlNode -> Pair.of(tlNode.getIedName(), tlNode.getLdInst())) - .collect(Collectors.toList()); - } - } diff --git a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java index 8d9cbfde1..567d73f75 100644 --- a/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java +++ b/sct-commons/src/main/java/org/lfenergy/compas/sct/commons/util/PrivateUtils.java @@ -270,7 +270,7 @@ public static String stdCheckFormatExceptionMessage(TPrivate key) throws ScdExce public static Stream streamIcdHeaders(SCL scd) { return scd .getSubstation() - .get(0) + .getFirst() .getVoltageLevel() .stream() .map(TVoltageLevel::getBay).flatMap(Collection::stream) diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockEditorServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockEditorServiceTest.java index 768c1195e..316e8ed6d 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockEditorServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ControlBlockEditorServiceTest.java @@ -50,7 +50,7 @@ class ControlBlockEditorServiceTest { @BeforeEach void init() { - controlBlockEditorService = new ControlBlockEditorService(new ControlService(), new LdeviceService()); + controlBlockEditorService = new ControlBlockEditorService(new ControlService(), new LdeviceService(new LnService())); } @Test diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesServiceTest.java index 54b837884..32bb50f2d 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DataTypeTemplatesServiceTest.java @@ -4,6 +4,7 @@ package org.lfenergy.compas.sct.commons; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.domain.DataAttribute; @@ -23,12 +24,18 @@ class DataTypeTemplatesServiceTest { + private DataTypeTemplatesService dataTypeTemplatesService; + + @BeforeEach + void setUp() { + dataTypeTemplatesService = new DataTypeTemplatesService(); + } + @Test void isDoModAndDaStValExist_when_LNodeType_not_exist_should_return_false() { //Given TDataTypeTemplates dtt = new TDataTypeTemplates(); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); boolean result = dataTypeTemplatesService.isDoModAndDaStValExist(dtt, "lnodeTypeId"); //Then assertThat(result).isFalse(); @@ -43,7 +50,6 @@ void isDoModAndDaStValExist_when_Do_not_exist_should_return_false() { tlNodeType.setId("lnodeTypeId"); dtt.getLNodeType().add(tlNodeType); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); boolean result = dataTypeTemplatesService.isDoModAndDaStValExist(dtt, "lnodeTypeId"); //Then assertThat(result).isFalse(); @@ -61,7 +67,6 @@ void isDoModAndDaStValExist_when_DoType_not_exist_should_return_false() { tlNodeType.getDO().add(tdo); dtt.getLNodeType().add(tlNodeType); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); boolean result = dataTypeTemplatesService.isDoModAndDaStValExist(dtt, "lnodeTypeId"); //Then assertThat(result).isFalse(); @@ -83,7 +88,6 @@ void isDoModAndDaStValExist_when_Da_Mod_not_exist_should_return_false() { tdoType.setId("doTypeId"); dtt.getDOType().add(tdoType); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); boolean result = dataTypeTemplatesService.isDoModAndDaStValExist(dtt, "lnodeTypeId"); //Then assertThat(result).isFalse(); @@ -108,7 +112,6 @@ void isDoModAndDaStValExist_when_Da_stVal_not_found_should_return_false() { tdoType.getSDOOrDA().add(tda); dtt.getDOType().add(tdoType); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); boolean result = dataTypeTemplatesService.isDoModAndDaStValExist(dtt, "lnodeTypeId"); //Then assertThat(result).isFalse(); @@ -133,7 +136,6 @@ void isDoModAndDaStValExist_when_DO_Mod_And_DA_stVal_exist_return_true() { tdoType.getSDOOrDA().add(tda); dtt.getDOType().add(tdoType); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); boolean result = dataTypeTemplatesService.isDoModAndDaStValExist(dtt, "lnodeTypeId"); //Then assertThat(result).isTrue(); @@ -145,10 +147,9 @@ void getFilteredDoLinkedToDa_should_return_expected_items() { TDataTypeTemplates dtt = initDttFromFile("/dtt-test-schema-conf/scd_dtt_do_sdo_da_bda_test.xml"); String lNodeTypeId = "LNodeType0"; - DoLinkedToDaFilter doLinkedToDaFilter = new DoLinkedToDaFilter(); + DoLinkedToDaFilter doLinkedToDaFilter = new DoLinkedToDaFilter(null, null, null, null); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); List result = dataTypeTemplatesService.getFilteredDoLinkedToDa(dtt, lNodeTypeId, doLinkedToDaFilter).toList(); //Then assertThat(result).hasSize(9) @@ -189,7 +190,6 @@ void getFilteredDOAndDA_when_given_DoName_should_return_expected_dataReference() DoLinkedToDaFilter doLinkedToDaFilter = DoLinkedToDaFilter.from("SecondDoName", ""); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); List result = dataTypeTemplatesService.getFilteredDoLinkedToDa(dtt, lNodeTypeId, doLinkedToDaFilter).toList(); //Then assertThat(result).hasSize(1).extracting(doLinkedToDa1 -> doLinkedToDa1.dataObject().getDoName(), @@ -210,7 +210,6 @@ void getFilteredDOAndDA_when_given_DO_with_one_structName_should_return_expected DoLinkedToDaFilter doLinkedToDaFilter = DoLinkedToDaFilter.from("FirstDoName.sdoName1", ""); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); List result = dataTypeTemplatesService.getFilteredDoLinkedToDa(dtt, lNodeTypeId, doLinkedToDaFilter).toList(); //Then assertThat(result).hasSize(3).extracting(doLinkedToDa1 -> doLinkedToDa1.dataObject().getDoName(), @@ -232,7 +231,6 @@ void getFilteredDOAndDA_when_given_DO_with_many_structName_should_return_expecte DoLinkedToDaFilter doLinkedToDaFilter = DoLinkedToDaFilter.from("FirstDoName.sdoName1.sdoName21", ""); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); List result = dataTypeTemplatesService.getFilteredDoLinkedToDa(dtt, lNodeTypeId, doLinkedToDaFilter).toList(); //Then assertThat(result).hasSize(2).extracting(doLinkedToDa1 -> doLinkedToDa1.dataObject().getDoName(), @@ -254,7 +252,6 @@ void getFilteredDOAndDA_when_given_DO_and_DA_with_structNames_should_return_expe DoLinkedToDaFilter doLinkedToDaFilter = DoLinkedToDaFilter.from("FirstDoName.sdoName2", "structDaName1.structBdaName1.enumBdaName22"); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); List result = dataTypeTemplatesService.getFilteredDoLinkedToDa(dtt, lNodeTypeId, doLinkedToDaFilter).toList(); //Then assertThat(result).hasSize(1).extracting(doLinkedToDa1 -> doLinkedToDa1.dataObject().getDoName(), @@ -286,7 +283,6 @@ void findDoLinkedToDa_should_find_DO_SDO_DA_and_all_BDA() { DoLinkedToDa doLinkedToDa = new DoLinkedToDa(dataObject, dataAttribute); DoLinkedToDaFilter doLinkedToDaFilter = new DoLinkedToDaFilter("Do", List.of("sdo1", "d"), "antRef", List.of("bda1", "bda2", "bda3")); // When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); Optional result = dataTypeTemplatesService.findDoLinkedToDa(dtt, "LNO1", doLinkedToDaFilter); // Then assertThat(result).get().usingRecursiveComparison().isEqualTo(doLinkedToDa); @@ -308,7 +304,6 @@ void findDoLinkedToDa_should_find_DO_SDO_DA_and_partial_BDA_list() { dataAttribute.setType("EnumType1"); DoLinkedToDa doLinkedToDa = new DoLinkedToDa(dataObject, dataAttribute); // When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); Optional result = dataTypeTemplatesService.findDoLinkedToDa(dtt, "LN1", new DoLinkedToDaFilter("Do1", List.of("sdo1", "sdo2"), "da2", List.of("bda1", "bda2"))); // Then assertThat(result).get().usingRecursiveComparison().isEqualTo(doLinkedToDa); @@ -327,7 +322,6 @@ void findDoLinkedToDa_should_find_DO_DA() { dataAttribute.setFc(TFCEnum.ST); DoLinkedToDa doLinkedToDa = new DoLinkedToDa(dataObject, dataAttribute); // When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); Optional result = dataTypeTemplatesService.findDoLinkedToDa(dtt, "LN1", new DoLinkedToDaFilter("Do1", List.of(), "da1", List.of())); // Then assertThat(result).get().usingRecursiveComparison().isEqualTo(doLinkedToDa); @@ -338,7 +332,6 @@ void getAllDOAndDA_when_LNodeType_not_exist_should_return_empty_list() { //Given TDataTypeTemplates dtt = new TDataTypeTemplates(); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); //Then assertThat(result).isEmpty(); @@ -352,8 +345,7 @@ void getAllDOAndDA_when_DO_not_exist_should_return_empty_list() { tlNodeType.setId("lnodeTypeId"); dtt.getLNodeType().add(tlNodeType); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); - List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); + List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); //Then assertThat(result).isEmpty(); } @@ -370,8 +362,7 @@ void getAllDOAndDA_when_DoType_not_exist_should_return_empty_list() { tlNodeType.getDO().add(tdo); dtt.getLNodeType().add(tlNodeType); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); - List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); + List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); //Then assertThat(result).isEmpty(); } @@ -393,8 +384,7 @@ void getAllDOAndDA_when_DA_not_exist_should_return_empty_list() { dtt.getDOType().add(tdoType); scl.setDataTypeTemplates(dtt); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); - List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); + List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); //Then assertThat(result).isEmpty(); } @@ -419,8 +409,7 @@ void getAllDOAndDA_when_1DO_linked_to_1DA_should_return_expectedItems() { dtt.getDOType().add(tdoType); scl.setDataTypeTemplates(dtt); //When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); - List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); + List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); //Then assertThat(result).hasSize(1); assertThat(result.getFirst()) @@ -437,8 +426,7 @@ void getAllDOAndDA_should_return_all_dataReference() { // File contain all combinations that can be made TDataTypeTemplates dtt = initDttFromFile("/dtt-test-schema-conf/scd_dtt_do_sdo_da_bda_tests.xml"); // When - DataTypeTemplatesService dataTypeTemplatesService = new DataTypeTemplatesService(); - List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); + List result = dataTypeTemplatesService.getAllDoLinkedToDa(dtt).toList(); // Then assertThat(result).hasSize(34) .extracting(doLinkedToDa1 -> doLinkedToDa1.dataObject().getDoName(), @@ -538,4 +526,14 @@ void getAllDOAndDA_should_return_all_dataReference() { ); } + @Test + void getEnumValues_should_succeed() { + // Given + TDataTypeTemplates dtt = initDttFromFile("/dtt-test-schema-conf/scd_dtt_do_sdo_da_bda_tests.xml"); + // When + List enumValues = dataTypeTemplatesService.getEnumValues(dtt, "LN1", DoLinkedToDaFilter.from("Do11", "sampleDa11")).toList(); + // Then + assertThat(enumValues).containsExactly("REB", "RVB", "RVL", "RVB+L"); + } + } diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java index 0d5511d73..348418743 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java @@ -128,7 +128,8 @@ void getAllSDOLinkedToDa_should_return_all_dai() { DataObject dataObject = new DataObject(); dataObject.setDoName("firstDONAME"); DataAttribute dataAttribute = new DataAttribute(); - DoLinkedToDa doLinkedToDa = new DoLinkedToDa(dataObject, dataAttribute); // When + DoLinkedToDa doLinkedToDa = new DoLinkedToDa(dataObject, dataAttribute); + // When List list = doTypeService.getAllSDOLinkedToDa(dtt, tdoType, doLinkedToDa); // Then assertThat(list) diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java index bdb7547cc..96949fe3b 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefEditorServiceTest.java @@ -36,7 +36,7 @@ class ExtRefEditorServiceTest { @BeforeEach void init() { - extRefEditorService = new ExtRefEditorService(new IedService(), new LdeviceService(), new LnService(), new DataTypeTemplatesService()); + extRefEditorService = new ExtRefEditorService(new IedService(), new LdeviceService(new LnService()), new LnService(), new DataTypeTemplatesService()); } @Test diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LNodeStatusServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LNodeStatusServiceTest.java deleted file mode 100644 index 505431be5..000000000 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LNodeStatusServiceTest.java +++ /dev/null @@ -1,194 +0,0 @@ -// SPDX-FileCopyrightText: 2024 RTE FRANCE -// -// SPDX-License-Identifier: Apache-2.0 - -package org.lfenergy.compas.sct.commons; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.lfenergy.compas.scl2007b4.model.SCL; -import org.lfenergy.compas.scl2007b4.model.TAnyLN; -import org.lfenergy.compas.scl2007b4.model.TLN; -import org.lfenergy.compas.sct.commons.dto.SclReportItem; -import org.lfenergy.compas.sct.commons.testhelpers.SclHelper; -import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; - -import java.util.List; -import java.util.stream.Stream; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Named.named; -import static org.lfenergy.compas.sct.commons.testhelpers.SclHelper.*; - -class LNodeStatusServiceTest { - - private LNodeStatusService lNodeStatusService; - - @BeforeEach - void setUp() { - lNodeStatusService = new LNodeStatusService(new LdeviceService(), new LnService(), new DataTypeTemplatesService()); - } - - @ParameterizedTest - @MethodSource("provideUpdateModStVal") - void updateLnStatusBasedOnPrivateLNodeStatus_should_update_Mod_stVal(String ldInst, String lnClass, String lnInst, String expected) { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).isEmpty(); - assertThat(findDai(scl, "IED_NAME_1", ldInst, lnClass, lnInst, "", "Mod", "stVal")) - .map(SclHelper::getValue) - .hasValue(expected); - } - - public static Stream provideUpdateModStVal() { - return Stream.of( - // Tests on LN - Arguments.of(named("LN 'on;off' to set to 'on'", "LDEVICE_1"), "PDIS", "1", "on"), - Arguments.of(named("LN 'off;on' to set to 'on'", "LDEVICE_1"), "PDIS", "2", "on"), - Arguments.of(named("LN 'on' to set to 'on'", "LDEVICE_1"), "PDIS", "3", "on"), - Arguments.of(named("LN 'on;off' to set to 'off'", "LDEVICE_1"), "PDIS", "4", "off"), - Arguments.of(named("LN 'off;on' to set to 'off'", "LDEVICE_1"), "PDIS", "5", "off"), - Arguments.of(named("LN 'off' to set to 'off'", "LDEVICE_1"), "PDIS", "6", "off"), - // Tests on LN0 - Arguments.of(named("LN0 'on;off' to set to 'on'", "LDEVICE_1"), "LLN0", "", "on"), - Arguments.of(named("LN0 'off;on' to set to 'on'", "LDEVICE_2"), "LLN0", "", "on"), - Arguments.of(named("LN0 'on' to set to 'on'", "LDEVICE_3"), "LLN0", "", "on"), - Arguments.of(named("LN0 'on;off' to set to 'off'", "LDEVICE_4"), "LLN0", "", "off"), - Arguments.of(named("LN0 'off;on' to set to 'off'", "LDEVICE_5"), "LLN0", "", "off"), - Arguments.of(named("LN0 'off' to set to 'off'", "LDEVICE_6"), "LLN0", "", "off") - ); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_do_nothing_if_DAI_Mod_stVal_is_missing() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus_without_mod_stval.scd"); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).isEmpty(); - assertThat(getLDevices(scl.getIED().getFirst()) - .flatMap(tlDevice -> Stream.concat(Stream.of(tlDevice.getLN0()), tlDevice.getLN().stream()))) - .flatMap(TAnyLN::getDOI) - .isEmpty(); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LNode_should_return_error() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - scl.getSubstation().getFirst().getVoltageLevel().getFirst().getBay().getFirst().getFunction().getFirst().getLNode().getFirst() - .getPrivate().clear(); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).containsExactly( - SclReportItem.error("LNode(iedName=IED_NAME_1, ldInst=LDEVICE_1, lnClass=PDIS, lnInst=1, prefix=)", - "The private COMPAS-LNodeStatus of the LNode has invalid value. Expecting one of [on, off] but got : null") - ); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_when_invalid_compasLNodeStatus_value_in_LNode_should_return_error() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - scl.getSubstation().getFirst().getVoltageLevel().getFirst().getBay().getFirst().getFunction().getFirst().getLNode().getFirst() - .getPrivate().getFirst().getContent().set(0, "helloworld"); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).containsExactly( - SclReportItem.error("LNode(iedName=IED_NAME_1, ldInst=LDEVICE_1, lnClass=PDIS, lnInst=1, prefix=)", - "The private COMPAS-LNodeStatus of the LNode has invalid value. Expecting one of [on, off] but got : helloworld") - ); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_when_LNode_does_not_match_any_LN_should_return_error() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - ((TLN) findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "PDIS", "1", "")) - .setPrefix("helloworld"); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).containsExactly( - SclReportItem.error("LNode(iedName=IED_NAME_1, ldInst=LDEVICE_1, lnClass=PDIS, lnInst=1, prefix=)", - "LNode in Substation section does not have a matching LN in IED section") - ); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_when_no_compasLNodeStatus_in_LN_should_return_error() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "PDIS", "1", "") - .getPrivate().clear(); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).containsExactly( - SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_1)/LN[PDIS,1,]", - "The private COMPAS-LNodeStatus of the LN has invalid value. Expecting one of [off;on, on;off, on, off] but got : null") - ); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_on_in_LNode_but_off_in_LN_should_return_error() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "LLN0", "", "") - .getPrivate().getFirst().getContent().set(0, "off"); - findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "PDIS", "1", "") - .getPrivate().getFirst().getContent().set(0, "off"); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).containsExactlyInAnyOrder( - SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_1)/LN[LLN0,,]", - "Cannot set DAI Mod.stVal to on, because LN private COMPAS-LNodeStatus is set to off"), - SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_1)/LN[PDIS,1,]", - "Cannot set DAI Mod.stVal to on, because LN private COMPAS-LNodeStatus is set to off") - ); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_when_compasLNodeStatus_is_off_in_LNode_but_on_in_LN_should_return_error() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - findAnyLn(scl, "IED_NAME_1", "LDEVICE_4", "LLN0", "", "") - .getPrivate().getFirst().getContent().set(0, "on"); - findAnyLn(scl, "IED_NAME_1", "LDEVICE_1", "PDIS", "4", "") - .getPrivate().getFirst().getContent().set(0, "on"); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).containsExactlyInAnyOrder( - SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_4)/LN[LLN0,,]", - "Cannot set DAI Mod.stVal to off, because LN private COMPAS-LNodeStatus is set to on"), - SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_1)/LN[PDIS,4,]", - "Cannot set DAI Mod.stVal to off, because LN private COMPAS-LNodeStatus is set to on") - ); - } - - @Test - void updateLnStatusBasedOnPrivateLNodeStatus_when_Mod_stVal_enumType_does_not_contains_value_should_return_error() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scl-lnodestatus/lnodestatus.scd"); - scl.getDataTypeTemplates().getEnumType().getFirst().getEnumVal().removeIf(tEnumVal -> tEnumVal.getValue().equals("on")); - // When - List sclReportItems = lNodeStatusService.updateLnModStValBasedOnLNodeStatus(scl); - // Then - assertThat(sclReportItems).contains( - SclReportItem.error("IED(IED_NAME_1)/LD(LDEVICE_1)/LN[PDIS,1,]", - "Cannot set DAI Mod.stVal to 'on' because value is not in EnumType [off, test]") - ); - } - -} diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LdeviceServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LdeviceServiceTest.java index 445fcf09b..051f1ce84 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LdeviceServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LdeviceServiceTest.java @@ -5,6 +5,7 @@ package org.lfenergy.compas.sct.commons; import org.assertj.core.groups.Tuple; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.lfenergy.compas.scl2007b4.model.SCL; import org.lfenergy.compas.scl2007b4.model.TIED; @@ -19,16 +20,20 @@ class LdeviceServiceTest { + private LdeviceService ldeviceService; + + @BeforeEach + void setUp() { + ldeviceService = new LdeviceService(new LnService()); + } + @Test void getLdeviceStatus_should_return_status() { //Given SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); - TLDevice tlDevice = std.getIED().get(0).getAccessPoint().get(0).getServer().getLDevice().get(0); - LdeviceService ldeviceService = new LdeviceService(); - + TLDevice tlDevice = std.getIED().getFirst().getAccessPoint().getFirst().getServer().getLDevice().getFirst(); //When Optional ldeviceStatus = ldeviceService.getLdeviceStatus(tlDevice); - //Then assertThat(ldeviceStatus).contains(ActiveStatus.ON); } @@ -37,12 +42,9 @@ void getLdeviceStatus_should_return_status() { void getLdevices_should_return_ldevices() { //Given SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); - TIED tied = std.getIED().get(0); - LdeviceService ldeviceService = new LdeviceService(); - + TIED tied = std.getIED().getFirst(); //When List tlDevices = ldeviceService.getLdevices(tied).toList(); - //Then assertThat(tlDevices) .hasSize(2) @@ -55,12 +57,9 @@ void getLdevices_should_return_ldevices() { void getFilteredLdevices_should_return_ldevices() { //Given SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); - TIED tied = std.getIED().get(0); - LdeviceService ldeviceService = new LdeviceService(); - + TIED tied = std.getIED().getFirst(); //When List tlDevices = ldeviceService.getFilteredLdevices(tied, tlDevice -> "LDTM".equals(tlDevice.getInst())).toList(); - //Then assertThat(tlDevices) .hasSize(1) @@ -72,12 +71,9 @@ void getFilteredLdevices_should_return_ldevices() { void findLdevice_should_return_ldevice() { //Given SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); - TIED tied = std.getIED().get(0); - LdeviceService ldeviceService = new LdeviceService(); - + TIED tied = std.getIED().getFirst(); //When TLDevice ldevice = ldeviceService.findLdevice(tied, tlDevice -> "LDTM".equals(tlDevice.getInst())).orElseThrow(); - //Then assertThat(ldevice) .extracting(TLDevice::getInst, TLDevice::getLdName) @@ -88,12 +84,9 @@ void findLdevice_should_return_ldevice() { void getActiveLdevices_should_return_ldevices() { //Given SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); - TIED tied = std.getIED().get(0); - LdeviceService ldeviceService = new LdeviceService(); - + TIED tied = std.getIED().getFirst(); //When List tlDevices = ldeviceService.getActiveLdevices(tied).toList(); - //Then assertThat(tlDevices) .hasSize(1) @@ -101,4 +94,4 @@ void getActiveLdevices_should_return_ldevices() { .containsExactly(Tuple.tuple("LDSUIED", "VirtualSAMULDSUIED")); } -} \ No newline at end of file +} diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnServiceTest.java index 38260e960..2c7f4bc28 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnServiceTest.java @@ -515,7 +515,7 @@ private TAnyLN initDOAndDAInstances(LinkedList doInstances, TSDI lastSDI = createSDIByStructName(firstSDI, structInstances); if(structInstances.size() == 1){ TDAI dai = new TDAI(); - dai.setName(daInstances.get(daInstances.size() - 1)); + dai.setName(daInstances.getLast()); TVal tVal = new TVal(); tVal.setValue(daiVal); dai.getVal().add(tVal); @@ -525,7 +525,7 @@ private TAnyLN initDOAndDAInstances(LinkedList doInstances, } else if(structInstances.size() == 1){ TDAI dai = new TDAI(); - dai.setName(daInstances.get(daInstances.size() - 1)); + dai.setName(daInstances.getLast()); TVal tVal = new TVal(); tVal.setValue(daiVal); dai.getVal().add(tVal); @@ -552,7 +552,7 @@ private TDAI initDOAndDAInstances(TAnyLN tAnyLN, TSDI firstSDI = createSDIFromDOI(tdoi, structInstances.getFirst()); TSDI lastSDI = createSDIByStructName(firstSDI, structInstances); if(structInstances.size() == 1){ - dai.setName(daInstances.get(daInstances.size() - 1)); + dai.setName(daInstances.getLast()); TVal tVal = new TVal(); dai.getVal().add(tVal); lastSDI.getSDIOrDAI().add(dai); @@ -560,7 +560,7 @@ private TDAI initDOAndDAInstances(TAnyLN tAnyLN, } } else if(structInstances.size() == 1){ - dai.setName(daInstances.get(daInstances.size() - 1)); + dai.setName(daInstances.getLast()); TVal tVal = new TVal(); dai.getVal().add(tVal); tdoi.getSDIOrDAI().add(dai); diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java index dafaf271a..3f164531c 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/SclServiceTest.java @@ -9,9 +9,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.MethodSource; import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.dto.*; import org.lfenergy.compas.sct.commons.exception.ScdException; @@ -21,7 +19,6 @@ import org.lfenergy.compas.sct.commons.scl.ldevice.LDeviceAdapter; import org.lfenergy.compas.sct.commons.scl.ln.LN0Adapter; import org.lfenergy.compas.sct.commons.scl.ln.LNAdapter; -import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper; import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; import org.mockito.InjectMocks; import org.mockito.junit.jupiter.MockitoExtension; @@ -29,7 +26,6 @@ import java.util.List; import java.util.Optional; import java.util.UUID; -import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -46,60 +42,6 @@ class SclServiceTest { @InjectMocks SclService sclService; - private static Stream sclProviderMissingRequiredObjects() { - SCL scl1 = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_KO_MissingBeh.scd"); - SCL scl2 = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivate.scd"); - SCL scl3 = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivateAttribute.scd"); - SCL scl4 = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_KO_MissingMod.scd"); - Tuple[] scl1Errors = new Tuple[]{Tuple.tuple("The LDevice doesn't have a DO @name='Beh' OR its associated DA@fc='ST' AND DA@name='stVal'", - "/SCL/IED[@name=\"IedName1\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0")}; - Tuple[] scl2Errors = new Tuple[]{Tuple.tuple("The LDevice doesn't have a Private compas:LDevice.", - "/SCL/IED[@name=\"IedName1\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0")}; - Tuple[] scl3Errors = new Tuple[]{Tuple.tuple("The Private compas:LDevice doesn't have the attribute 'LDeviceStatus'", - "/SCL/IED[@name=\"IedName1\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0")}; - Tuple[] scl4Errors = new Tuple[]{Tuple.tuple("The LDevice doesn't have a DO @name='Mod'", - "/SCL/IED[@name=\"IedName1\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0")}; - return Stream.of( - Arguments.of("MissingDOBeh", scl1, scl1Errors), - Arguments.of("MissingLDevicePrivate", scl2, scl2Errors), - Arguments.of("MissingLDevicePrivateAttribute", scl3, scl3Errors), - Arguments.of("MissingDOMod", scl4, scl4Errors) - ); - } - - private static Stream sclProviderBasedLDeviceStatus() { - SCL scl1 = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_LD_STATUS_ACTIVE.scd"); - SCL scl2 = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_LD_STATUS_UNTESTED.scd"); - SCL scl3 = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test1_LD_STATUS_INACTIVE.scd"); - Tuple[] scl1Errors = new Tuple[]{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 cannot be set to 'on' but has been selected into SSD.", - "/SCL/IED[@name=\"IedName2\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0"), - Tuple.tuple("The LDevice cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'.", - "/SCL/IED[@name=\"IedName3\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0" - )}; - Tuple[] scl2Errors = new Tuple[]{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 cannot be set to 'on' but has been selected into SSD.", - "/SCL/IED[@name=\"IedName2\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0"), - Tuple.tuple("The LDevice cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'.", - "/SCL/IED[@name=\"IedName3\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0" - )}; - Tuple[] scl3Errors = new Tuple[]{Tuple.tuple("The LDevice is not qualified into STD but has been selected into SSD.", - "/SCL/IED[@name=\"IedName1\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0"), - Tuple.tuple("The LDevice cannot be set to 'on' but has been selected into SSD.", - "/SCL/IED[@name=\"IedName2\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0"), - Tuple.tuple("The LDevice cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'.", - "/SCL/IED[@name=\"IedName3\"]/AccessPoint/Server/LDevice[@inst=\"LDSUIED\"]/LN0" - )}; - return Stream.of( - Arguments.of("ACTIVE", scl1, scl1Errors), - Arguments.of("UNTESTED", scl2, scl2Errors), - Arguments.of("INACTIVE", scl3, scl3Errors) - ); - } - - @Test void addHistoryItem_should_add_history_elements() throws ScdException { //Given @@ -175,7 +117,6 @@ void addSubnetworks_whenNoCommunicationTagInIcd_should_not_add_subnetwork() { @Test void addSubnetworks_shouldNotUpdateScd_when_noCommunicationInSTDExist() { //Givens - SCL initial = SclTestMarshaller.getSCLFromFile("/scl_update_communication/scd_without_communication.xml"); SCL scd = SclTestMarshaller.getSCLFromFile("/scl_update_communication/scd_without_communication.xml"); SCL icd = SclTestMarshaller.getSCLFromFile("/scl_update_communication/std_without_communication.xml"); assertThat(scd.getCommunication()).isNull(); @@ -396,138 +337,6 @@ void importSTDElementsInSCD_whenNoSTDMatch_shouldThrowException() { .hasMessage("There is no STD file found corresponding to headerId = f8dbc8c1-2db7-4652-a9d6-0b414bdeccfa, headerVersion = 01.00.00, headerRevision = 01.00.00 and ICDSystemVersionUUID = IED4d4fe1a8cda64cf88a5ee4176a1a0eef"); } - @ParameterizedTest(name = "{0}") - @MethodSource("sclProviderMissingRequiredObjects") - void updateLDeviceStatus_whenMissingRequiredObject_shouldReturnReportWithError(String testCase, SCL scl, Tuple... errors) { - // Given - assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED")).isPresent(); - assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off"); - String before = MarshallerWrapper.marshall(scl); - // When - List sclReportItems = sclService.updateLDeviceStatus(scl); - // Then - String after = MarshallerWrapper.marshall(scl); - assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse(); - assertThat(sclReportItems) - .hasSize(1) - .extracting(SclReportItem::message, SclReportItem::xpath) - .containsExactly(errors); - assertThat(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue()).isEqualTo("off"); - assertThat(before).isEqualTo(after); - } - - @ParameterizedTest(name = "{0}") - @MethodSource("sclProviderBasedLDeviceStatus") - void updateLDeviceStatus_whenLDeviceStatusActiveOrUntestedOrInactive_shouldReturnReportWithError(String testCase, SCL scl, Tuple... errors) { - // Given - 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 - List sclReportItems = sclService.updateLDeviceStatus(scl); - // Then - String after = MarshallerWrapper.marshall(scl); - assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse(); - assertThat(sclReportItems) - .hasSize(3) - .extracting(SclReportItem::message, SclReportItem::xpath) - .containsExactly(errors); - 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_whenAllLDeviceInactive_shouldReturnReportWithError() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test2_LD_STATUS_INACTIVE.scd"); - 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 - List sclReportItems = sclService.updateLDeviceStatus(scl); - // Then - assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isFalse(); - assertThat(sclReportItems) - .hasSize(2) - .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")); - 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"); - } - - @Test - void updateLDeviceStatus_shouldReturnUpdatedFile() { - // Given - SCL givenScl = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_Template.scd"); - 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 - List sclReportItems = sclService.updateLDeviceStatus(givenScl); - // Then - 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 - void updateLDeviceStatus_when_DAI_Mod_DO_stVal_whateverIsUpdatableOrNot_shouldReturnUpdatedFile() { - // Given - SCL givenScl = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue_165_enhance_68_Test_Dai_Updatable.scd"); - assertThat(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED")) - .map(TVal::getValue) - .hasValue("off"); - assertThat(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED")) - .map(TVal::getValue) - .hasValue("on"); - assertThat(getLDeviceStatusValue(givenScl, "IedName3", "LDSUIED")) - .map(TVal::getValue) - .isNotPresent(); - assertThat(getLDeviceStatusValue(givenScl, "IedName4", "LDSUIED")) - .map(TVal::getValue) - .hasValue("on"); - assertThat(getLDeviceStatusValue(givenScl, "IedName5", "LDSUIED")) - .map(TVal::getValue) - .hasValue("on"); - // When - List sclReportItems = sclService.updateLDeviceStatus(givenScl); - // Then - assertThat(sclReportItems.stream().noneMatch(SclReportItem::isError)).isTrue(); - assertThat(getLDeviceStatusValue(givenScl, "IedName1", "LDSUIED")) - .map(TVal::getValue) - .hasValue("on"); - assertThat(getLDeviceStatusValue(givenScl, "IedName2", "LDSUIED")) - .map(TVal::getValue) - .hasValue("off"); - assertThat(getLDeviceStatusValue(givenScl, "IedName3", "LDSUIED")) - .map(TVal::getValue) - .hasValue("off"); - assertThat(getLDeviceStatusValue(givenScl, "IedName4", "LDSUIED")) - .map(TVal::getValue) - .hasValue("off"); - assertThat(getLDeviceStatusValue(givenScl, "IedName5", "LDSUIED")) - .map(TVal::getValue) - .hasValue("off"); - } - - private Optional getLDeviceStatusValue(SCL scl, String iedName, String ldInst) { - return getValFromDaiName(scl, iedName, ldInst, "Mod", "stVal"); - } - @ParameterizedTest(name = "{0}") @CsvSource({ "Test update setSrcRef Value,LD_WITH_1_InRef,InRef2,setSrcRef,IED_NAME1LD_WITH_1_InRef/PRANCR1.Do11.sdo11", diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaTest.java index 2691f0783..dc44cbad7 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/domain/DoLinkedToDaTest.java @@ -11,7 +11,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertAll; class DoLinkedToDaTest { diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java index 72f2c5dbc..be6d40995 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/dto/LNodeDTOTest.java @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.lfenergy.compas.scl2007b4.model.TExtRef; +import org.lfenergy.compas.scl2007b4.model.*; import org.lfenergy.compas.sct.commons.scl.dtt.DataTypeTemplateAdapter; import org.lfenergy.compas.sct.commons.scl.dtt.LNodeTypeAdapter; import org.lfenergy.compas.sct.commons.scl.ied.IEDAdapter; @@ -24,7 +24,7 @@ class LNodeDTOTest { @Test @Tag("issue-321") - void testConstructor(){ + void testConstructor() { // When LNodeDTO lNodeDTO = new LNodeDTO(); lNodeDTO.setNodeClass(DTO.HOLDER_LN_CLASS); @@ -33,14 +33,14 @@ void testConstructor(){ lNodeDTO.setNodeType(DTO.LN_TYPE); // Then assertAll("LNODE", - ()-> assertThat(lNodeDTO.getGooseControlBlocks()).isEmpty(), - ()-> assertThat(lNodeDTO.getDataAttributeRefs()).isEmpty(), - ()-> assertThat(lNodeDTO.getDatSets()).isEmpty(), - ()-> assertThat(lNodeDTO.getExtRefs()).isEmpty(), - ()-> assertThat(lNodeDTO.getInst()).isEqualTo(DTO.HOLDER_LN_INST), - ()-> assertThat(lNodeDTO.getNodeClass()).isEqualTo(DTO.HOLDER_LN_CLASS), - ()-> assertThat(lNodeDTO.getNodeType()).isEqualTo(DTO.LN_TYPE), - ()-> assertThat(lNodeDTO.getPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX) + () -> assertThat(lNodeDTO.getGooseControlBlocks()).isEmpty(), + () -> assertThat(lNodeDTO.getDataAttributeRefs()).isEmpty(), + () -> assertThat(lNodeDTO.getDatSets()).isEmpty(), + () -> assertThat(lNodeDTO.getExtRefs()).isEmpty(), + () -> assertThat(lNodeDTO.getInst()).isEqualTo(DTO.HOLDER_LN_INST), + () -> assertThat(lNodeDTO.getNodeClass()).isEqualTo(DTO.HOLDER_LN_CLASS), + () -> assertThat(lNodeDTO.getNodeType()).isEqualTo(DTO.LN_TYPE), + () -> assertThat(lNodeDTO.getPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX) ); // When lNodeDTO.addDataAttributeRef(DataAttributeRef.builder().daName(new DaTypeName("da1")).build()); @@ -67,7 +67,7 @@ void testConstructor(){ } @Test - void from_whenCalledWithLNAdapter_shouldFillValues(){ + void from_whenCalledWithLNAdapter_shouldFillValues() { // When IEDAdapter iedAdapter = mock(IEDAdapter.class); LDeviceAdapter lDeviceAdapter = mock(LDeviceAdapter.class); @@ -93,14 +93,14 @@ void from_whenCalledWithLNAdapter_shouldFillValues(){ // When LNodeDTO lNodeDTO = LNodeDTO.from(lnAdapter, - new LogicalNodeOptions(true,true,false,false)); + new LogicalNodeOptions(true, true, false, false)); // Then assertThat(lNodeDTO).isNotNull(); assertAll("LNODE", - ()-> assertThat(lNodeDTO.getInst()).isEqualTo(DTO.HOLDER_LN_INST), - ()-> assertThat(lNodeDTO.getNodeClass()).isEqualTo(DTO.HOLDER_LN_CLASS), - ()-> assertThat(lNodeDTO.getNodeType()).isEqualTo(DTO.LN_TYPE), - ()-> assertThat(lNodeDTO.getPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX), + () -> assertThat(lNodeDTO.getInst()).isEqualTo(DTO.HOLDER_LN_INST), + () -> assertThat(lNodeDTO.getNodeClass()).isEqualTo(DTO.HOLDER_LN_CLASS), + () -> assertThat(lNodeDTO.getNodeType()).isEqualTo(DTO.LN_TYPE), + () -> assertThat(lNodeDTO.getPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX), () -> assertThat(lNodeDTO.getExtRefs()).hasSize(1) ); ExtRefInfo extRefInfo = lNodeDTO.getExtRefs().iterator().next(); @@ -112,7 +112,64 @@ void from_whenCalledWithLNAdapter_shouldFillValues(){ } @Test - void extractExtRefInfo_whenCalledWithLNAdapter_shouldFillValues(){ + void from_whenCalledWithTAnyLn_shouldFillValues() { + // When + TExtRef extRef = DTO.createExtRef(); + TLN tAnyLN = new TLN(); + tAnyLN.getLnClass().add(DTO.HOLDER_LN_CLASS); + tAnyLN.setInst(DTO.HOLDER_LN_INST); + tAnyLN.setPrefix(DTO.HOLDER_LN_PREFIX); + tAnyLN.setLnType(DTO.LN_TYPE); + tAnyLN.setInputs(new TInputs()); + tAnyLN.getInputs().getExtRef().add(extRef); + + SCL scl = new SCL(); + scl.setHeader(new THeader()); + TDataTypeTemplates dataTypeTemplates = new TDataTypeTemplates(); + TLNodeType tlNodeType = new TLNodeType(); + tlNodeType.setId(DTO.LN_TYPE); + TDO tdo = new TDO(); + tdo.setName("Do1"); + tdo.setType("DO1"); + tlNodeType.getDO().add(tdo); + TDOType tdoType = new TDOType(); + tdoType.setId("DO1"); + TDA tda = new TDA(); + tda.setName("Da1"); + tda.setBType(TPredefinedBasicTypeEnum.BOOLEAN); + tdoType.getSDOOrDA().add(tda); + dataTypeTemplates.getDOType().add(tdoType); + dataTypeTemplates.getLNodeType().add(tlNodeType); + scl.setDataTypeTemplates(dataTypeTemplates); + + // When + LNodeDTO lNodeDTO = LNodeDTO.from(tAnyLN, new LogicalNodeOptions(true, true, false, true), DTO.HOLDER_IED_NAME, DTO.HOLDER_LD_INST, scl); + // Then + assertThat(lNodeDTO).isNotNull(); + assertAll("LNODE", + () -> assertThat(lNodeDTO.getInst()).isEqualTo(DTO.HOLDER_LN_INST), + () -> assertThat(lNodeDTO.getNodeClass()).isEqualTo(DTO.HOLDER_LN_CLASS), + () -> assertThat(lNodeDTO.getNodeType()).isEqualTo(DTO.LN_TYPE), + () -> assertThat(lNodeDTO.getPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX), + () -> assertThat(lNodeDTO.getExtRefs()).hasSize(1), + () -> assertThat(lNodeDTO.getDataAttributeRefs()).hasSize(1) + ); + ExtRefInfo extRefInfo = lNodeDTO.getExtRefs().iterator().next(); + assertThat(extRefInfo.getHolderIEDName()).isEqualTo(DTO.HOLDER_IED_NAME); + assertThat(extRefInfo.getHolderLDInst()).isEqualTo(DTO.HOLDER_LD_INST); + assertThat(extRefInfo.getHolderLnClass()).isEqualTo(DTO.HOLDER_LN_CLASS); + assertThat(extRefInfo.getHolderLnInst()).isEqualTo(DTO.HOLDER_LN_INST); + assertThat(extRefInfo.getHolderLnPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX); + + DaTypeName daTypeName = new DaTypeName("Da1"); + daTypeName.setBType(TPredefinedBasicTypeEnum.BOOLEAN); + DoTypeName doTypeName = new DoTypeName("Do1"); + assertThat(lNodeDTO.getDataAttributeRefs().iterator().next()) + .isEqualTo(DataAttributeRef.builder().lnType(DTO.LN_TYPE).lnClass(DTO.HOLDER_LN_CLASS).lnInst(DTO.HOLDER_LN_INST).prefix(DTO.HOLDER_LN_PREFIX).daName(daTypeName).doName(doTypeName).build()); + } + + @Test + void extractExtRefInfo_whenCalledWithLNAdapter_shouldFillValues() { // Given LNAdapter lnAdapter = mock(LNAdapter.class); when(lnAdapter.getLNClass()).thenReturn(DTO.HOLDER_LN_CLASS); @@ -128,10 +185,10 @@ void extractExtRefInfo_whenCalledWithLNAdapter_shouldFillValues(){ // Then assertThat(lNodeDTO).isNotNull(); assertAll("LNODE", - ()-> assertThat(lNodeDTO.getInst()).isEqualTo(DTO.HOLDER_LN_INST), - ()-> assertThat(lNodeDTO.getNodeClass()).isEqualTo(DTO.HOLDER_LN_CLASS), - ()-> assertThat(lNodeDTO.getNodeType()).isEqualTo(DTO.LN_TYPE), - ()-> assertThat(lNodeDTO.getPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX), + () -> assertThat(lNodeDTO.getInst()).isEqualTo(DTO.HOLDER_LN_INST), + () -> assertThat(lNodeDTO.getNodeClass()).isEqualTo(DTO.HOLDER_LN_CLASS), + () -> assertThat(lNodeDTO.getNodeType()).isEqualTo(DTO.LN_TYPE), + () -> assertThat(lNodeDTO.getPrefix()).isEqualTo(DTO.HOLDER_LN_PREFIX), () -> assertThat(lNodeDTO.getExtRefs()).hasSize(1) ); } diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivationTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivationTest.java deleted file mode 100644 index 8858ed3ac..000000000 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ldevice/LDeviceActivationTest.java +++ /dev/null @@ -1,199 +0,0 @@ -// SPDX-FileCopyrightText: 2022 RTE FRANCE -// -// SPDX-License-Identifier: Apache-2.0 - -package org.lfenergy.compas.sct.commons.scl.ldevice; - -import org.apache.commons.lang3.tuple.Pair; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.CsvSource; -import org.junit.jupiter.params.provider.ValueSource; -import org.lfenergy.compas.scl2007b4.model.TCompasLDeviceStatus; - -import java.util.List; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; - -class LDeviceActivationTest { - - @ParameterizedTest - @ValueSource(strings = {"ACTIVE", "UNTESTED"}) - void checkLDeviceActivationStatus_shouldReturnNoError_when_LDeviceStatusACTIVE_Or_UNTESTED_And_Contains_ON_And_LDeviceReferencedINLNode(String lDeviceStatus) { - // Given - List> iedNameLdInstList = List.of(Pair.of("iedName1", "ldInst1")); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("on"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.fromValue(lDeviceStatus), Set.of("on")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isTrue(); - assertThat(lDeviceActivation.getErrorMessage()).isNull(); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("on"); - } - - @ParameterizedTest - @ValueSource(strings = {"ACTIVE", "UNTESTED"}) - void checkLDeviceActivationStatus_shouldReturnError_when_LDeviceStatusACTIVE_Or_UNTESTED_And_Contains_ON_And_NotLDeviceReferencedINLNode(String lDeviceStatus) { - // Given - List> iedNameLdInstList = List.of(); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("on"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst2", TCompasLDeviceStatus.valueOf(lDeviceStatus), Set.of("on")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isFalse(); - assertThat(lDeviceActivation.getErrorMessage()).isEqualTo("The LDevice cannot be set to 'off' but has not been selected into SSD."); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("on"); - } - - @ParameterizedTest - @ValueSource(strings = {"ACTIVE", "UNTESTED"}) - void checkLDeviceActivationStatus_shouldReturnError_when_LDeviceStatusACTIVE_Or_UNTESTED_And_Contains_OFF_And_LDeviceReferencedINLNode(String lDeviceStatus) { - // Given - List> iedNameLdInstList = List.of(Pair.of("iedName1", "ldInst1")); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("off"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.valueOf(lDeviceStatus), Set.of("off")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isFalse(); - assertThat(lDeviceActivation.getErrorMessage()).isEqualTo( - "The LDevice cannot be set to 'on' but has been selected into SSD."); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("off"); - } - - @ParameterizedTest - @ValueSource(strings = {"ACTIVE", "UNTESTED"}) - void checkLDeviceActivationStatus_shouldReturnNoError_when_LDeviceStatusACTIVE_Or_UNTESTED_And_Contains_OFF_And_NotLDeviceReferencedINLNode(String lDeviceStatus) { - // Given - List> iedNameLdInstList = List.of(); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("on"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.valueOf(lDeviceStatus), Set.of("off")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isTrue(); - assertThat(lDeviceActivation.getErrorMessage()).isNull(); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("off"); - } - - @ParameterizedTest - @ValueSource(strings = {"ACTIVE", "UNTESTED"}) - void checkLDeviceActivationStatus_shouldReturnNoError_when_LDeviceStatusACTIVE_Or_UNTESTED_And_Contains_ON_And_OFF_And_LDeviceReferencedINLNode(String lDeviceStatus) { - // Given - List> iedNameLdInstList = List.of(Pair.of("iedName1", "ldInst1")); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("off"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.valueOf(lDeviceStatus), Set.of("on", "off")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isTrue(); - assertThat(lDeviceActivation.getErrorMessage()).isNull(); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("on"); - } - - @ParameterizedTest - @ValueSource(strings = {"ACTIVE", "UNTESTED"}) - void checkLDeviceActivationStatus_shouldReturnNoError_when_LDeviceStatusACTIVE_Or_UNTESTED_And_Contains_ON_And_OFF_And_NotLDeviceReferencedINLNode(String lDeviceStatus) { - // Given - List> iedNameLdInstList = List.of(); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("off"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst2", TCompasLDeviceStatus.valueOf(lDeviceStatus), Set.of("on", "off")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isTrue(); - assertThat(lDeviceActivation.getErrorMessage()).isNull(); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("off"); - } - - @ParameterizedTest - @CsvSource(value = {"ACTIVE; iedName1; ldInst1","INACTIVE; iedName1; ldInst1", "UNTESTED; iedName1; ldInst1", "ACTIVE;;","INACTIVE;;", "UNTESTED;;"}, delimiter = ';') - void checkLDeviceActivationStatus_shouldReturnError_when_Contains_Not_ON_Nor_OFF(String lDeviceStatus, String iedName, String ldInst) { - // Given - List> iedNameLdInstList = List.of(Pair.of(iedName, ldInst)); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("off"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.valueOf(lDeviceStatus), Set.of()); - // Then - assertThat(lDeviceActivation.isUpdatable()).isFalse(); - assertThat(lDeviceActivation.getErrorMessage()).isEqualTo( - "The LDevice cannot be activated or desactivated because its BehaviourKind Enum contains NOT 'on' AND NOT 'off'."); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("off"); - } - - @Test - void checkLDeviceActivationStatus_shouldReturnError_when_LDeviceStatusINACTIVE_And_Contains_ON_And_LDeviceReferencedINLNode() { - // Given - List> iedNameLdInstList = List.of(Pair.of("iedName1", "ldInst1")); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("on"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.INACTIVE, Set.of("on")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isFalse(); - assertThat(lDeviceActivation.getErrorMessage()).isEqualTo("The LDevice is not qualified into STD but has been selected into SSD."); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("on"); - } - - @Test - void checkLDeviceActivationStatus_shouldReturnNoError_when_LDeviceStatusINACTIVE_And_Contains_ON_And_OFF_And_NotLDeviceReferencedINLNode() { - // Given - List> iedNameLdInstList = List.of(); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("on"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.INACTIVE, Set.of("on", "off")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isTrue(); - assertThat(lDeviceActivation.getErrorMessage()).isNull(); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("off"); - } - - @Test - void checkLDeviceActivationStatus_shouldReturnError_when_LDeviceStatusINACTIVE_And_Contains_ON_And_NotLDeviceReferencedINLNode() { - // Given - List> iedNameLdInstList = List.of(); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("on"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.INACTIVE, Set.of("on")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isFalse(); - assertThat(lDeviceActivation.getErrorMessage()).isEqualTo("The LDevice cannot be set to 'off' but has not been selected into SSD."); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("on"); - } - - @Test - void checkLDeviceActivationStatus_shouldReturnNoError_when_LDeviceStatusINACTIVE_And_Contains_OFF_And_NotLDeviceReferencedINLNode() { - // Given - List> iedNameLdInstList = List.of(); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("on"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.INACTIVE, Set.of("off")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isTrue(); - assertThat(lDeviceActivation.getErrorMessage()).isNull(); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("off"); - } - - @Test - void checkLDeviceActivationStatus_shouldReturnError_when_LDeviceStatusINACTIVE_And_Contains_ON_And_OFF_And_LDeviceReferencedINLNode() { - // Given - List> iedNameLdInstList = List.of(Pair.of("iedName1", "ldInst1")); - LDeviceActivation lDeviceActivation = new LDeviceActivation(iedNameLdInstList); - lDeviceActivation.setNewVal("off"); - // When - lDeviceActivation.checkLDeviceActivationStatus("iedName1", "ldInst1", TCompasLDeviceStatus.INACTIVE, Set.of("on", "off")); - // Then - assertThat(lDeviceActivation.isUpdatable()).isFalse(); - assertThat(lDeviceActivation.getErrorMessage()).isEqualTo( - "The LDevice is not qualified into STD but has been selected into SSD."); - assertThat(lDeviceActivation.getNewVal()).isEqualTo("off"); - } - -} \ No newline at end of file diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LnIdTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LnIdTest.java index bdbff7a3b..d8e17e15f 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LnIdTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/ln/LnIdTest.java @@ -5,44 +5,65 @@ package org.lfenergy.compas.sct.commons.scl.ln; -import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Test; -import org.lfenergy.compas.scl2007b4.model.LN0; -import org.lfenergy.compas.scl2007b4.model.TLLN0Enum; -import org.lfenergy.compas.scl2007b4.model.TLN; -import org.lfenergy.compas.scl2007b4.model.TSystemLNGroupEnum; +import org.lfenergy.compas.scl2007b4.model.*; import static org.assertj.core.api.Assertions.assertThat; class LnIdTest { @Test - void test_LnKey_withLN() { + void from_LN_should_succeed() { //Given TLN ln = new TLN(); - ln.setLnType("LnTypeAny"); ln.setInst("1"); ln.getLnClass().add(TSystemLNGroupEnum.LGOS.value()); + ln.setPrefix("Prefix"); // When LnId lnId = LnId.from(ln); // Then assertThat(lnId.lnClass()).isEqualTo("LGOS"); assertThat(lnId.lnInst()).isEqualTo("1"); - assertThat(lnId.prefix()).isEqualTo(StringUtils.EMPTY); + assertThat(lnId.prefix()).isEqualTo("Prefix"); } @Test - void test_LnKey_withLN0() { + void from_LN0_should_succeed() { //Given LN0 ln0 = new LN0(); - ln0.setLnType("LnType0"); ln0.getLnClass().add(TLLN0Enum.LLN_0.value()); // When LnId lnId = LnId.from(ln0); // Then - assertThat(lnId.lnClass()).isEqualTo("LLN0"); - assertThat(lnId.lnInst()).isEqualTo(""); - assertThat(lnId.prefix()).isEqualTo(StringUtils.EMPTY); + assertThat(lnId).isSameAs(LnId.LN0_ID); + } + + @Test + void from_TLNode_should_succeed() { + //Given + TLNode tlNode = new TLNode(); + tlNode.setLnInst("1"); + tlNode.getLnClass().add(TSystemLNGroupEnum.LGOS.value()); + tlNode.setPrefix("Prefix"); + // When + LnId lnId = LnId.from(tlNode); + // Then + assertThat(lnId.lnClass()).isEqualTo("LGOS"); + assertThat(lnId.lnInst()).isEqualTo("1"); + assertThat(lnId.prefix()).isEqualTo("Prefix"); + } + + @Test + void from_TLNode_LN0_should_succeed() { + //Given + TLNode tlNode = new TLNode(); + tlNode.setLnInst(""); + tlNode.getLnClass().add("LLN0"); + tlNode.setPrefix(""); + // When + LnId lnId = LnId.from(tlNode); + // Then + assertThat(lnId).isSameAs(LnId.LN0_ID); } } diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapterTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapterTest.java index f7d1abdc2..1f7edd2f9 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapterTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/scl/sstation/SubstationAdapterTest.java @@ -4,7 +4,6 @@ package org.lfenergy.compas.sct.commons.scl.sstation; -import org.apache.commons.lang3.tuple.Pair; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.lfenergy.compas.scl2007b4.model.SCL; @@ -12,9 +11,6 @@ import org.lfenergy.compas.scl2007b4.model.TSubstation; import org.lfenergy.compas.scl2007b4.model.TVoltageLevel; import org.lfenergy.compas.sct.commons.scl.SclRootAdapter; -import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; - -import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -93,19 +89,4 @@ void addPrivate_with_type_and_source_should_create_Private() { assertThat(substationAdapter.getCurrentElem().getPrivate()).isNotEmpty(); } - - @Test - void getIedAndLDeviceNamesForLN0FromLNode_whenLNodeContainsLN0_shouldReturnListOf1Pair() { - // Given - SCL scl = SclTestMarshaller.getSCLFromFile("/scd-refresh-lnode/issue68_Test_Template.scd"); - SclRootAdapter sclRootAdapter = new SclRootAdapter(scl); - substationAdapter = sclRootAdapter.getSubstationAdapter(); - // When - List> iedNameLdInstList = substationAdapter.getIedAndLDeviceNamesForLN0FromLNode(); - // Then - assertThat(iedNameLdInstList) - .hasSize(1) - .containsExactly(Pair.of("IedName1", "LDSUIED")); - } - } 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 eb24171e4..c3232434a 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 @@ -115,264 +115,255 @@ public static TAnyLN findAnyLn(SCL scl, String iedName, String ldInst, String ln .orElseThrow(() -> new AssertionFailedError("LN (lnClass=%s, lnInst=%s, lnPrefix=%s) not found".formatted(lnClass, lnInst, prefix))); } - public static Stream getLDevices(TIED tied){ + public static Stream getLDevices(TIED tied) { return tied.getAccessPoint().stream() .filter(TAccessPoint::isSetServer) .flatMap(tAccessPoint -> tAccessPoint.getServer().getLDevice().stream()); } -public static IDataParentAdapter findDoiOrSdi(AbstractLNAdapter lnAdapter, String dataTypeRef) { - if (dataTypeRef.length() < 1) { - Assertions.fail("dataTypeRef must at least contain a DO, but got: " + dataTypeRef); - } - String[] names = dataTypeRef.split("\\."); - IDataParentAdapter parentAdapter = lnAdapter.getDOIAdapterByName(names[0]); - for (int i = 1; i < names.length; i++) { - parentAdapter = parentAdapter.getStructuredDataAdapterByName(names[i]); + public static IDataParentAdapter findDoiOrSdi(AbstractLNAdapter lnAdapter, String dataTypeRef) { + if (dataTypeRef.isEmpty()) { + Assertions.fail("dataTypeRef must at least contain a DO, but got: " + dataTypeRef); + } + String[] names = dataTypeRef.split("\\."); + IDataParentAdapter parentAdapter = lnAdapter.getDOIAdapterByName(names[0]); + for (int i = 1; i < names.length; i++) { + parentAdapter = parentAdapter.getStructuredDataAdapterByName(names[i]); + } + return parentAdapter; } - return parentAdapter; -} -public static Optional findDai(SCL scl, String iedName, String ldInst, String doiName, String daiName) { - return findDai( scl, iedName, ldInst, "LLN0", "", "", doiName, daiName); -} - -public static Optional findDai(SCL scl, String iedName, String ldInst, String lnClass, String lnInst, String lnPrefix, String doiName, String daiName) { - return findAnyLn(scl, iedName, ldInst, lnClass, lnInst, lnPrefix) - .getDOI().stream() - .filter(tdoi -> tdoi.getName().equals(doiName)) - .flatMap(tdoi -> tdoi.getSDIOrDAI().stream().map(tUnNaming -> (TDAI) tUnNaming)) - .filter(tdai -> tdai.getName().equals(daiName)) - .findFirst(); -} - -public static AbstractDAIAdapter findDai(AbstractLNAdapter lnAdapter, String dataTypeRef) { - String[] names = dataTypeRef.split("\\."); - if (names.length < 2) { - Assertions.fail("dataTypeRef must at least contain a DO and a DA name, but got: " + dataTypeRef); + public static Optional findDai(SCL scl, String iedName, String ldInst, String doiName, String daiName) { + return findDai(scl, iedName, ldInst, "LLN0", "", "", doiName, daiName); } - IDataParentAdapter parentAdapter = findDoiOrSdi(lnAdapter, String.join(".", Arrays.asList(names).subList(0, names.length - 1))); - return parentAdapter.getDataAdapterByName(names[names.length - 1]); -} - -public static String getValue(AbstractDAIAdapter daiAdapter) { - return getValue(daiAdapter.getCurrentElem()); -} - -public static String getValue(TDAI tdai) { - if (!tdai.isSetVal()) { - Assertions.fail("No value found for DAI " + tdai.getName()); - } else if (tdai.getVal().size() > 1) { - Assertions.fail("Expecting a single value for for DAI " + tdai.getName()); + public static Optional findDai(SCL scl, String iedName, String ldInst, String lnClass, String lnInst, String lnPrefix, String doiName, String daiName) { + return findAnyLn(scl, iedName, ldInst, lnClass, lnInst, lnPrefix) + .getDOI().stream() + .filter(tdoi -> tdoi.getName().equals(doiName)) + .flatMap(tdoi -> tdoi.getSDIOrDAI().stream().map(tUnNaming -> (TDAI) tUnNaming)) + .filter(tdai -> tdai.getName().equals(daiName)) + .findFirst(); } - return tdai.getVal().get(0).getValue(); -} + public static AbstractDAIAdapter findDai(AbstractLNAdapter lnAdapter, String dataTypeRef) { + String[] names = dataTypeRef.split("\\."); + if (names.length < 2) { + Assertions.fail("dataTypeRef must at least contain a DO and a DA name, but got: " + dataTypeRef); + } -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))); -} + IDataParentAdapter parentAdapter = findDoiOrSdi(lnAdapter, String.join(".", Arrays.asList(names).subList(0, names.length - 1))); + return parentAdapter.getDataAdapterByName(names[names.length - 1]); + } -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 String getValue(AbstractDAIAdapter daiAdapter) { + return getValue(daiAdapter.getCurrentElem()); + } -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() - .orElseThrow(() -> new AssertionFailedError(String.format("%s name=%s not found in IED.name=%s,LDevice.inst=%s,LN0", - controlBlockClass.getSimpleName(), cbName, iedName, ldInst))); -} + public static String getValue(TDAI tdai) { + if (!tdai.isSetVal()) { + Assertions.fail("No value found for DAI " + tdai.getName()); + } else if (tdai.getVal().size() > 1) { + Assertions.fail("Expecting a single value for for DAI " + tdai.getName()); + } + return tdai.getVal().getFirst().getValue(); + } -public static void assertControlBlockExists(SCL scd, String iedName, String ldInst, String cbName, - String datSet, String id, ControlBlockEnum controlBlockEnum) { - TControl controlBlock = findControlBlock(scd, iedName, ldInst, cbName, controlBlockEnum.getControlBlockClass()); - assertThat(controlBlock.getDatSet()).isEqualTo(datSet); - assertThat(getControlBlockId(controlBlock)).isEqualTo(id); -} + 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))); + } -private static String getControlBlockId(TControl tControl) { - if (tControl instanceof TGSEControl tgseControl) { - return tgseControl.getAppID(); + 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() + .orElseThrow(() -> new AssertionFailedError(String.format("%s name=%s not found in IED.name=%s,LDevice.inst=%s,LN0", + controlBlockClass.getSimpleName(), cbName, iedName, ldInst))); } - if (tControl instanceof TSampledValueControl tSampledValueControl) { - return tSampledValueControl.getSmvID(); + + public static void assertControlBlockExists(SCL scd, String iedName, String ldInst, String cbName, + String datSet, String id, ControlBlockEnum controlBlockEnum) { + TControl controlBlock = findControlBlock(scd, iedName, ldInst, cbName, controlBlockEnum.getControlBlockClass()); + assertThat(controlBlock.getDatSet()).isEqualTo(datSet); + assertThat(getControlBlockId(controlBlock)).isEqualTo(id); } - if (tControl instanceof TReportControl tReportControl) { - return tReportControl.getRptID(); + + private static String getControlBlockId(TControl tControl) { + if (tControl instanceof TGSEControl tgseControl) { + return tgseControl.getAppID(); + } + if (tControl instanceof TSampledValueControl tSampledValueControl) { + return tSampledValueControl.getSmvID(); + } + if (tControl instanceof TReportControl tReportControl) { + return tReportControl.getRptID(); + } + throw new AssertionFailedError("Cannot get Id for ControlBlock of type " + tControl.getClass().getSimpleName()); } - throw new AssertionFailedError("Cannot get Id for ControlBlock of type " + tControl.getClass().getSimpleName()); -} -public static Stream streamAllDataSets(SCL scl) { - return streamAllLn0Adapters(scl) - .map(ln0Adapter -> ln0Adapter.getCurrentElem().getDataSet()) - .flatMap(List::stream); -} + public static Stream streamAllDataSets(SCL scl) { + return streamAllLn0Adapters(scl) + .map(ln0Adapter -> ln0Adapter.getCurrentElem().getDataSet()) + .flatMap(List::stream); + } -public static Stream streamAllLn0Adapters(SCL scl) { - return new SclRootAdapter(scl) - .streamIEDAdapters() - .flatMap(IEDAdapter::streamLDeviceAdapters) - .filter(LDeviceAdapter::hasLN0) - .map(LDeviceAdapter::getLN0Adapter); -} + public static Stream streamAllLn0Adapters(SCL scl) { + return new SclRootAdapter(scl) + .streamIEDAdapters() + .flatMap(IEDAdapter::streamLDeviceAdapters) + .filter(LDeviceAdapter::hasLN0) + .map(LDeviceAdapter::getLN0Adapter); + } -public static Stream streamAllExtRef(SCL scl) { - return streamAllLn0Adapters(scl) - .filter(AbstractLNAdapter::hasInputs) - .map(LN0Adapter::getInputsAdapter) - .map(InputsAdapter::getCurrentElem) - .map(TInputs::getExtRef) - .flatMap(List::stream); -} + public static Stream streamAllExtRef(SCL scl) { + return streamAllLn0Adapters(scl) + .filter(AbstractLNAdapter::hasInputs) + .map(LN0Adapter::getInputsAdapter) + .map(InputsAdapter::getCurrentElem) + .map(TInputs::getExtRef) + .flatMap(List::stream); + } -public static String getDaiValue(AbstractLNAdapter ln, String doiName, String daiName) { - return ln.getDOIAdapterByName(doiName).getDataAdapterByName(daiName).getCurrentElem().getVal().get(0).getValue(); -} + public static String getDaiValue(AbstractLNAdapter ln, String doiName, String daiName) { + return ln.getDOIAdapterByName(doiName).getDataAdapterByName(daiName).getCurrentElem().getVal().getFirst().getValue(); + } -public static Stream streamAllConnectedApGseP(SCL scd, String pType) { - return scd.getCommunication().getSubNetwork().stream() - .map(TSubNetwork::getConnectedAP) - .flatMap(List::stream) - .map(TConnectedAP::getGSE) - .flatMap(List::stream) - .map(TControlBlock::getAddress) - .map(TAddress::getP) - .flatMap(List::stream) - .filter(tp -> pType.equals(tp.getType())) - .map(TP::getValue); -} + public static Stream streamAllConnectedApGseP(SCL scd, String pType) { + return scd.getCommunication().getSubNetwork().stream() + .map(TSubNetwork::getConnectedAP) + .flatMap(List::stream) + .map(TConnectedAP::getGSE) + .flatMap(List::stream) + .map(TControlBlock::getAddress) + .map(TAddress::getP) + .flatMap(List::stream) + .filter(tp -> pType.equals(tp.getType())) + .map(TP::getValue); + } -public static SclRootAdapter createSclRootAdapterWithIed(String iedName) { - SCL scl = new SCL(); - scl.setHeader(new THeader()); - TIED ied = new TIED(); - ied.setName(iedName); - scl.getIED().add(ied); - return new SclRootAdapter(scl); -} + public static SclRootAdapter createSclRootAdapterWithIed(String iedName) { + SCL scl = new SCL(); + scl.setHeader(new THeader()); + TIED ied = new TIED(); + ied.setName(iedName); + scl.getIED().add(ied); + return new SclRootAdapter(scl); + } -public static SclRootAdapter createSclRootWithConnectedAp(String iedName, String apName) { - SclRootAdapter sclRootAdapter = createSclRootAdapterWithIed(iedName); - SCL scl = sclRootAdapter.getCurrentElem(); - scl.setCommunication(new TCommunication()); - TSubNetwork subNetwork = new TSubNetwork(); - scl.getCommunication().getSubNetwork().add(subNetwork); - subNetwork.getConnectedAP().add(newConnectedAp(iedName, apName)); - return sclRootAdapter; -} + public static SclRootAdapter createSclRootWithConnectedAp(String iedName, String apName) { + SclRootAdapter sclRootAdapter = createSclRootAdapterWithIed(iedName); + SCL scl = sclRootAdapter.getCurrentElem(); + scl.setCommunication(new TCommunication()); + TSubNetwork subNetwork = new TSubNetwork(); + scl.getCommunication().getSubNetwork().add(subNetwork); + subNetwork.getConnectedAP().add(newConnectedAp(iedName, apName)); + return sclRootAdapter; + } -public static TExtRef createExtRefExample(String cbName, TServiceType tServiceType) { - TExtRef tExtRef = new TExtRef(); - tExtRef.setIedName("IED_NAME_2"); - tExtRef.setServiceType(tServiceType); - tExtRef.setSrcLDInst("Inst_2"); - tExtRef.setSrcLNInst("LN"); - tExtRef.setSrcPrefix("Prefix"); - tExtRef.setSrcCBName(cbName); - return tExtRef; -} + public static TExtRef createExtRefExample(String cbName, TServiceType tServiceType) { + TExtRef tExtRef = new TExtRef(); + tExtRef.setIedName("IED_NAME_2"); + tExtRef.setServiceType(tServiceType); + tExtRef.setSrcLDInst("Inst_2"); + tExtRef.setSrcLNInst("LN"); + tExtRef.setSrcPrefix("Prefix"); + tExtRef.setSrcCBName(cbName); + return tExtRef; + } -public static SclRootAdapter createIedsInScl(String lnClass, String doName) { - // DataTypeTemplate - TDO tdo = new TDO(); - tdo.setName(doName); - tdo.setType("REF"); - TLNodeType tlNodeType = new TLNodeType(); - tlNodeType.setId("T1"); - tlNodeType.getLnClass().add(lnClass); - tlNodeType.getDO().add(tdo); - - TDA tda = new TDA(); - tda.setName("setSrcRef"); - tda.setValImport(true); - tda.setBType(TPredefinedBasicTypeEnum.OBJ_REF); - tda.setFc(TFCEnum.SP); - - TDOType tdoType = new TDOType(); - tdoType.setId("REF"); - tdoType.getSDOOrDA().add(tda); - - TDataTypeTemplates tDataTypeTemplates = new TDataTypeTemplates(); - tDataTypeTemplates.getLNodeType().add(tlNodeType); - tDataTypeTemplates.getDOType().add(tdoType); - - - //ied Client - TDOI tdoi = new TDOI(); - tdoi.setName(doName); - TLDevice tlDevice = new TLDevice(); - tlDevice.setInst("LD_ADD"); - TInputs tInputs = new TInputs(); - LN0 ln0 = new LN0(); - ln0.setInputs(tInputs); - tlDevice.setLN0(ln0); - - TLDevice tlDevice1 = new TLDevice(); - tlDevice1.setLN0(new LN0()); - tlDevice1.setInst(LD_SUIED); - TLN tln1 = new TLN(); - tln1.getLnClass().add(lnClass); - tln1.setLnType("T1"); - tln1.getDOI().add(tdoi); - tlDevice1.getLN().add(tln1); - TServer tServer1 = new TServer(); - tServer1.getLDevice().add(tlDevice1); - tServer1.getLDevice().add(tlDevice); - TAccessPoint tAccessPoint1 = new TAccessPoint(); - tAccessPoint1.setName("AP_NAME"); - tAccessPoint1.setServer(tServer1); - TIED tied1 = new TIED(); - tied1.setName(IED_NAME_1); - tied1.getAccessPoint().add(tAccessPoint1); - - //ied Source - TLDevice tlDevice2 = new TLDevice(); - tlDevice2.setInst("Inst_2"); - tlDevice2.setLdName("LD_Name"); - tlDevice2.setLN0(new LN0()); - TServer tServer2 = new TServer(); - tServer2.getLDevice().add(tlDevice2); - TAccessPoint tAccessPoint2 = new TAccessPoint(); - tAccessPoint2.setName("AP_NAME"); - tAccessPoint2.setServer(tServer2); - TIED tied2 = new TIED(); - tied2.setName(IED_NAME_2); - tied2.getAccessPoint().add(tAccessPoint2); - //SCL file - SCL scd = new SCL(); - scd.getIED().add(tied1); - scd.getIED().add(tied2); - THeader tHeader = new THeader(); - tHeader.setRevision("1"); - scd.setHeader(tHeader); - scd.setDataTypeTemplates(tDataTypeTemplates); - - return new SclRootAdapter(scd); -} + public static SclRootAdapter createIedsInScl(String lnClass, String doName) { + // DataTypeTemplate + TDO tdo = new TDO(); + tdo.setName(doName); + tdo.setType("REF"); + TLNodeType tlNodeType = new TLNodeType(); + tlNodeType.setId("T1"); + tlNodeType.getLnClass().add(lnClass); + tlNodeType.getDO().add(tdo); + + TDA tda = new TDA(); + tda.setName("setSrcRef"); + tda.setValImport(true); + tda.setBType(TPredefinedBasicTypeEnum.OBJ_REF); + tda.setFc(TFCEnum.SP); + + TDOType tdoType = new TDOType(); + tdoType.setId("REF"); + tdoType.getSDOOrDA().add(tda); + + TDataTypeTemplates tDataTypeTemplates = new TDataTypeTemplates(); + tDataTypeTemplates.getLNodeType().add(tlNodeType); + tDataTypeTemplates.getDOType().add(tdoType); + + + //ied Client + TDOI tdoi = new TDOI(); + tdoi.setName(doName); + TLDevice tlDevice = new TLDevice(); + tlDevice.setInst("LD_ADD"); + TInputs tInputs = new TInputs(); + LN0 ln0 = new LN0(); + ln0.setInputs(tInputs); + tlDevice.setLN0(ln0); + + TLDevice tlDevice1 = new TLDevice(); + tlDevice1.setLN0(new LN0()); + tlDevice1.setInst(LD_SUIED); + TLN tln1 = new TLN(); + tln1.getLnClass().add(lnClass); + tln1.setLnType("T1"); + tln1.getDOI().add(tdoi); + tlDevice1.getLN().add(tln1); + TServer tServer1 = new TServer(); + tServer1.getLDevice().add(tlDevice1); + tServer1.getLDevice().add(tlDevice); + TAccessPoint tAccessPoint1 = new TAccessPoint(); + tAccessPoint1.setName("AP_NAME"); + tAccessPoint1.setServer(tServer1); + TIED tied1 = new TIED(); + tied1.setName(IED_NAME_1); + tied1.getAccessPoint().add(tAccessPoint1); + + //ied Source + TLDevice tlDevice2 = new TLDevice(); + tlDevice2.setInst("Inst_2"); + tlDevice2.setLdName("LD_Name"); + tlDevice2.setLN0(new LN0()); + TServer tServer2 = new TServer(); + tServer2.getLDevice().add(tlDevice2); + TAccessPoint tAccessPoint2 = new TAccessPoint(); + tAccessPoint2.setName("AP_NAME"); + tAccessPoint2.setServer(tServer2); + TIED tied2 = new TIED(); + tied2.setName(IED_NAME_2); + tied2.getAccessPoint().add(tAccessPoint2); + //SCL file + SCL scd = new SCL(); + scd.getIED().add(tied1); + scd.getIED().add(tied2); + THeader tHeader = new THeader(); + tHeader.setRevision("1"); + scd.setHeader(tHeader); + scd.setDataTypeTemplates(tDataTypeTemplates); + + return new SclRootAdapter(scd); + } -public static List getDaiValues(LDeviceAdapter lDeviceAdapter, String lnClass, String doName, String daName) { - return getDAIAdapters(lDeviceAdapter, lnClass, doName, daName) - .map(daiAdapter -> daiAdapter.getCurrentElem().getVal()) - .flatMap(List::stream) - .toList(); -} + public static List getDaiValues(LDeviceAdapter lDeviceAdapter, String lnClass, String doName, String daName) { + return getDAIAdapters(lDeviceAdapter, lnClass, doName, daName) + .map(daiAdapter -> daiAdapter.getCurrentElem().getVal()) + .flatMap(List::stream) + .toList(); + } -public static Stream getDAIAdapters(LDeviceAdapter lDeviceAdapter, String lnClass, String doName, String daName) { - return lDeviceAdapter.getLNAdapters().stream() - .filter(lnAdapter -> lnClassEquals(lnAdapter.getCurrentElem().getLnClass(), lnClass)) - .map(lnAdapter -> lnAdapter.getDOIAdapterByName(doName)) - .map(doiAdapter -> (DOIAdapter.DAIAdapter) doiAdapter.getDataAdapterByName(daName)); -} + public static Stream getDAIAdapters(LDeviceAdapter lDeviceAdapter, String lnClass, String doName, String daName) { + return lDeviceAdapter.getLNAdapters().stream() + .filter(lnAdapter -> lnClassEquals(lnAdapter.getCurrentElem().getLnClass(), lnClass)) + .map(lnAdapter -> lnAdapter.getDOIAdapterByName(doName)) + .map(doiAdapter -> (DOIAdapter.DAIAdapter) doiAdapter.getDataAdapterByName(daName)); + } } diff --git a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java index 6b8ab3469..a29b84f0e 100644 --- a/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java +++ b/sct-commons/src/test/java/org/lfenergy/compas/sct/commons/util/PrivateUtilsTest.java @@ -198,7 +198,7 @@ void createPrivate_should_return_private_new_private(Object compasElement) throw assertThat(resultPrivate).isNotNull() .hasFieldOrPropertyWithValue("type", privateEnum.getPrivateType()); assertThat(resultPrivate.getContent()).hasSize(1).first().satisfies(content -> assertThat(content).isInstanceOf(JAXBElement.class)); - JAXBElement content = (JAXBElement) resultPrivate.getContent().get(0); + JAXBElement content = (JAXBElement) resultPrivate.getContent().getFirst(); assertThat(content.isNil()).isFalse(); assertThat(content.getValue()).isNotNull().isInstanceOf(compasElement.getClass()) .isEqualTo(compasElement); @@ -258,10 +258,10 @@ void removePrivates_should_remove_privates_of_given_type() { PrivateUtils.removePrivates(baseElement, PrivateEnum.COMPAS_ICDHEADER); // Then assertThat(baseElement.getPrivate()).hasSize(1); - TPrivate tPrivate = baseElement.getPrivate().get(0); + TPrivate tPrivate = baseElement.getPrivate().getFirst(); assertThat(tPrivate.getType()).isEqualTo(privateSCD.getType()); assertThat(tPrivate.getContent()).hasSize(1).first().isInstanceOf(JAXBElement.class); - JAXBElement jaxbElement = (JAXBElement) tPrivate.getContent().get(0); + JAXBElement jaxbElement = (JAXBElement) tPrivate.getContent().getFirst(); assertThat(jaxbElement.isNil()).isFalse(); assertThat(jaxbElement.getValue()).isEqualTo(TCompasSclFileType.SCD); } @@ -561,7 +561,7 @@ void copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate() { PrivateUtils.copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate(stdTPrivate, lNodeCompasICDHeader); // Then - TCompasICDHeader result = PrivateUtils.extractCompasICDHeader(stdTPrivate).get(); + TCompasICDHeader result = PrivateUtils.extractCompasICDHeader(stdTPrivate).orElseThrow(); assertThat(result).extracting(TCompasICDHeader::getICDSystemVersionUUID, TCompasICDHeader::getIEDName, TCompasICDHeader::getIEDSubstationinstance, TCompasICDHeader::getBayLabel) .containsExactlyInAnyOrder("UUID-2", "IED-1", BigInteger.ONE, "BAY-1"); @@ -613,7 +613,7 @@ void getCompasICDHeaders_should_return_ICDHeaders() { private static TIED createTIED() { SCL sclFromFile = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml"); - return sclFromFile.getIED().get(0); + return sclFromFile.getIED().getFirst(); } @Test @@ -632,7 +632,7 @@ void createPrivate_compas_Topo_should_succeed(){ } @Test - void extractStringPrivate_should_succeed(){ + void extractStringPrivate_should_succeed() { // Given TIED tied = new TIED(); TPrivate tPrivate = new TPrivate(); diff --git a/sct-commons/src/test/resources/dtt-test-schema-conf/scd_dtt_do_sdo_da_bda_tests.xml b/sct-commons/src/test/resources/dtt-test-schema-conf/scd_dtt_do_sdo_da_bda_tests.xml index 7afa8fad6..b99fdb787 100644 --- a/sct-commons/src/test/resources/dtt-test-schema-conf/scd_dtt_do_sdo_da_bda_tests.xml +++ b/sct-commons/src/test/resources/dtt-test-schema-conf/scd_dtt_do_sdo_da_bda_tests.xml @@ -37,7 +37,10 @@ - Completed-diff + REB + RVB + RVL + RVB+L diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test1_LD_STATUS_INACTIVE.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test1_LD_STATUS_INACTIVE.scd deleted file mode 100644 index 33fc9cba8..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test1_LD_STATUS_INACTIVE.scd +++ /dev/null @@ -1,247 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
- -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
- -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - on - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - on - blocked - test - test/blocked - - - off - blocked - test - test/blocked - - - blocked - test - test/blocked - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test2_LD_STATUS_INACTIVE.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test2_LD_STATUS_INACTIVE.scd deleted file mode 100644 index 72b928c71..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test2_LD_STATUS_INACTIVE.scd +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
- -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
- -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - on - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - on - blocked - test - test/blocked - - - on - off - blocked - test - test/blocked - - - on - off - blocked - test - test/blocked - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_Dai_Not_Updatable.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_Dai_Not_Updatable.scd deleted file mode 100644 index 730ca6fd7..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_Dai_Not_Updatable.scd +++ /dev/null @@ -1,223 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
- -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
- -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - on - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - on - off - blocked - test - test/blocked - - - on - off - blocked - test - test/blocked - - - on - off - blocked - test - test/blocked - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingBeh.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingBeh.scd deleted file mode 100644 index 9e88bb19e..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingBeh.scd +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - - - - - - - - - - - - - blocked - test - test/blocked - off - on - - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivate.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivate.scd deleted file mode 100644 index 49cb8aac5..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivate.scd +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - - - - - - - - - - - - - - blocked - test - test/blocked - off - on - - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivateAttribute.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivateAttribute.scd deleted file mode 100644 index b592f569d..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingLDevicePrivateAttribute.scd +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - - - - - - - - - - - - - - blocked - test - test/blocked - off - on - - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingMod.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingMod.scd deleted file mode 100644 index 27b6c193d..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_KO_MissingMod.scd +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - - - - - - - - - - - - - blocked - test - test/blocked - off - on - - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_LD_STATUS_ACTIVE.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_LD_STATUS_ACTIVE.scd deleted file mode 100644 index 87ca28bf1..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_LD_STATUS_ACTIVE.scd +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
- -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
- -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - on - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - on - blocked - test - test/blocked - - - off - blocked - test - test/blocked - - - blocked - test - test/blocked - - -
diff --git a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_LD_STATUS_UNTESTED.scd b/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_LD_STATUS_UNTESTED.scd deleted file mode 100644 index c6f31cdb5..000000000 --- a/sct-commons/src/test/resources/scd-refresh-lnode/issue68_Test_LD_STATUS_UNTESTED.scd +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - SCD - -
- - - -
- - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - -
-

00000001

-
-
- -
-

00000001

-
-
-
- - -
-

Adresse IP du serveur Syslog

-
-
- -
-

Adresse IP du serveur Syslog

-
-
-
-
- - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - off - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - on - - - - - - - - - - - SAMU - SAMU - - - - - - - - - - - - - - - - - 01.00.000 - - - 01.00.000 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - on - blocked - test - test/blocked - - - off - blocked - test - test/blocked - - - blocked - test - test/blocked - - -
diff --git a/sct-commons/src/test/resources/scl-lnodestatus/lnodestatus.scd b/sct-commons/src/test/resources/scl-lnodestatus/lnodestatus.scd deleted file mode 100644 index 6ff6a8e6f..000000000 --- a/sct-commons/src/test/resources/scl-lnodestatus/lnodestatus.scd +++ /dev/null @@ -1,165 +0,0 @@ - - - - - - - - SCD - -
- - - 90 - - - - on - - - on - - - on - - - off - - - off - - - off - - - - - on - - - on - - - on - - - off - - - off - - - off - - - - - - - - - - - - on;off - - - - - - on;off - - - - - - off;on - - - - - - on - - - - - - on;off - - - - - - off;on - - - - - - off - - - - - - - - off;on - - - - - - - - on - - - - - - - - on;off - - - - - - - - off;on - - - - - - - - off - - - - - - - - - - - - - - - - - - - - on - off - test - - - diff --git a/sct-commons/src/test/resources/scl-lnodestatus/lnodestatus_without_mod_stval.scd b/sct-commons/src/test/resources/scl-lnodestatus/lnodestatus_without_mod_stval.scd deleted file mode 100644 index da7204fdc..000000000 --- a/sct-commons/src/test/resources/scl-lnodestatus/lnodestatus_without_mod_stval.scd +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - SCD - -
- - - 90 - - - - on - - - on - - - off - - - off - - - - - on - - - on - - - off - - - off - - - - - - - - - - - - on - - - on;off - - - on - - - on;off - - - off - - - - - on - - - - - on;off - - - - - off - - - - - - - - - - - - - - - - - on - off - test - - -