Skip to content

Commit

Permalink
Merge pull request #207 from com-pas/feature/206_update_compas_core_s…
Browse files Browse the repository at this point in the history
…cl-extension

feat(206): update compas-core dependency and refacto test class MarshallerWrapper
  • Loading branch information
AliouDIAITE authored Nov 29, 2022
2 parents 930c95b + 45b4e4f commit 5407cda
Show file tree
Hide file tree
Showing 44 changed files with 627 additions and 1,504 deletions.
52 changes: 32 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,36 @@
<sonar.coverage.exclusions>sct-coverage/**</sonar.coverage.exclusions>
<aggregate.report.dir>../sct-coverage/target/site/jacoco-aggregate/jacoco.xml</aggregate.report.dir>
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
<scl-extension.version>0.9.1</scl-extension.version>
<compas-core.version>0.12.0</compas-core.version>
<compas-scl-xsd.version>0.0.4</compas-scl-xsd.version>
<maven.plugin.javadoc>3.4.1</maven.plugin.javadoc>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<junit-version>5.9.0</junit-version>
<logback-classic.version>1.4.5</logback-classic.version>
<assertj.version>3.22.0</assertj.version>
<lombok.version>1.18.24</lombok.version>
</properties>

<dependencies>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl2007b4</artifactId>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -72,12 +89,12 @@
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl2007b4</artifactId>
<version>0.2.1</version>
<version>${compas-core.version}</version>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>${scl-extension.version}</version>
<version>${compas-core.version}</version>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.xsd</groupId>
Expand All @@ -87,24 +104,15 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.6</version>
<version>${logback-classic.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl2007b4</artifactId>
</dependency>
<dependency>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
</dependencies>
<modules>
<module>sct-commons</module>
<module>sct-coverage</module>
Expand All @@ -123,12 +131,16 @@
<plugin>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>${scl-extension.version}</version>
<version>${compas-core.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
Expand Down
17 changes: 1 addition & 16 deletions sct-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,27 +54,16 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.6.28</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -102,6 +91,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>unpack</id>
Expand All @@ -120,11 +110,6 @@
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
</artifactItem>
<artifactItem>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>0.8.0</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
Expand Down
4 changes: 2 additions & 2 deletions sct-app/src/test/resources/std_1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<compas:SystemVersion MainSystemVersion="01.00" MinorSystemVersion="009.001.001"/>
</Private>
<Private type="COMPAS-ICDHeader">
<compas:ICDHeader IEDType="GTW" ICDSystemVersionUUID="b4f8089e-4170-47f1-b6ad-dd1f50885518" VendorName="RTE" IEDredundancy="A" IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00" headerId="f8dbc8c1-2db7-4652-a9d6-0b414bdeccfa" headerVersion="01.00.00" headerRevision="01.00.00"/>
<compas:ICDHeader IEDType="SCU" ICDSystemVersionUUID="b4f8089e-4170-47f1-b6ad-dd1f50885518" VendorName="RTE" IEDredundancy="A" IEDmodel="ICDfromModeling" hwRev="01.00.00" swRev="01.00.00" headerId="f8dbc8c1-2db7-4652-a9d6-0b414bdeccfa" headerVersion="01.00.00" headerRevision="01.00.00"/>
</Private>
<Services nameLength="64">
<ConfLNs fixPrefix="true" fixLnInst="true"/>
Expand Down Expand Up @@ -341,4 +341,4 @@
<EnumVal ord="24">Y</EnumVal>
</EnumType>
</DataTypeTemplates>
</SCL>
</SCL>
19 changes: 2 additions & 17 deletions sct-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
<properties>
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/${aggregate.report.dir}</sonar.coverage.jacoco.xmlReportPaths>
<sonar.jacoco.excludes>**/scl2007b4/**/*</sonar.jacoco.excludes>
<assertJ.version>3.22.0</assertJ.version>
<opencsv.version>5.6</opencsv.version>
<opencsv.version>5.7.1</opencsv.version>
<mockito.version>4.9.0</mockito.version>
</properties>

