Skip to content

Commit d9b27b0

Browse files
committed
feat(#295): add createPrivate for CompasTopo
Signed-off-by: massifben <[email protected]>
1 parent 56e2f83 commit d9b27b0

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,21 @@ public static TPrivate createPrivate(TCompasSystemVersion compasSystemVersion) {
159159
return createPrivate(objectFactory.createSystemVersion(compasSystemVersion));
160160
}
161161

162+
/**
163+
* Create a single Private of type COMPAS-Topo
164+
* containing all given TCompasTopo
165+
* @param compasTopos list of TCompasTopo
166+
* @return created Private
167+
*/
168+
public static TPrivate createPrivate(List<TCompasTopo> compasTopos) {
169+
TPrivate tPrivate = new TPrivate();
170+
tPrivate.setType(PrivateEnum.COMPAS_TOPO.getPrivateType());
171+
tPrivate.getContent().addAll(
172+
compasTopos.stream().map(objectFactory::createTopo).toList()
173+
);
174+
return tPrivate;
175+
}
176+
162177
/**
163178
* Create Private of given type as parameter
164179
* @param jaxbElement content of Private to create

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,4 +579,19 @@ private static TIED createTIED() {
579579
SCL sclFromFile = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
580580
return sclFromFile.getIED().get(0);
581581
}
582+
583+
@Test
584+
void createPrivate_compas_Topo_should_succeed(){
585+
// Given
586+
TCompasTopo tCompasTopo1 = new TCompasTopo();
587+
TCompasTopo tCompasTopo2 = new TCompasTopo();
588+
List<TCompasTopo> compasTopos = List.of(tCompasTopo1, tCompasTopo2);
589+
// When
590+
TPrivate result = PrivateService.createPrivate(compasTopos);
591+
// Then
592+
assertThat(result.getContent())
593+
.map(JAXBElement.class::cast)
594+
.map(JAXBElement::getValue)
595+
.containsExactly(tCompasTopo1, tCompasTopo2);
596+
}
582597
}

0 commit comments

Comments
 (0)