Skip to content

Commit

Permalink
Merge pull request #89 from com-pas/develop
Browse files Browse the repository at this point in the history
Create new release
  • Loading branch information
Dennis Labordus authored Dec 14, 2021
2 parents 6f01ba8 + 31e04fd commit b1dc75d
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 105 deletions.
35 changes: 21 additions & 14 deletions .github/workflows/build-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

name: Build Project

on: push
on:
push:
branches:
- '**'
pull_request:
branches:
- 'main'
- 'develop'

jobs:
build:
Expand All @@ -13,16 +20,16 @@ jobs:
timeout-minutes: 15

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.11
uses: actions/setup-java@v2.3.1
with:
distribution: 'zulu'
java-version: '11'
- name: Create custom Maven Settings.xml
uses: whelk-io/maven-settings-xml-action@v20
with:
output_file: custom_maven_settings.xml
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
- name: Build with Maven
run: ./mvnw -s custom_maven_settings.xml -B clean verify
- uses: actions/checkout@v2
- name: Set up JDK 1.11
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '11'
- name: Create custom Maven Settings.xml
uses: whelk-io/maven-settings-xml-action@v20
with:
output_file: custom_maven_settings.xml
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
- name: Build with Maven
run: ./mvnw -s custom_maven_settings.xml -B clean verify
2 changes: 1 addition & 1 deletion .github/workflows/release-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
- name: Set up JDK 1.11
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '11'
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/sonarcloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

name: SonarCloud Analysis

on: push
on:
push:
branches:
- '**'
pull_request:
branches:
- 'main'
- 'develop'

jobs:
build:
Expand All @@ -15,18 +22,18 @@ jobs:
with:
fetch-depth: 0
- name: Set up JDK 1.11
uses: actions/setup-java@v2.3.1
uses: actions/setup-java@v2.4.0
with:
distribution: 'zulu'
java-version: '11'
- name: Cache SonarCloud packages
uses: actions/cache@v2.1.6
uses: actions/cache@v2.1.7
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Maven packages
uses: actions/cache@v2.1.6
uses: actions/cache@v2.1.7
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ SPDX-License-Identifier: Apache-2.0
<slf4j.version>1.7.32</slf4j.version>
<jackson.version>2.13.0</jackson.version>
<jaxb.bind.version>2.3.3</jaxb.bind.version>
<junit.jupiter.version>5.8.1</junit.jupiter.version>
<mockito-junit-jupiter.version>4.0.0</mockito-junit-jupiter.version>
<junit.jupiter.version>5.8.2</junit.jupiter.version>
<mockito-junit-jupiter.version>4.1.0</mockito-junit-jupiter.version>
<openpojo.version>0.9.1</openpojo.version>
</properties>

Expand Down Expand Up @@ -119,7 +119,7 @@ SPDX-License-Identifier: Apache-2.0
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-core</artifactId>
<version>5.0.0.Final</version>
<version>5.0.1.Final</version>
<scope>test</scope>
</dependency>

Expand Down
4 changes: 4 additions & 0 deletions scl-extension/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ SPDX-License-Identifier: Apache-2.0
<configuration>
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
<generatePackage>org.lfenergy.compas.scl.extensions.model</generatePackage>
<bindingDirectory>${project.basedir}/src/main/bindings</bindingDirectory>
<bindingIncludes>
<include>*.xjb</include>
</bindingIncludes>
</configuration>
</plugin>
</plugins>
Expand Down
15 changes: 15 additions & 0 deletions scl-extension/src/main/bindings/scl-extensions.xjb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2021 Alliander N.V.
SPDX-License-Identifier: Apache-2.0
-->
<jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
version="2.1">
<jxb:bindings schemaLocation="../resources/xsd/SCL_CoMPAS.xsd">
<jxb:bindings node="//xs:simpleType[@name='tSclFileType']">
<jxb:typesafeEnumClass ref="org.lfenergy.compas.scl.extensions.model.SclFileType"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-FileCopyrightText: 2021 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.extensions.model;

import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;

