-
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
26fc78b
commit 31821d2
Showing
1 changed file
with
86 additions
and
0 deletions.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
sct-commons/src/test/java/org/lfenergy/compas/sct/commons/LnodeTypeServiceTest.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,86 @@ | ||
// 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.TDataTypeTemplates; | ||
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 LnodeTypeServiceTest { | ||
|
||
@Test | ||
void getLnodeTypes() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); | ||
LnodeTypeService lnodeTypeService = new LnodeTypeService(); | ||
|
||
//When | ||
List<TLNodeType> tlnodeTypes = lnodeTypeService.getLnodeTypes(dataTypeTemplates).toList(); | ||
|
||
//Then | ||
assertThat(tlnodeTypes) | ||
.hasSize(15) | ||
.flatExtracting(TLNodeType::getLnClass) | ||
.containsExactly("LPAI", | ||
"LLN0", | ||
"LLN0", | ||
"TCTR", | ||
"LSET", | ||
"LCCH", | ||
"LPCP", | ||
"LGOS", | ||
"LTMS", | ||
"XSWI", | ||
"GAPC", | ||
"TVTR", | ||
"LSYN", | ||
"XSWI", | ||
"LSET"); | ||
} | ||
|
||
@Test | ||
void getFilteredLnodeTypes() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); | ||
LnodeTypeService lnodeTypeService = new LnodeTypeService(); | ||
|
||
//When | ||
List<TLNodeType> tlnodeTypes = | ||
lnodeTypeService.getFilteredLnodeTypes(dataTypeTemplates, tlNodeType -> tlNodeType.getLnClass().contains("LPAI")).toList(); | ||
|
||
//Then | ||
assertThat(tlnodeTypes) | ||
.hasSize(1) | ||
.extracting(TLNodeType::getLnClass, TLNodeType::getId) | ||
.containsExactly(Tuple.tuple(List.of("LPAI"), "RTE_8884DBCF760D916CCE3EE9D1846CE46F_LPAI_V1.0.0")); | ||
} | ||
|
||
@Test | ||
void findLnodeType() { | ||
//Given | ||
SCL std = SclTestMarshaller.getSCLFromFile("/std/std_sample.std"); | ||
TDataTypeTemplates dataTypeTemplates = std.getDataTypeTemplates(); | ||
LnodeTypeService lnodeTypeService = new LnodeTypeService(); | ||
|
||
//When | ||
TLNodeType tlnodeType = | ||
lnodeTypeService.findLnodeType(dataTypeTemplates, tlNodeType -> tlNodeType.getLnClass().contains("LPAI")).orElseThrow(); | ||
|
||
//Then | ||
assertThat(tlnodeType) | ||
.extracting(TLNodeType::getLnClass, TLNodeType::getId) | ||
.containsExactly(List.of("LPAI"), "RTE_8884DBCF760D916CCE3EE9D1846CE46F_LPAI_V1.0.0"); | ||
} | ||
} |