88import org .junit .jupiter .api .Test ;
99import org .lfenergy .compas .scl2007b4 .model .SCL ;
1010import org .lfenergy .compas .scl2007b4 .model .TIED ;
11+ import org .lfenergy .compas .sct .commons .exception .ScdException ;
1112import org .lfenergy .compas .sct .commons .testhelpers .SclTestMarshaller ;
1213
1314import java .util .List ;
1415
1516import static org .assertj .core .api .Assertions .assertThat ;
17+ import static org .assertj .core .api .Assertions .assertThatCode ;
1618
1719class IedServiceTest {
1820
1921 @ Test
2022 void getFilteredIeds_should_return_ldevices () {
2123 //Given
2224 SCL std = SclTestMarshaller .getSCLFromFile ("/std/std_sample.std" );
23- IedService ldeviceService = new IedService ();
25+ IedService iedService = new IedService ();
2426
2527 //When
26- List <TIED > tieds = ldeviceService .getFilteredIeds (std , tied -> "IED4d4fe1a8cda64cf88a5ee4176a1a0eef" .equals (tied .getName ())).toList ();
28+ List <TIED > tieds = iedService .getFilteredIeds (std , tied -> "IED4d4fe1a8cda64cf88a5ee4176a1a0eef" .equals (tied .getName ())).toList ();
2729
2830 //Then
2931 assertThat (tieds )
@@ -32,14 +34,42 @@ void getFilteredIeds_should_return_ldevices() {
3234 .containsExactly (Tuple .tuple ("IED4d4fe1a8cda64cf88a5ee4176a1a0eef" , "ADU" ));
3335 }
3436
37+ @ Test
38+ void findByName_should_return_ied_infos () {
39+ //Given
40+ SCL std = SclTestMarshaller .getSCLFromFile ("/scl-srv-scd-extref-cb/scd_get_binders_test.xml" );
41+ IedService iedService = new IedService ();
42+
43+ //When
44+ TIED tied = iedService .findByName (std , "IED_NAME1" ).orElseThrow ();
45+
46+ //Then
47+ assertThat (tied )
48+ .extracting (TIED ::getName , TIED ::getType )
49+ .containsExactly ("IED_NAME1" , null );
50+ }
51+
52+ @ Test
53+ void findByName_should_fail () {
54+ //Given
55+ SCL std = SclTestMarshaller .getSCLFromFile ("/scl-srv-scd-extref-cb/scd_get_binders_test.xml" );
56+ IedService iedService = new IedService ();
57+
58+ //When
59+ //Then
60+ assertThatCode (() -> iedService .findByName (std , null ))
61+ .isInstanceOf (ScdException .class )
62+ .hasMessage ("The given iedName is null" );
63+ }
64+
3565 @ Test
3666 void findIed_should_return_ldevice () {
3767 //Given
3868 SCL std = SclTestMarshaller .getSCLFromFile ("/std/std_sample.std" );
39- IedService ldeviceService = new IedService ();
69+ IedService iedService = new IedService ();
4070
4171 //When
42- TIED tied = ldeviceService .findIed (std , ied -> "IED4d4fe1a8cda64cf88a5ee4176a1a0eef" .equals (ied .getName ())).orElseThrow ();
72+ TIED tied = iedService .findIed (std , ied -> "IED4d4fe1a8cda64cf88a5ee4176a1a0eef" .equals (ied .getName ())).orElseThrow ();
4373
4474 //Then
4575 assertThat (tied )
0 commit comments