8
8
import org .junit .jupiter .api .Test ;
9
9
import org .lfenergy .compas .scl2007b4 .model .SCL ;
10
10
import org .lfenergy .compas .scl2007b4 .model .TIED ;
11
+ import org .lfenergy .compas .sct .commons .exception .ScdException ;
11
12
import org .lfenergy .compas .sct .commons .testhelpers .SclTestMarshaller ;
12
13
13
14
import java .util .List ;
14
15
15
16
import static org .assertj .core .api .Assertions .assertThat ;
17
+ import static org .assertj .core .api .Assertions .assertThatCode ;
16
18
17
19
class IedServiceTest {
18
20
19
21
@ Test
20
22
void getFilteredIeds_should_return_ldevices () {
21
23
//Given
22
24
SCL std = SclTestMarshaller .getSCLFromFile ("/std/std_sample.std" );
23
- IedService ldeviceService = new IedService ();
25
+ IedService iedService = new IedService ();
24
26
25
27
//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 ();
27
29
28
30
//Then
29
31
assertThat (tieds )
@@ -32,14 +34,42 @@ void getFilteredIeds_should_return_ldevices() {
32
34
.containsExactly (Tuple .tuple ("IED4d4fe1a8cda64cf88a5ee4176a1a0eef" , "ADU" ));
33
35
}
34
36
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
+
35
65
@ Test
36
66
void findIed_should_return_ldevice () {
37
67
//Given
38
68
SCL std = SclTestMarshaller .getSCLFromFile ("/std/std_sample.std" );
39
- IedService ldeviceService = new IedService ();
69
+ IedService iedService = new IedService ();
40
70
41
71
//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 ();
43
73
44
74
//Then
45
75
assertThat (tied )
0 commit comments