@@ -198,7 +198,7 @@ void createPrivate_should_return_private_new_private(Object compasElement) throw
198198 assertThat (resultPrivate ).isNotNull ()
199199 .hasFieldOrPropertyWithValue ("type" , privateEnum .getPrivateType ());
200200 assertThat (resultPrivate .getContent ()).hasSize (1 ).first ().satisfies (content -> assertThat (content ).isInstanceOf (JAXBElement .class ));
201- JAXBElement <?> content = (JAXBElement <?>) resultPrivate .getContent ().get ( 0 );
201+ JAXBElement <?> content = (JAXBElement <?>) resultPrivate .getContent ().getFirst ( );
202202 assertThat (content .isNil ()).isFalse ();
203203 assertThat (content .getValue ()).isNotNull ().isInstanceOf (compasElement .getClass ())
204204 .isEqualTo (compasElement );
@@ -258,10 +258,10 @@ void removePrivates_should_remove_privates_of_given_type() {
258258 PrivateUtils .removePrivates (baseElement , PrivateEnum .COMPAS_ICDHEADER );
259259 // Then
260260 assertThat (baseElement .getPrivate ()).hasSize (1 );
261- TPrivate tPrivate = baseElement .getPrivate ().get ( 0 );
261+ TPrivate tPrivate = baseElement .getPrivate ().getFirst ( );
262262 assertThat (tPrivate .getType ()).isEqualTo (privateSCD .getType ());
263263 assertThat (tPrivate .getContent ()).hasSize (1 ).first ().isInstanceOf (JAXBElement .class );
264- JAXBElement <?> jaxbElement = (JAXBElement <?>) tPrivate .getContent ().get ( 0 );
264+ JAXBElement <?> jaxbElement = (JAXBElement <?>) tPrivate .getContent ().getFirst ( );
265265 assertThat (jaxbElement .isNil ()).isFalse ();
266266 assertThat (jaxbElement .getValue ()).isEqualTo (TCompasSclFileType .SCD );
267267 }
@@ -561,7 +561,7 @@ void copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate() {
561561 PrivateUtils .copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate (stdTPrivate , lNodeCompasICDHeader );
562562
563563 // Then
564- TCompasICDHeader result = PrivateUtils .extractCompasICDHeader (stdTPrivate ).get ();
564+ TCompasICDHeader result = PrivateUtils .extractCompasICDHeader (stdTPrivate ).orElseThrow ();
565565 assertThat (result ).extracting (TCompasICDHeader ::getICDSystemVersionUUID , TCompasICDHeader ::getIEDName ,
566566 TCompasICDHeader ::getIEDSubstationinstance , TCompasICDHeader ::getBayLabel )
567567 .containsExactlyInAnyOrder ("UUID-2" , "IED-1" , BigInteger .ONE , "BAY-1" );
@@ -613,7 +613,7 @@ void getCompasICDHeaders_should_return_ICDHeaders() {
613613
614614 private static TIED createTIED () {
615615 SCL sclFromFile = SclTestMarshaller .getSCLFromFile ("/scd-ied-dtt-com-import-stds/std.xml" );
616- return sclFromFile .getIED ().get ( 0 );
616+ return sclFromFile .getIED ().getFirst ( );
617617 }
618618
619619 @ Test
@@ -630,4 +630,18 @@ void createPrivate_compas_Topo_should_succeed(){
630630 .map (JAXBElement ::getValue )
631631 .containsExactly (tCompasTopo1 , tCompasTopo2 );
632632 }
633+
634+ @ Test
635+ void extractStringPrivate_should_succeed () {
636+ // Given
637+ TIED tied = new TIED ();
638+ TPrivate tPrivate = new TPrivate ();
639+ tPrivate .setType ("MyCustomType" );
640+ tPrivate .getContent ().add ("hello World" );
641+ tied .getPrivate ().add (tPrivate );
642+ // When
643+ Optional <String > result = PrivateUtils .extractStringPrivate (tied , "MyCustomType" );
644+ // Then
645+ assertThat (result ).hasValue ("hello World" );
646+ }
633647}
0 commit comments