-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: gleizesDor <115622893+gleizesDor@users.noreply.github.com>
- Loading branch information
1 parent
1a59232
commit 26fc78b
Showing
2 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.assertj.core.groups.Tuple; | ||
import org.junit.jupiter.api.Test; | ||
import org.lfenergy.compas.scl2007b4.model.SCL; | ||
import org.lfenergy.compas.scl2007b4.model.TDO; | ||
import org.lfenergy.compas.scl2007b4.model.TLNodeType; | ||
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class DoServiceTest { | ||
|
||
@Test | ||
void getDos() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TLNodeType lnodeType = std.getDataTypeTemplates().getLNodeType().get(0); | ||
DoService doService = new DoService(); | ||
|
||
//When | ||
List<TDO> dos = doService.getDos(lnodeType).toList(); | ||
|
||
//Then | ||
assertThat(dos) | ||
.hasSize(14) | ||
.extracting(TDO::getName) | ||
.containsExactly("NumInput1", | ||
"PolConnRef1", | ||
"BrdPos", | ||
"ConnName1", | ||
"PhyHealth", | ||
"ConnRef1", | ||
"NamPlt", | ||
"RfHz1", | ||
"PhyNam", | ||
"Beh", | ||
"BrdNum", | ||
"ARtgLow1", | ||
"ARtgHigh1", | ||
"AnIn1"); | ||
} | ||
|
||
@Test | ||
void getFilteredDos() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TLNodeType lnodeType = std.getDataTypeTemplates().getLNodeType().get(0); | ||
DoService doService = new DoService(); | ||
|
||
//When | ||
List<TDO> dos = doService.getFilteredDos(lnodeType, tdo -> "NumInput1".equals(tdo.getName())).toList(); | ||
|
||
//Then | ||
assertThat(dos) | ||
.hasSize(1) | ||
.extracting(TDO::getName, TDO::getType) | ||
.containsExactly(Tuple.tuple("NumInput1", "RTE_X_X_X_553F8AE90EC0448B1518B00F5EAABB58_ING_V1.0.0")); | ||
} | ||
|
||
@Test | ||
void findDo() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TLNodeType lnodeType = std.getDataTypeTemplates().getLNodeType().get(0); | ||
DoService doService = new DoService(); | ||
|
||
//When | ||
TDO tdo1 = doService.findDo(lnodeType, tdo -> "NumInput1".equals(tdo.getName())).orElseThrow(); | ||
|
||
//Then | ||
assertThat(tdo1) | ||
.extracting(TDO::getName, TDO::getType) | ||
.containsExactly("NumInput1", "RTE_X_X_X_553F8AE90EC0448B1518B00F5EAABB58_ING_V1.0.0"); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
sct-commons/src/test/java/org/lfenergy/compas/sct/commons/DoTypeServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// SPDX-FileCopyrightText: 2023 RTE FRANCE | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.lfenergy.compas.sct.commons; | ||
|
||
import org.assertj.core.groups.Tuple; | ||
import org.junit.jupiter.api.Test; | ||
import org.lfenergy.compas.scl2007b4.model.SCL; | ||
import org.lfenergy.compas.scl2007b4.model.TDOType; | ||
import org.lfenergy.compas.scl2007b4.model.TDataTypeTemplates; | ||
import org.lfenergy.compas.scl2007b4.model.TPredefinedCDCEnum; | ||
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller; | ||
|
||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class DoTypeServiceTest { | ||
|
||
@Test | ||
void getDoTypes() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); | ||
DoTypeService doTypeService = new DoTypeService(); | ||
|
||
//When | ||
List<TDOType> tdoTypes = doTypeService.getDoTypes(dataTypeTemplates).toList(); | ||
|
||
//Then | ||
assertThat(tdoTypes) | ||
.hasSize(47); | ||
} | ||
|
||
@Test | ||
void getFilteredDoTypes() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); | ||
DoTypeService doTypeService = new DoTypeService(); | ||
|
||
//When | ||
List<TDOType> tdoTypes = | ||
doTypeService.getFilteredDoTypes(dataTypeTemplates, tdoType -> TPredefinedCDCEnum.DPL.equals(tdoType.getCdc())).toList(); | ||
|
||
//Then | ||
assertThat(tdoTypes) | ||
.hasSize(2) | ||
.extracting(TDOType::getCdc, TDOType::getId) | ||
.containsExactly(Tuple.tuple(TPredefinedCDCEnum.DPL, "RTE_X_X_X_48BA5C40D0913654FA5291A28C0D9716_DPL_V1.0.0"), | ||
Tuple.tuple(TPredefinedCDCEnum.DPL, "RTE_X_X_X_D93000A2D6F9B026504B48576A914DA3_DPL_V1.0.0")); | ||
|
||
} | ||
|
||
@Test | ||
void findDoType() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); | ||
DoTypeService doTypeService = new DoTypeService(); | ||
|
||
//When | ||
TDOType tdoType = doTypeService.findDoType(dataTypeTemplates, tdoType1 -> TPredefinedCDCEnum.DPL.equals(tdoType1.getCdc())).orElseThrow(); | ||
|
||
//Then | ||
assertThat(tdoType) | ||
.extracting(TDOType::getCdc, TDOType::getId) | ||
.containsExactly(TPredefinedCDCEnum.DPL, "RTE_X_X_X_48BA5C40D0913654FA5291A28C0D9716_DPL_V1.0.0"); | ||
} | ||
} |