Skip to content

Commit fdc489d

Browse files
Merge pull request #325 from com-pas/develop
Release
2 parents 86d6850 + f2c32a3 commit fdc489d

File tree

72 files changed

+3178
-2196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3178
-2196
lines changed

sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceIntegrationTest.java

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import java.util.List;
2424
import java.util.UUID;
2525

26-
import static org.assertj.core.api.Assertions.assertThat;
27-
import static org.junit.jupiter.api.Assertions.*;
26+
import static org.assertj.core.api.Assertions.*;
2827
import static org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller.assertIsMarshallable;
2928

3029
class SclAutomationServiceIntegrationTest {
@@ -52,17 +51,17 @@ void createSCD_should_return_generatedSCD() {
5251
// When
5352
SCL scd = sclAutomationService.createSCD(ssd, headerDTO, List.of(std));
5453
// Then
55-
assertNotNull(scd.getHeader().getId());
56-
assertNull(scd.getHeader().getHistory());
57-
assertEquals(1, scd.getSubstation().size());
58-
assertEquals(1, scd.getIED().size());
59-
assertNotNull(scd.getDataTypeTemplates());
60-
assertEquals(2, scd.getCommunication().getSubNetwork().size());
54+
assertThat(scd.getHeader().getId()).isNotNull();
55+
assertThat(scd.getHeader().getHistory()).isNull();
56+
assertThat(scd.getSubstation()).hasSize(1);
57+
assertThat(scd.getIED()).hasSize(1);
58+
assertThat(scd.getDataTypeTemplates()).isNotNull();
59+
assertThat(scd.getCommunication().getSubNetwork()).hasSize(2);
6160
assertIsMarshallable(scd);
6261
}
6362

6463
@Test
65-
void createSCD_With_HItem() {
64+
void createSCD_WithHItem_should_return_generatedSCD() {
6665
// Given
6766
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
6867
historyItem.setWhat("what");
@@ -76,14 +75,14 @@ void createSCD_With_HItem() {
7675
// When
7776
SCL scd = sclAutomationService.createSCD(ssd, headerDTO, List.of(std1, std2, std3));
7877
// Then
79-
assertNotNull(scd.getHeader().getId());
80-
assertEquals(1, scd.getHeader().getHistory().getHitem().size());
81-
assertEquals(1, scd.getSubstation().size());
78+
assertThat(scd.getHeader().getId()).isNotNull();
79+
assertThat(scd.getHeader().getHistory().getHitem()).hasSize(1);
80+
assertThat(scd.getSubstation()).hasSize(1);
8281
assertIsMarshallable(scd);
8382
}
8483

8584
@Test
86-
void createSCD_With_HItems() {
85+
void createSCD_WithManyHItem_should_return_generatedSCD() {
8786
// Given
8887
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
8988
historyItem.setWhat("what");
@@ -101,24 +100,24 @@ void createSCD_With_HItems() {
101100
// When
102101
SCL scd = sclAutomationService.createSCD(ssd, headerDTO, List.of(std1, std2, std3));
103102
// Then
104-
assertNotNull(scd.getHeader().getId());
105-
assertEquals(1, scd.getHeader().getHistory().getHitem().size());
106-
assertEquals("what", scd.getHeader().getHistory().getHitem().get(0).getWhat());
103+
assertThat(scd.getHeader().getId()).isNotNull();
104+
assertThat(scd.getHeader().getHistory().getHitem()).hasSize(1);
105+
assertThat(scd.getHeader().getHistory().getHitem().get(0).getWhat()).isEqualTo("what");
107106
assertIsMarshallable(scd);
108107
}
109108

110109
@Test
111-
void createSCD_SSD_Without_Substation() {
110+
void createSCD_whenSSDWithoutSubstation_shouldThrowException() {
112111
// Given
113112
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd_without_substations.xml");
114113
// When & Then
115114
List<SCL> stdListEmpty = List.of();
116-
assertThrows(ScdException.class,
117-
() -> sclAutomationService.createSCD(ssd, headerDTO, stdListEmpty));
115+
assertThatThrownBy(() -> sclAutomationService.createSCD(ssd, headerDTO, stdListEmpty))
116+
.isInstanceOf(ScdException.class);
118117
}
119118

120119
@Test
121-
void createSCD_should_throw_exception_when_null_ssd() {
120+
void createSCD_whenSSDIsNull_shouldThrowException() {
122121
// Given
123122
HeaderDTO.HistoryItem historyItem = new HeaderDTO.HistoryItem();
124123
historyItem.setWhat("what");
@@ -129,18 +128,20 @@ void createSCD_should_throw_exception_when_null_ssd() {
129128
List<SCL> stdList = List.of(std1);
130129

131130
// When & Then
132-
assertThrows(NullPointerException.class, () -> sclAutomationService.createSCD(null, headerDTO, stdList));
131+
assertThatCode(() -> sclAutomationService.createSCD(null, headerDTO, stdList))
132+
.isInstanceOf(NullPointerException.class);
133133
}
134134

135135
@Test
136-
void createSCD_should_throw_exception_when_null_headerDTO() {
136+
void createSCD_whenheaderDTOIsNull_shouldThrowException() {
137137
// Given
138138
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
139139
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
140140
List<SCL> stdList = List.of(std1);
141141

142142
// When & Then
143-
assertThrows(NullPointerException.class, () -> sclAutomationService.createSCD(ssd, null, stdList));
143+
assertThatCode(() -> sclAutomationService.createSCD(ssd, null, stdList))
144+
.isInstanceOf(NullPointerException.class);
144145
}
145146

146147
@Test
@@ -160,7 +161,7 @@ void createSCD_should_delete_ControlBlocks_DataSet_and_ExtRef_src_attributes() {
160161

161162
assertThat(ln0.getDataSet()).isEmpty();
162163
assertThat(ln0.getInputs().getExtRef()).hasSize(2);
163-
assertFalse(ln0.getInputs().getExtRef().get(0).isSetSrcLDInst());
164+
assertThat(ln0.getInputs().getExtRef().get(0).isSetSrcLDInst()).isFalse();
164165
assertIsMarshallable(scd);
165166
}
166167

sct-app/src/test/java/org.lfenergy.compas.sct.app/SclAutomationServiceTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void createSCD_with_headerHistory_should_return_generatedSCD() throws Invocation
114114
}
115115

116116
@Test
117-
void createSCD_should_throw_exception_when_sclEditor_initScl_Fail() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
117+
void createSCD_when_sclEditor_initScl_Fail_should_throw_exception() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
118118
// Given
119119
SCL ssd = (SCL) BeanUtils.cloneBean(scl);
120120
SCL std = (SCL) BeanUtils.cloneBean(scl);
@@ -126,7 +126,7 @@ void createSCD_should_throw_exception_when_sclEditor_initScl_Fail() throws Invoc
126126
}
127127

128128
@Test
129-
void createSCD_should_throw_exception_when_sclEditor_addHistoryItem_Fail() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
129+
void createSCD_when_sclEditor_addHistoryItem_Fail_should_throw_exception() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
130130
// Given
131131
SCL ssd = (SCL) BeanUtils.cloneBean(scl);
132132
SCL std = (SCL) BeanUtils.cloneBean(scl);
@@ -140,7 +140,7 @@ void createSCD_should_throw_exception_when_sclEditor_addHistoryItem_Fail() throw
140140
}
141141

142142
@Test
143-
void createSCD_should_throw_exception_when_substationEditor_addSubstation_Fail() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
143+
void createSCD_when_substationEditor_addSubstation_Fail_should_throw_exception() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
144144
// Given
145145
SCL ssd = (SCL) BeanUtils.cloneBean(scl);
146146
SCL std = (SCL) BeanUtils.cloneBean(scl);
@@ -155,7 +155,7 @@ void createSCD_should_throw_exception_when_substationEditor_addSubstation_Fail()
155155
}
156156

157157
@Test
158-
void createSCD_should_throw_exception_when_sclEditor_importSTDElementsInSCD_Fail() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
158+
void createSCD_when_sclEditor_importSTDElementsInSCD_Fail_should_throw_exception() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
159159
// Given
160160
SCL ssd = (SCL) BeanUtils.cloneBean(scl);
161161
SCL std = (SCL) BeanUtils.cloneBean(scl);
@@ -172,7 +172,7 @@ void createSCD_should_throw_exception_when_sclEditor_importSTDElementsInSCD_Fail
172172
}
173173

174174
@Test
175-
void createSCD_should_throw_exception_when_sclEditor_removeAllControlBlocksAndDatasetsAndExtRefSrcBindings_Fail() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
175+
void createSCD_when_sclEditor_removeAllControlBlocksAndDatasetsAndExtRefSrcBindings_Fail_should_throw_exception() throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
176176
// Given
177177
SCL ssd = (SCL) BeanUtils.cloneBean(scl);
178178
SCL std = (SCL) BeanUtils.cloneBean(scl);

sct-commons/src/main/java/org/lfenergy/compas/sct/commons/scl/dtt/LNodeTypeAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public String getId() {
346346
/**
347347
* Find bound DOType info
348348
* @param signalInfo extRef signal info for binding
349-
* @return DOType info as object contening name, id and adapter
349+
* @return DOType info as object containing name, id and adapter
350350
* @throws ScdException throws when DO unknown
351351
*/
352352
public DataTypeTemplateAdapter.DOTypeInfo findMatchingDOType(ExtRefSignalInfo signalInfo) throws ScdException{

sct-commons/src/test/java/org/lfenergy/compas/sct/commons/ExtRefServiceTest.java

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import org.assertj.core.api.Assertions;
88
import org.assertj.core.groups.Tuple;
9+
import org.junit.jupiter.api.Tag;
910
import org.junit.jupiter.api.Test;
1011
import org.junit.jupiter.api.extension.ExtendWith;
1112
import org.junit.jupiter.params.ParameterizedTest;
@@ -38,8 +39,7 @@
3839
import java.util.Optional;
3940
import java.util.stream.Stream;
4041

41-
import static org.assertj.core.api.Assertions.assertThat;
42-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
42+
import static org.assertj.core.api.Assertions.*;
4343
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4444
import static org.lfenergy.compas.scl2007b4.model.TFCEnum.ST;
4545
import static org.lfenergy.compas.sct.commons.dto.ControlBlockNetworkSettings.*;
@@ -559,7 +559,7 @@ void filterDuplicatedExtRefs_should_not_remove_not_duplicated_extrefs() {
559559
}
560560

561561
@Test
562-
void manageBindingForLDEPF_should_return_noReportAndExtRefUpdateSuccessfully_whenFlowKindIsInternalAndAllExtRefInSameBay() {
562+
void manageBindingForLDEPF_whenFlowKindIsInternalAndAllExtRefInSameBay_should_return_noReportAndExtRefUpdateSuccessfully() {
563563
//Given
564564
String fileName = "LDEPF_Setting_file.csv";
565565
InputStream inputStream = Objects.requireNonNull(CsvUtils.class.getClassLoader().getResourceAsStream(fileName), "Resource not found: " + fileName);
@@ -626,7 +626,8 @@ void manageBindingForLDEPF_should_return_noReportAndExtRefUpdateSuccessfully_whe
626626
}
627627

628628
@Test
629-
void manageBindingForLDEPF_should_return_no_report_when_extRef_withDifferentIedType_update_successfully() {
629+
void manageBindingForLDEPF_when_extRef_withDifferentIedType_update_successfully_should_return_no_report() {
630+
// Given
630631
String fileName = "LDEPF_Setting_file.csv";
631632
InputStream inputStream = Objects.requireNonNull(CsvUtils.class.getClassLoader().getResourceAsStream(fileName), "Resource not found: " + fileName);
632633
InputStreamReader reader = new InputStreamReader(inputStream);
@@ -703,7 +704,7 @@ void manageBindingForLDEPF_should_return_no_report_when_extRef_withDifferentIedT
703704
}
704705

705706
@Test
706-
void manageBindingForLDEPF_should_return_report_when_manyIedSourceFound() {
707+
void manageBindingForLDEPF_when_manyIedSourceFound_should_return_report() {
707708
//Given
708709
String fileName = "LDEPF_Setting_file.csv";
709710
InputStream inputStream = Objects.requireNonNull(CsvUtils.class.getClassLoader().getResourceAsStream(fileName), "Resource not found: " + fileName);
@@ -746,7 +747,8 @@ void manageBindingForLDEPF_should_return_report_when_manyIedSourceFound() {
746747
}
747748

748749
@Test
749-
void manageBindingForLDEPF_should_return_no_report_when_extRefInFlowKindInternalAndExternal_update_successfully() {
750+
void manageBindingForLDEPF_when_extRefInFlowKindInternalAndExternal_update_successfully_should_return_no_report() {
751+
//Given
750752
String fileName = "LDEPF_Setting_file.csv";
751753
InputStream inputStream = Objects.requireNonNull(CsvUtils.class.getClassLoader().getResourceAsStream(fileName), "Resource not found: " + fileName);
752754
InputStreamReader reader = new InputStreamReader(inputStream);
@@ -815,24 +817,27 @@ private LDEPFSettingData getLDEPFSettingByAnalogNum(List<LDEPFSettingData> setti
815817
}
816818

817819
@Test
818-
void updateExtRefSource_shouldThrowScdException_whenSignalInfoNullOrInvalid() {
820+
@Tag("issue-321")
821+
void updateExtRefSource_whenSignalInfoNullOrInvalid_shouldThrowScdException() {
819822
//Given
820823
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-srv-scd-extref-cb/scd_get_cbs_test.xml");
821824
ExtRefInfo extRefInfo = new ExtRefInfo();
822825
extRefInfo.setHolderIEDName("IED_NAME2");
823826
extRefInfo.setHolderLDInst("LD_INST21");
824827
extRefInfo.setHolderLnClass(TLLN0Enum.LLN_0.value());
825-
826-
//When Then
827828
assertThat(extRefInfo.getSignalInfo()).isNull();
829+
//When Then
828830
assertThatThrownBy(() -> extRefService.updateExtRefSource(scd, extRefInfo)).isInstanceOf(ScdException.class); // signal = null
831+
//Given
829832
extRefInfo.setSignalInfo(new ExtRefSignalInfo());
830833
assertThat(extRefInfo.getSignalInfo()).isNotNull();
834+
//When Then
831835
assertThatThrownBy(() -> extRefService.updateExtRefSource(scd, extRefInfo)).isInstanceOf(ScdException.class);// signal invalid
832836
}
833837

834838
@Test
835-
void updateExtRefSource_shouldThrowScdException_whenBindingInfoNullOrInvalid() {
839+
@Tag("issue-321")
840+
void updateExtRefSource_whenBindingInfoNullOrInvalid_shouldThrowScdException() {
836841
//Given
837842
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-srv-scd-extref-cb/scd_get_cbs_test.xml");
838843
ExtRefInfo extRefInfo = new ExtRefInfo();
@@ -845,16 +850,19 @@ void updateExtRefSource_shouldThrowScdException_whenBindingInfoNullOrInvalid() {
845850
extRefSignalInfo.setPDA("da21.bda211.bda212.bda213");
846851
extRefSignalInfo.setPDO("Do21.sdo21");
847852
extRefInfo.setSignalInfo(extRefSignalInfo);
848-
//When Then
849853
assertThat(extRefInfo.getBindingInfo()).isNull();
850-
assertThatThrownBy(() -> extRefService.updateExtRefSource(scd, extRefInfo)).isInstanceOf(ScdException.class); // binding = null
854+
//When Then
855+
assertThatThrownBy(() -> extRefService.updateExtRefSource(scd, extRefInfo))
856+
.isInstanceOf(ScdException.class); // binding = null
857+
//Given
851858
extRefInfo.setBindingInfo(new ExtRefBindingInfo());
852859
assertThat(extRefInfo.getBindingInfo()).isNotNull();
860+
//When Then
853861
assertThatThrownBy(() -> extRefService.updateExtRefSource(scd, extRefInfo)).isInstanceOf(ScdException.class);// binding invalid
854862
}
855863

856864
@Test
857-
void updateExtRefSource_shouldThrowScdException_whenBindingInternalByIedName() {
865+
void updateExtRefSource_whenBindingInternalByIedName_shouldThrowScdException() {
858866
//Given
859867
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-srv-scd-extref-cb/scd_get_cbs_test.xml");
860868
ExtRefInfo extRefInfo = new ExtRefInfo();
@@ -878,7 +886,7 @@ void updateExtRefSource_shouldThrowScdException_whenBindingInternalByIedName() {
878886
}
879887

880888
@Test
881-
void updateExtRefSource_shouldThrowScdException_whenBindingInternaByServiceType() {
889+
void updateExtRefSource_whenBindingInternaByServiceType_shouldThrowScdException() {
882890
//Given
883891
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-srv-scd-extref-cb/scd_get_cbs_test.xml");
884892
ExtRefInfo extRefInfo = new ExtRefInfo();
@@ -903,7 +911,8 @@ void updateExtRefSource_shouldThrowScdException_whenBindingInternaByServiceType(
903911
}
904912

905913
@Test
906-
void updateExtRefSource_shouldThrowScdException_whenSourceInfoNullOrInvalid() {
914+
@Tag("issue-321")
915+
void updateExtRefSource_whenSourceInfoNullOrInvalid_shouldThrowScdException() {
907916
//Given
908917
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-srv-scd-extref-cb/scd_get_cbs_test.xml");
909918
ExtRefInfo extRefInfo = new ExtRefInfo();
@@ -923,16 +932,18 @@ void updateExtRefSource_shouldThrowScdException_whenSourceInfoNullOrInvalid() {
923932
extRefBindingInfo.setLnClass(TLLN0Enum.LLN_0.value());
924933
extRefInfo.setBindingInfo(new ExtRefBindingInfo());
925934

926-
//When Then
927935
assertThat(extRefInfo.getSourceInfo()).isNull();
936+
//When Then
928937
assertThatThrownBy(() -> extRefService.updateExtRefSource(scd, extRefInfo)).isInstanceOf(ScdException.class); // signal = null
938+
//Given
929939
extRefInfo.setSourceInfo(new ExtRefSourceInfo());
930940
assertThat(extRefInfo.getSourceInfo()).isNotNull();
941+
//When Then
931942
assertThatThrownBy(() -> extRefService.updateExtRefSource(scd, extRefInfo)).isInstanceOf(ScdException.class);// signal invalid
932943
}
933944

934945
@Test
935-
void updateExtRefSource_shouldThrowScdException_whenBindingExternalBinding() {
946+
void updateExtRefSource_whenBindingExternalBinding_shouldThrowScdException() {
936947
//Given
937948
SCL scd = SclTestMarshaller.getSCLFromFile("/scl-srv-scd-extref-cb/scd_get_cbs_test.xml");
938949
ExtRefInfo extRefInfo = new ExtRefInfo();

0 commit comments

Comments
 (0)