Skip to content

Commit 93ea330

Browse files
authored
Merge branch 'dev' into ms/#1294-enhancing-load-profile-source
2 parents 60493eb + 66f5a93 commit 93ea330

File tree

6 files changed

+172
-21
lines changed

6 files changed

+172
-21
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ jobs:
3030
with:
3131
fetch-depth: 0
3232

33+
- name: Setup Java
34+
uses: actions/setup-java@v4
35+
with:
36+
distribution: 'temurin'
37+
java-version: 17
38+
3339
- name: Setup Gradle
3440
uses: gradle/actions/setup-gradle@v4
3541

@@ -59,12 +65,6 @@ jobs:
5965
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
6066
run: bash scripts/run-version-check.sh
6167

62-
- name: Setup Java
63-
uses: actions/setup-java@v4
64-
with:
65-
distribution: 'temurin'
66-
java-version: 17
67-
6868
- name: Build Project
6969
run: ./gradlew --refresh-dependencies clean assemble spotlessCheck
7070

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ie3-institute/PowerSystemDataModel'
12+
steps:
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
16+
with:
17+
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
19+
- name: Enable auto-merge for Dependabot PRs
20+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
21+
run: gh pr merge --auto --merge "$PR_URL"
22+
env:
23+
PR_URL: ${{ github.event.pull_request.html_url }}
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Implemented GitHub Actions for automatic code integration. [#1237](https://github.com/ie3-institute/PowerSystemDataModel/issues/1237)
1111
- Added `CopyBuilders` to `Line-/Transformer2W-/Tranformer3WTypeInput` [#1275](https://github.com/ie3-institute/PowerSystemDataModel/issues/1275)
12+
- Implementing auto-merge for dependabot PRs [#1299](https://github.com/ie3-institute/PowerSystemDataModel/issues/1299)
1213

1314
### Fixed
1415
- Fixed SonarQube junit path issue in GitHub Actions [#1284](https://github.com/ie3-institute/PowerSystemDataModel/issues/1284)
16+
- Fixed no errors thrown in `getMapping()` in `TimeSeriesMappingSource` [#1287](https://github.com/ie3-institute/PowerSystemDataModel/issues/1287)
17+
1518
### Changed
1619
- Replaced `return this` with `return thisInstance` in CopyBuilders [#1250](https://github.com/ie3-institute/PowerSystemDataModel/issues/1250)
1720
- Enhancing load profile source [#1294](https://github.com/ie3-institute/PowerSystemDataModel/issues/1294)

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'signing'
66
id 'pmd' // code check, working on source code
77
id 'com.diffplug.spotless' version '7.0.2' //code format
8-
id 'com.github.spotbugs' version '6.1.7' // code check, working on byte code
8+
id 'com.github.spotbugs' version '6.1.10' // code check, working on byte code
99
id 'de.undercouch.download' version '5.6.0'
1010
id 'kr.motd.sphinx' version '2.10.1' // documentation generation
1111
id 'jacoco' // java code coverage plugin
@@ -21,7 +21,7 @@ ext {
2121
groovyBinaryVersion = "4.0.26"
2222

2323
junitVersion = '1.12.0'
24-
testcontainersVersion = '1.20.6'
24+
testcontainersVersion = '1.21.0'
2525

2626
scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
2727
}
@@ -57,7 +57,7 @@ repositories {
5757
dependencies {
5858

5959
// ie³ power system utils
60-
implementation 'com.github.ie3-institute:PowerSystemUtils:2.2.1'
60+
implementation 'com.github.ie3-institute:PowerSystemUtils:3.0.0'
6161

6262
implementation 'tech.units:indriya:2.2.2'
6363

@@ -98,10 +98,10 @@ dependencies {
9898

9999
// Databases
100100
implementation 'org.influxdb:influxdb-java:2.25'
101-
implementation 'com.couchbase.client:java-client:3.7.9'
101+
implementation 'com.couchbase.client:java-client:3.8.0'
102102
runtimeOnly 'org.postgresql:postgresql:42.7.5' // postgresql jdbc driver required during runtime
103103

104-
implementation 'commons-io:commons-io:2.18.0' // I/O functionalities
104+
implementation 'commons-io:commons-io:2.19.0' // I/O functionalities
105105
implementation 'commons-codec:commons-codec:1.18.0' // needed by commons-compress
106106
implementation 'org.apache.commons:commons-compress:1.27.1' // I/O functionalities
107107
}

src/main/java/edu/ie3/datamodel/io/source/TimeSeriesMappingSource.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
*/
66
package edu.ie3.datamodel.io.source;
77

8-
import edu.ie3.datamodel.exceptions.FactoryException;
9-
import edu.ie3.datamodel.exceptions.SourceException;
10-
import edu.ie3.datamodel.exceptions.ValidationException;
8+
import edu.ie3.datamodel.exceptions.*;
119
import edu.ie3.datamodel.io.factory.EntityData;
1210
import edu.ie3.datamodel.io.factory.timeseries.TimeSeriesMappingFactory;
1311
import edu.ie3.datamodel.models.input.InputEntity;
1412
import edu.ie3.datamodel.models.timeseries.TimeSeries;
1513
import edu.ie3.datamodel.utils.Try;
16-
import edu.ie3.datamodel.utils.Try.*;
1714
import java.util.*;
1815
import java.util.stream.Collectors;
1916
import java.util.stream.Stream;
@@ -41,12 +38,11 @@ public void validate() throws ValidationException {
4138
* @return That mapping
4239
*/
4340
public Map<UUID, UUID> getMapping() throws SourceException {
44-
return getMappingSourceData()
45-
.map(this::createMappingEntry)
46-
.filter(Try::isSuccess)
47-
.map(t -> (Success<MappingEntry, FactoryException>) t)
48-
.map(Success::get)
49-
.collect(Collectors.toMap(MappingEntry::getAsset, MappingEntry::getTimeSeries));
41+
return Try.scanStream(getMappingSourceData().map(this::createMappingEntry), "MappingEntry")
42+
.transform(
43+
s -> s.collect(Collectors.toMap(MappingEntry::getAsset, MappingEntry::getTimeSeries)),
44+
SourceException::new)
45+
.getOrThrow();
5046
}
5147

5248
/**
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* © 2025. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
package edu.ie3.datamodel.io.source
7+
8+
import edu.ie3.datamodel.exceptions.FactoryException
9+
import edu.ie3.datamodel.exceptions.FailureException
10+
import edu.ie3.datamodel.exceptions.SourceException
11+
import spock.lang.Shared
12+
import spock.lang.Specification
13+
14+
import java.util.stream.Stream
15+
import javax.xml.transform.Source
16+
17+
class TimeSeriesMappingSourceTest extends Specification {
18+
19+
@Shared
20+
MixedMappingSource validSource
21+
22+
def setupSpec() {
23+
validSource = new MixedMappingSource(true, true)
24+
}
25+
26+
class MixedMappingSource extends TimeSeriesMappingSource {
27+
28+
private boolean validAsset
29+
private boolean validTimeSeries
30+
31+
MixedMappingSource(boolean validAsset, boolean validTimeSeries) {
32+
this.validAsset = validAsset
33+
this.validTimeSeries = validTimeSeries
34+
}
35+
36+
@Override
37+
Stream<Map<String, String>> getMappingSourceData() throws SourceException {
38+
switch (getCase()){
39+
case "VALID":
40+
return Stream.of(
41+
Map.of("asset", "b86e95b0-e579-4a80-a534-37c7a470a409", "timeSeries", "9185b8c1-86ba-4a16-8dea-5ac898e8caa5")
42+
)
43+
case "INVALID_ASSET":
44+
return Stream.of(
45+
Map.of("asset", "invalidAsset", "timeSeries", "3fbfaa97-cff4-46d4-95ba-a95665e87c26"),
46+
Map.of("asset", "c7ebcc6c-55fc-479b-aa6b-6fa82ccac6b8", "timeSeries", "3fbfaa97-cff4-46d4-95ba-a95665e87c26")
47+
)
48+
case "INVALID_TIMESERIES":
49+
return Stream.of(
50+
Map.of("asset", "90a96daa-012b-4fea-82dc-24ba7a7ab81c", "timeSeries", "invalidTimeSeries"),
51+
Map.of("asset","90a96daa-012b-4fea-82dc-24ba7a7ab81c","timeSeries","3fbfaa97-cff4-46d4-95ba-a95665e87c26")
52+
)
53+
case "INVALID_ALL":
54+
return Stream.of(
55+
Map.of("asset", "invalidAsset", "timeSeries", "invalidTimeSeries"),
56+
Map.of("asset", "invalidAsset2", "timeSeries", "invalidTimeSeries2")
57+
)
58+
}
59+
}
60+
61+
private String getCase() {
62+
if (validAsset && validTimeSeries) {
63+
return "VALID"
64+
} else if (!validAsset && validTimeSeries) {
65+
return "INVALID_ASSET"
66+
} else if (validAsset && !validTimeSeries) {
67+
return "INVALID_TIMESERIES"
68+
} else if (!validAsset && !validTimeSeries) {
69+
return "INVALID_ALL"
70+
}
71+
}
72+
73+
@Override
74+
Optional<Set<String>> getSourceFields() throws SourceException {
75+
return Optional.of(Set.of("asset", "timeSeries"))
76+
}
77+
}
78+
79+
80+
81+
def "valid mapping entries should correctly be processed"(){
82+
given: "dummy mapping source with valid data"
83+
84+
when:
85+
def actualMapping = validSource.getMapping()
86+
87+
then:
88+
actualMapping.size() == 1
89+
actualMapping.containsKey(UUID.fromString("b86e95b0-e579-4a80-a534-37c7a470a409"))
90+
actualMapping.get(UUID.fromString("b86e95b0-e579-4a80-a534-37c7a470a409")) == UUID.fromString("9185b8c1-86ba-4a16-8dea-5ac898e8caa5")
91+
}
92+
93+
def "should throw SourceException for invalid asset"(){
94+
given: "DummyMappingSource"
95+
validSource = new MixedMappingSource(false, true)
96+
when:
97+
validSource.getMapping()
98+
99+
then:
100+
def ex = thrown(SourceException)
101+
ex.cause.class == FailureException
102+
ex.cause.message.startsWith("1 exception(s) occurred within \"MappingEntry\" data")
103+
}
104+
105+
def "should throw SourceException for invalid timeSeries"(){
106+
given: "DummyMappingSource"
107+
validSource = new MixedMappingSource(true, false)
108+
when:
109+
validSource.getMapping()
110+
111+
then:
112+
def ex = thrown(SourceException)
113+
ex.cause.class == FailureException
114+
ex.cause.message.startsWith("1 exception(s) occurred within \"MappingEntry\" data")
115+
}
116+
117+
def "should throw SourceException for invalid timeSeries and asset"(){
118+
given: "DummyMappingSource"
119+
validSource = new MixedMappingSource(false, false)
120+
when:
121+
validSource.getMapping()
122+
123+
then:
124+
def ex = thrown(SourceException)
125+
ex.cause.class == FailureException
126+
ex.cause.message.startsWith("2 exception(s) occurred within \"MappingEntry\" data")
127+
}
128+
}

0 commit comments

Comments
 (0)