@@ -198,7 +198,7 @@ void createPrivate_should_return_private_new_private(Object compasElement) throw
198
198
assertThat (resultPrivate ).isNotNull ()
199
199
.hasFieldOrPropertyWithValue ("type" , privateEnum .getPrivateType ());
200
200
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 ( );
202
202
assertThat (content .isNil ()).isFalse ();
203
203
assertThat (content .getValue ()).isNotNull ().isInstanceOf (compasElement .getClass ())
204
204
.isEqualTo (compasElement );
@@ -258,10 +258,10 @@ void removePrivates_should_remove_privates_of_given_type() {
258
258
PrivateUtils .removePrivates (baseElement , PrivateEnum .COMPAS_ICDHEADER );
259
259
// Then
260
260
assertThat (baseElement .getPrivate ()).hasSize (1 );
261
- TPrivate tPrivate = baseElement .getPrivate ().get ( 0 );
261
+ TPrivate tPrivate = baseElement .getPrivate ().getFirst ( );
262
262
assertThat (tPrivate .getType ()).isEqualTo (privateSCD .getType ());
263
263
assertThat (tPrivate .getContent ()).hasSize (1 ).first ().isInstanceOf (JAXBElement .class );
264
- JAXBElement <?> jaxbElement = (JAXBElement <?>) tPrivate .getContent ().get ( 0 );
264
+ JAXBElement <?> jaxbElement = (JAXBElement <?>) tPrivate .getContent ().getFirst ( );
265
265
assertThat (jaxbElement .isNil ()).isFalse ();
266
266
assertThat (jaxbElement .getValue ()).isEqualTo (TCompasSclFileType .SCD );
267
267
}
@@ -561,7 +561,7 @@ void copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate() {
561
561
PrivateUtils .copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate (stdTPrivate , lNodeCompasICDHeader );
562
562
563
563
// Then
564
- TCompasICDHeader result = PrivateUtils .extractCompasICDHeader (stdTPrivate ).get ();
564
+ TCompasICDHeader result = PrivateUtils .extractCompasICDHeader (stdTPrivate ).orElseThrow ();
565
565
assertThat (result ).extracting (TCompasICDHeader ::getICDSystemVersionUUID , TCompasICDHeader ::getIEDName ,
566
566
TCompasICDHeader ::getIEDSubstationinstance , TCompasICDHeader ::getBayLabel )
567
567
.containsExactlyInAnyOrder ("UUID-2" , "IED-1" , BigInteger .ONE , "BAY-1" );
@@ -613,7 +613,7 @@ void getCompasICDHeaders_should_return_ICDHeaders() {
613
613
614
614
private static TIED createTIED () {
615
615
SCL sclFromFile = SclTestMarshaller .getSCLFromFile ("/scd-ied-dtt-com-import-stds/std.xml" );
616
- return sclFromFile .getIED ().get ( 0 );
616
+ return sclFromFile .getIED ().getFirst ( );
617
617
}
618
618
619
619
@ Test
@@ -630,4 +630,18 @@ void createPrivate_compas_Topo_should_succeed(){
630
630
.map (JAXBElement ::getValue )
631
631
.containsExactly (tCompasTopo1 , tCompasTopo2 );
632
632
}
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
+ }
633
647
}
0 commit comments