@XmlType(name = "tSclFileType", namespace = "https://www.lfenergy.org/compas/extension/v1")
@XmlEnum
public enum SclFileType {
SSD("Substation Specification Description"),
IID("IED Instance Description"),
ICD("IED Capability Description"),
SCD("Substation Configuration Description"),
CID("Configured IED Description"),
SED("System Exchange Description"),
ISD("IED Specification Description"),
STD("System Template Definition");

private final String description;

SclFileType(String description) {
this.description = description;
}

public String getDescription() {
return description;
}
}
137 changes: 72 additions & 65 deletions scl-extension/src/main/resources/xsd/SCL_CoMPAS.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -4,69 +4,76 @@ SPDX-FileCopyrightText: 2021 Alliander N.V.
SPDX-License-Identifier: Apache-2.0
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="https://www.lfenergy.org/compas/extension/v1" targetNamespace="https://www.lfenergy.org/compas/extension/v1" elementFormDefault="qualified" attributeFormDefault="unqualified" version="v1">
<xs:annotation>
<xs:documentation xml:lang="en">
COPYRIGHT (c) 2021 Alliander N.V.
</xs:documentation>
<xs:documentation xml:lang="en">
Version 1.0 Release 2021/06/16
</xs:documentation>
</xs:annotation>
<!--
SCL Name element.
-->
<xs:simpleType name="tSclName">
<xs:annotation>
<xs:documentation>Name of the SCL configuration, extension excluded</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:normalizedString"/>
</xs:simpleType>
<xs:element name="SclName" type="tSclName"/>
<!--
SCL File Type element.
-->
<xs:simpleType name="tSclFileType">
<xs:annotation>
<xs:documentation>File type of the SCL configuration file</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:Name">
<xs:enumeration value="SSD">
<xs:annotation>
<xs:documentation>Substation Specification Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="IID">
<xs:annotation>
<xs:documentation>IED Instance Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ICD">
<xs:annotation>
<xs:documentation>IED Capability Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SCD">
<xs:annotation>
<xs:documentation>Substation Configuration Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="CID">
<xs:annotation>
<xs:documentation>Configured IED Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SED">
<xs:annotation>
<xs:documentation>System Exchange Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ISD">
<xs:annotation>
<xs:documentation>IED Specification Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:element name="SclFileType" type="tSclFileType"/>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="https://www.lfenergy.org/compas/extension/v1"
targetNamespace="https://www.lfenergy.org/compas/extension/v1" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="v1">
<xs:annotation>
<xs:documentation xml:lang="en">
COPYRIGHT (c) 2021 Alliander N.V.
</xs:documentation>
<xs:documentation xml:lang="en">
Version 1.0 Release 2021/06/16
</xs:documentation>
</xs:annotation>
<!--
SCL Name element.
-->
<xs:simpleType name="tSclName">
<xs:annotation>
<xs:documentation>Name of the SCL configuration, extension excluded</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:normalizedString"/>
</xs:simpleType>
<xs:element name="SclName" type="tSclName"/>
<!--
SCL File Type element.
-->
<xs:simpleType name="tSclFileType">
<xs:annotation>
<xs:documentation>File type of the SCL configuration file</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:Name">
<xs:enumeration value="SSD">
<xs:annotation>
<xs:documentation>Substation Specification Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="IID">
<xs:annotation>
<xs:documentation>IED Instance Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ICD">
<xs:annotation>
<xs:documentation>IED Capability Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SCD">
<xs:annotation>
<xs:documentation>Substation Configuration Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="CID">
<xs:annotation>
<xs:documentation>Configured IED Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SED">
<xs:annotation>
<xs:documentation>System Exchange Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ISD">
<xs:annotation>
<xs:documentation>IED Specification Description</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="STD">
<xs:annotation>
<xs:documentation>System Template Definition</xs:documentation>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:element name="SclFileType" type="tSclFileType"/>
</xs:schema>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2021 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.extensions.model;

import org.junit.jupiter.api.Test;

import java.lang.reflect.InvocationTargetException;

import static org.junit.jupiter.api.Assertions.assertNotNull;

abstract class AbstractEnumTest {
@Test
void testEnumCodeCoverage() {
Class<? extends Enum<?>> enumClass = getEnumClass();
try {
for (var o : (Enum<?>[]) enumClass.getMethod("values").invoke(null)) {
assertNotNull(enumClass.getMethod("valueOf", String.class).invoke(null, o.name()));
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException exp) {
throw new RuntimeException(exp);
}
}

protected abstract Class<? extends Enum<?>> getEnumClass();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: 2021 Alliander N.V.
//
// SPDX-License-Identifier: Apache-2.0
package org.lfenergy.compas.scl.extensions.model;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNotNull;

class SclFileTypeTest extends AbstractEnumTest {
@Override
protected Class<? extends Enum<?>> getEnumClass() {
return SclFileType.class;
}

@Test
void getDescription_WhenCalledForEveryType_ThenEveryTypeHasADescription() {
for (var type : SclFileType.values()) {
assertNotNull(type.getDescription());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import org.lfenergy.compas.scl.extensions.commons.AbstractCompasExtensionsManager;
import org.lfenergy.compas.scl.extensions.commons.CompasExtensionsField;
import org.lfenergy.compas.scl.extensions.model.TSclFileType;
import org.lfenergy.compas.scl.extensions.model.SclFileType;
import org.lfenergy.compas.scl2003.model.SCL;
import org.lfenergy.compas.scl2003.model.TPrivate;

Expand All @@ -31,8 +31,8 @@ public Optional<String> getCompasSclName(TPrivate compasPrivate) {
return getCompasValue(compasPrivate, SCL_NAME_EXTENSION, String.class);
}

public Optional<TSclFileType> getCompasSclFileType(TPrivate compasPrivate) {
return getCompasValue(compasPrivate, SCL_FILETYPE_EXTENSION, TSclFileType.class);
public Optional<SclFileType> getCompasSclFileType(TPrivate compasPrivate) {
return getCompasValue(compasPrivate, SCL_FILETYPE_EXTENSION, SclFileType.class);
}

private <T> Optional<T> getCompasValue(TPrivate compasPrivate, CompasExtensionsField field, Class<T> clazz) {
Expand Down
Loading

0 comments on commit b1dc75d

Please sign in to comment.