Expand Down Expand Up @@ -91,11 +90,6 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
Expand All @@ -110,7 +104,6 @@
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertJ.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -125,10 +118,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -161,6 +150,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>unpack</id>
Expand All @@ -179,11 +169,6 @@
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
</artifactItem>
<artifactItem>
<groupId>org.lfenergy.compas.core</groupId>
<artifactId>scl-extension</artifactId>
<version>0.8.0</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
Expand Down
13 changes: 0 additions & 13 deletions sct-commons/src/main/resources/jaxb-marshaller-config.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ void testAddLDevice(){
assertTrue(iedDTO.getLDeviceDTO(DTO.HOLDER_LD_INST).isPresent());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.lfenergy.compas.sct.commons.dto.*;
import org.lfenergy.compas.sct.commons.exception.ScdException;
import org.lfenergy.compas.sct.commons.scl.ied.*;
import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;

import java.util.*;
Expand All @@ -26,7 +27,6 @@
import static org.lfenergy.compas.sct.commons.testhelpers.DataTypeUtils.createDa;
import static org.lfenergy.compas.sct.commons.testhelpers.DataTypeUtils.createDo;
import static org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller.assertIsMarshallable;
import static org.lfenergy.compas.sct.commons.testhelpers.marshaller.SclTestMarshaller.createWrapper;
import static org.lfenergy.compas.sct.commons.util.PrivateEnum.COMPAS_SCL_FILE_TYPE;

class SclServiceTest {
Expand Down Expand Up @@ -700,8 +700,8 @@ void testImportSTDElementsInSCD() throws Exception {
void testImportSTDElementsInSCD_with_Multiple_STD() throws Exception {
SCL scd = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/scd_lnode_with_many_compas_icdheader.xml");
SCL std0 = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std.xml");
SCL std1 = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std_SITESITE1GTW1.xml");
SCL std2 = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std_SITESITE1GTW2.xml");
SCL std1 = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std_SITESITE1SCU1.xml");
SCL std2 = SclTestMarshaller.getSCLFromFile("/scd-ied-dtt-com-import-stds/std_SITESITE1SCU2.xml");
SclRootAdapter scdRootAdapter = new SclRootAdapter(scd);

SclRootAdapter expectedScdAdapter = assertDoesNotThrow( () -> SclService.importSTDElementsInSCD(
Expand Down Expand Up @@ -835,11 +835,11 @@ void updateLDeviceStatus_shouldReturnReportWithError_MissingRequiredObject(Strin
// Given
assertTrue(getLDeviceStatusValue(scl, "IedName1", "LDSUIED").isPresent());
assertEquals("off", getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue());
String before = createWrapper().marshall(scl);
String before = MarshallerWrapper.marshall(scl);
// When
SclReport sclReport = SclService.updateLDeviceStatus(scl);
// Then
String after = createWrapper().marshall(sclReport.getSclRootAdapter().getCurrentElem());
String after = MarshallerWrapper.marshall(sclReport.getSclRootAdapter().getCurrentElem());
assertFalse(sclReport.isSuccess());
assertThat(sclReport.getSclReportItems())
.hasSize(1)
Expand Down Expand Up @@ -888,11 +888,11 @@ void updateLDeviceStatus_shouldReturnReportWithError_WhenLDeviceStatusActiveOrUn
assertEquals("off", getLDeviceStatusValue(scl, "IedName1", "LDSUIED").get().getValue());
assertEquals("on", getLDeviceStatusValue(scl, "IedName2", "LDSUIED").get().getValue());
assertFalse(getLDeviceStatusValue(scl, "IedName3", "LDSUIED").isPresent());
String before = createWrapper().marshall(scl);
String before = MarshallerWrapper.marshall(scl);
// When
SclReport sclReport = SclService.updateLDeviceStatus(scl);
// Then
String after = createWrapper().marshall(sclReport.getSclRootAdapter().getCurrentElem());
String after = MarshallerWrapper.marshall(sclReport.getSclRootAdapter().getCurrentElem());
assertFalse(sclReport.isSuccess());
assertThat(sclReport.getSclReportItems())
.hasSize(3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void testAmChildElementRef() {
}

@Test
void addPrivate() throws Exception {
void addPrivate() {
ConnectedAPAdapter connectedAPAdapter = subNetworkAdapter.getConnectedAPAdapter(DTO.HOLDER_IED_NAME, DTO.AP_NAME);
TPrivate tPrivate = new TPrivate();
tPrivate.setType("Private Type");
Expand Down Expand Up @@ -107,4 +107,4 @@ void elementXPath(String iedName, String apName, String message) {
assertThat(elementXPath).isEqualTo(message);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

package org.lfenergy.compas.sct.commons.scl.dtt;

import org.apache.commons.io.IOUtils;
import org.lfenergy.compas.scl2007b4.model.SCL;
import org.lfenergy.compas.scl2007b4.model.TDataTypeTemplates;
import org.lfenergy.compas.sct.commons.testhelpers.MarshallerWrapper;
import org.lfenergy.compas.sct.commons.scl.SclElementAdapter;
import org.lfenergy.compas.sct.commons.scl.SclRootAdapter;
import org.lfenergy.compas.sct.commons.testhelpers.SclTestMarshaller;
import org.mockito.Mockito;


Expand All @@ -26,7 +25,7 @@ public void init(){
}

protected static DataTypeTemplateAdapter initDttAdapterFromFile(String fileName) throws Exception {
SCL scd = AbstractDTTLevel.getSCLFromFile(fileName);
SCL scd = SclTestMarshaller.getSCLFromFile(fileName);
SclRootAdapter sclRootAdapter = new SclRootAdapter(scd);
return new DataTypeTemplateAdapter(
sclRootAdapter,
Expand All @@ -43,15 +42,4 @@ protected SclElementAdapter getMockedSclParentAdapter(){
}
protected abstract void completeInit() ;

public static SCL getSCLFromFile(String filename) throws Exception {
MarshallerWrapper marshallerWrapper = createWrapper();
byte[] rawXml = IOUtils.resourceToByteArray(filename);
return marshallerWrapper.unmarshall(rawXml,SCL.class);
}

public static MarshallerWrapper createWrapper() {
return MarshallerWrapper.builder()
.withProperties("classpath:scl_schema.yml")
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,8 @@ void testImportLNodeType() throws Exception {
assertTrue(nbLNodeType < rcvDttAdapter.getLNodeTypeAdapters().size());
assertFalse(mapOldNewId.isEmpty());

MarshallerWrapper marshallerWrapper = AbstractDTTLevel.createWrapper();
System.out.println(marshallerWrapper.marshall(rcvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(marshallerWrapper.marshall(prvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(MarshallerWrapper.marshall(rcvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(MarshallerWrapper.marshall(prvDttAdapter.getParentAdapter().getCurrentElem()));
}

@Test
Expand All @@ -358,9 +357,8 @@ void testImportDOType() throws Exception {
rcvDttAdapter.importDOType("IEDName",prvDttAdapter);
assertTrue(nbDOType < rcvDttAdapter.getDOTypeAdapters().size());

MarshallerWrapper marshallerWrapper = AbstractDTTLevel.createWrapper();
System.out.println(marshallerWrapper.marshall(rcvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(marshallerWrapper.marshall(prvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(MarshallerWrapper.marshall(rcvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(MarshallerWrapper.marshall(prvDttAdapter.getParentAdapter().getCurrentElem()));
}

@Test
Expand All @@ -375,9 +373,8 @@ void testImportDAType() throws Exception {

rcvDttAdapter.importDAType("IEDName",prvDttAdapter);
assertTrue(nbDAType < rcvDttAdapter.getDATypeAdapters().size());
MarshallerWrapper marshallerWrapper = AbstractDTTLevel.createWrapper();
System.out.println(marshallerWrapper.marshall(prvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(marshallerWrapper.marshall(rcvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(MarshallerWrapper.marshall(prvDttAdapter.getParentAdapter().getCurrentElem()));
System.out.println(MarshallerWrapper.marshall(rcvDttAdapter.getParentAdapter().getCurrentElem()));
}

@ParameterizedTest
Expand Down
Loading

0 comments on commit 5407cda

Please sign in to comment.