Skip to content

Commit

Permalink
Merge pull request #296 from com-pas/feat/295-add-createPrivate-for-c…
Browse files Browse the repository at this point in the history
…ompasTopo

feat(#295): add createPrivate for CompasTopo
  • Loading branch information
massifben authored Jul 13, 2023
2 parents 56e2f83 + d9b27b0 commit f93a527
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ public static TPrivate createPrivate(TCompasSystemVersion compasSystemVersion) {
return createPrivate(objectFactory.createSystemVersion(compasSystemVersion));
}

/**
* Create a single Private of type COMPAS-Topo
* containing all given TCompasTopo
* @param compasTopos list of TCompasTopo
* @return created Private
*/
public static TPrivate createPrivate(List<TCompasTopo> compasTopos) {
TPrivate tPrivate = new TPrivate();
tPrivate.setType(PrivateEnum.COMPAS_TOPO.getPrivateType());
tPrivate.getContent().addAll(
compasTopos.stream().map(objectFactory::createTopo).toList()
);
return tPrivate;
}

/**
* Create Private of given type as parameter
* @param jaxbElement content of Private to create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,19 @@ private static TIED createTIED() {
SCL sclFromFile = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
return sclFromFile.getIED().get(0);
}

@Test
void createPrivate_compas_Topo_should_succeed(){
// Given
TCompasTopo tCompasTopo1 = new TCompasTopo();
TCompasTopo tCompasTopo2 = new TCompasTopo();
List<TCompasTopo> compasTopos = List.of(tCompasTopo1, tCompasTopo2);
// When
TPrivate result = PrivateService.createPrivate(compasTopos);
// Then
assertThat(result.getContent())
.map(JAXBElement.class::cast)
.map(JAXBElement::getValue)
.containsExactly(tCompasTopo1, tCompasTopo2);
}
}

0 comments on commit f93a527

Please sign in to comment.