Skip to content

Commit 9fc367c

Browse files
AliouDIAITESaintierFrFlurbmassifben
authored
Release 0.0.4 (#103)
* [#65] : correcting history for automation service Signed-off-by: Aliou DIAITE <[email protected]> * [#65 ==> 95] : correcting history for automation service: add test Signed-off-by: Aliou DIAITE <[email protected]> * Update SCL communication import method to allow the import of the att… (#91) * Update SCL communication import method to allow the import of the attributes Address et PhysConn if present. Signed-off-by: SAINTIER FRANCOIS <[email protected]> * [#66] : WIP Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : WIP to be refactored Signed-off-by: Aliou DIAITE <[email protected]> * Update SCL communication import method to allow the import of the att… (#91) * Update SCL communication import method to allow the import of the attributes Address et PhysConn if present. Signed-off-by: SAINTIER FRANCOIS <[email protected]> Signed-off-by: Aliou DIAITE <[email protected]> * [#65] : correcting history for automation service Signed-off-by: Aliou DIAITE <[email protected]> * [#65 ==> 95] : correcting history for automation service: add test Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : WIP refactoring and test needed Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : WIP add files and tests, refactoring Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : moving code to subnetwork and refactoring Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : delete not yet used code Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : WIP Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : WIP to be refactored Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : refactoring after remarks for pull request Signed-off-by: Aliou DIAITE <[email protected]> * [#66] : delete commented code and update pom.xml Signed-off-by: Aliou DIAITE <[email protected]> * Added CII Best Practices Badge + removed unused LFX Security Tool badge Signed-off-by: Flurb <[email protected]> * [#88] : add private COMPAS_SCL_FILE_TYPE in created SCD (#102) [#88] : add private COMPAS_SCL_FILE_TYPE in created SCD Signed-off-by: Aliou DIAITE <[email protected]> * [#70] : all updatable DA should be returned Signed-off-by: massifben <[email protected]> Co-authored-by: SaintierFr <[email protected]> Co-authored-by: Flurb <[email protected]> Co-authored-by: massifben <[email protected]>
1 parent a64fe00 commit 9fc367c

Some content is hidden

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

50 files changed

+4416
-526
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ SPDX-License-Identifier: Apache-2.0
55
-->
66

77
[![REUSE status](https://api.reuse.software/badge/github.com/com-pas/compas-sct)](https://api.reuse.software/info/github.com/com-pas/compas-sct)
8+
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5925/badge)](https://bestpractices.coreinfrastructure.org/projects/5925)
89

910
# System Configuration Tool (SCT) components
1011

pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<dependency>
4444
<groupId>org.projectlombok</groupId>
4545
<artifactId>lombok</artifactId>
46-
<version>1.18.20</version>
46+
<version>1.18.24</version>
4747
</dependency>
4848
<dependency>
4949
<groupId>org.junit.jupiter</groupId>
@@ -68,6 +68,11 @@
6868
<artifactId>scl2007b4</artifactId>
6969
<version>0.2.1</version>
7070
</dependency>
71+
<dependency>
72+
<groupId>org.lfenergy.compas.core</groupId>
73+
<artifactId>scl-extension</artifactId>
74+
<version>0.8.0</version>
75+
</dependency>
7176
<dependency>
7277
<groupId>ch.qos.logback</groupId>
7378
<artifactId>logback-classic</artifactId>
@@ -80,6 +85,10 @@
8085
<groupId>org.lfenergy.compas.core</groupId>
8186
<artifactId>scl2007b4</artifactId>
8287
</dependency>
88+
<dependency>
89+
<groupId>org.lfenergy.compas.core</groupId>
90+
<artifactId>scl-extension</artifactId>
91+
</dependency>
8392
<dependency>
8493
<groupId>ch.qos.logback</groupId>
8594
<artifactId>logback-classic</artifactId>
@@ -132,4 +141,4 @@
132141
</plugin>
133142
</plugins>
134143
</build>
135-
</project>
144+
</project>

sct-app/pom.xml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
<artifactId>junit-jupiter-engine</artifactId>
5757
<scope>test</scope>
5858
</dependency>
59+
<dependency>
60+
<groupId>org.mockito</groupId>
61+
<artifactId>mockito-core</artifactId>
62+
<version>3.6.28</version>
63+
<scope>test</scope>
64+
</dependency>
5965
</dependencies>
6066
<build>
6167
<plugins>
@@ -67,12 +73,29 @@
6773
<target>11</target>
6874
</configuration>
6975
</plugin>
70-
7176
<plugin>
7277
<groupId>org.apache.maven.plugins</groupId>
7378
<artifactId>maven-surefire-plugin</artifactId>
7479
</plugin>
75-
80+
<plugin>
81+
<groupId>org.jacoco</groupId>
82+
<artifactId>jacoco-maven-plugin</artifactId>
83+
<executions>
84+
<execution>
85+
<id>default-prepare-agent</id>
86+
<goals>
87+
<goal>prepare-agent</goal>
88+
</goals>
89+
</execution>
90+
<execution>
91+
<id>report</id>
92+
<phase>test</phase>
93+
<goals>
94+
<goal>report</goal>
95+
</goals>
96+
</execution>
97+
</executions>
98+
</plugin>
7699
<plugin>
77100
<groupId>org.apache.maven.plugins</groupId>
78101
<artifactId>maven-dependency-plugin</artifactId>
@@ -83,21 +106,25 @@
83106
<goals>
84107
<goal>unpack</goal>
85108
</goals>
86-
87109
<configuration>
110+
<includes>**/SCL2007B4/*.xsd, **/SCL_CoMPAS.xsd</includes>
88111
<artifactItems>
89112
<artifactItem>
90113
<groupId>org.lfenergy.compas.xsd</groupId>
91114
<artifactId>compas-scl-xsd</artifactId>
92115
<version>0.0.4</version>
93116
</artifactItem>
117+
<artifactItem>
118+
<groupId>org.lfenergy.compas.core</groupId>
119+
<artifactId>scl-extension</artifactId>
120+
<version>0.8.0</version>
121+
</artifactItem>
94122
</artifactItems>
95123
<outputDirectory>${project.build.directory}</outputDirectory>
96124
</configuration>
97125
</execution>
98126
</executions>
99127
</plugin>
100-
101128
</plugins>
102129
</build>
103130
</project>

sct-app/src/main/java/org/lfenergy/compas/sct/app/SclAutomationService.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,34 @@
66

77
import lombok.NonNull;
88
import lombok.extern.slf4j.Slf4j;
9+
import org.apache.commons.lang3.tuple.Pair;
910
import org.lfenergy.compas.scl2007b4.model.SCL;
1011
import org.lfenergy.compas.sct.commons.dto.HeaderDTO;
12+
import org.lfenergy.compas.sct.commons.dto.SubNetworkDTO;
1113
import org.lfenergy.compas.sct.commons.exception.ScdException;
1214
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
1315
import org.lfenergy.compas.sct.commons.scl.SclService;
1416

15-
import java.util.Optional;
17+
import java.util.*;
1618

1719
@Slf4j
1820
public class SclAutomationService {
1921

22+
private static final Map<Pair<String, String>, List<String>> comMap = Map.of(
23+
Pair.of("RSPACE_PROCESS_NETWORK", SubNetworkDTO.SubnetworkType.MMS.toString()), Arrays.asList("PROCESS_AP", "TOTO_AP_GE"),
24+
Pair.of("RSPACE_ADMIN_NETWORK", SubNetworkDTO.SubnetworkType.IP.toString()), Arrays.asList("ADMIN_AP","TATA_AP_EFFACEC"));
25+
2026
private SclAutomationService(){throw new IllegalStateException("SclAutomationService class"); }
2127

22-
public static SclRootAdapter createSCD(@NonNull SCL ssd, @NonNull HeaderDTO headerDTO) throws ScdException {
28+
public static SclRootAdapter createSCD(@NonNull SCL ssd, @NonNull HeaderDTO headerDTO, Set<SCL> stds) throws ScdException {
2329
SclRootAdapter scdAdapter = SclService.initScl(Optional.ofNullable(headerDTO.getId()),
2430
headerDTO.getVersion(),headerDTO.getRevision());
2531
if(!headerDTO.getHistoryItems().isEmpty()) {
26-
headerDTO.getHistoryItems().forEach(hItem ->
27-
SclService.addHistoryItem(scdAdapter.getCurrentElem(), hItem.getWho(), hItem.getWhat(), hItem.getWhy()));
32+
HeaderDTO.HistoryItem hItem = headerDTO.getHistoryItems().get(0);
33+
SclService.addHistoryItem(scdAdapter.getCurrentElem(), hItem.getWho(), hItem.getWhat(), hItem.getWhy());
2834
}
29-
SclService.addSubstation(scdAdapter.getCurrentElem(), ssd);
35+
SclService.addSubstation(scdAdapter.getCurrentElem(), ssd);
36+
SclService.importSTDElementsInSCD(scdAdapter, stds, comMap);
3037
return scdAdapter;
3138
}
3239
}

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;
1414

1515
import java.util.Arrays;
16+
import java.util.HashSet;
17+
import java.util.Set;
1618

1719
import static org.junit.jupiter.api.Assertions.*;
1820

@@ -29,11 +31,15 @@ void init(){
2931

3032
@Test
3133
void createSCD() throws Exception {
32-
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
33-
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO);
34+
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd.xml");
35+
SCL std = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
36+
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std));
3437
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
3538
assertNull(expectedSCD.getCurrentElem().getHeader().getHistory());
3639
assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());
40+
assertEquals(1, expectedSCD.getCurrentElem().getIED().size());
41+
assertNotNull(expectedSCD.getCurrentElem().getDataTypeTemplates());
42+
assertEquals(2, expectedSCD.getCurrentElem().getCommunication().getSubNetwork().size());
3743
}
3844

3945
@Test
@@ -44,7 +50,10 @@ void createSCD_With_HItem() throws Exception {
4450
historyItem.setWhy("because");
4551
headerDTO.getHistoryItems().add(historyItem);
4652
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
47-
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO);
53+
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
54+
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
55+
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
56+
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO, Set.of(std1, std2, std3));
4857
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
4958
assertEquals(1 ,expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
5059
assertEquals(1, expectedSCD.getCurrentElem().getSubstation().size());
@@ -62,16 +71,20 @@ void createSCD_With_HItems() throws Exception {
6271
historyItemBis.setWhy("because bis");
6372
headerDTO.getHistoryItems().addAll(Arrays.asList(historyItem, historyItemBis));
6473
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd.xml");
65-
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO);
74+
SCL std1 = SclTestMarshaller.getSCLFromFile("/std_1.xml");
75+
SCL std2 = SclTestMarshaller.getSCLFromFile("/std_2.xml");
76+
SCL std3 = SclTestMarshaller.getSCLFromFile("/std_3.xml");
77+
SclRootAdapter expectedSCD = SclAutomationService.createSCD(ssd, headerDTO,Set.of(std1, std2, std3));
6678
assertNotNull(expectedSCD.getCurrentElem().getHeader().getId());
67-
assertEquals(2 ,expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
79+
assertEquals(1, expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().size());
80+
assertEquals("what", expectedSCD.getCurrentElem().getHeader().getHistory().getHitem().get(0).getWhat());
6881
}
6982

70-
7183
@Test
7284
void createSCD_SSD_Without_Substation() throws Exception {
7385
SCL ssd = SclTestMarshaller.getSCLFromFile("/scd-substation-import-ssd/ssd_without_substations.xml");
7486
assertThrows(ScdException.class,
75-
() -> SclAutomationService.createSCD(ssd, headerDTO) );
87+
() -> SclAutomationService.createSCD(ssd, headerDTO, new HashSet<>()) );
7688
}
89+
7790
}

0 commit comments

Comments
 (0)