Skip to content

Commit d98a5da

Browse files
committed
Fix sonarqube issues.
1 parent d3d089d commit d98a5da

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ protected Try<LoadProfileEntry<V>, FactoryException> createEntries(
9595
* @return the resolution in seconds.
9696
*/
9797
public static long getResolution(LoadProfile loadProfile) {
98-
// currently all registered profiles and all sources use 15 minutes intervals
99-
return 900L;
98+
99+
if (loadProfile == LoadProfile.DefaultLoadProfiles.NO_LOAD_PROFILE) {
100+
// since no load profile was assigned, we return the maximal possible value
101+
return Long.MAX_VALUE;
102+
} else {
103+
// currently all registered profiles and all sources use 15 minutes intervals
104+
return 900L;
105+
}
100106
}
101107

102108
/**

src/test/groovy/edu/ie3/datamodel/io/source/LoadProfileSourceTest.groovy

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,25 @@ package edu.ie3.datamodel.io.source
88
import static edu.ie3.datamodel.models.profile.LoadProfile.RandomLoadProfile.RANDOM_LOAD_PROFILE
99

1010
import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile
11+
import edu.ie3.datamodel.models.profile.LoadProfile
1112
import spock.lang.Specification
1213

1314
class LoadProfileSourceTest extends Specification {
1415

15-
def "A LoadProfileSourceTest should read in all build-in BDEWStandardLoadProfiles"() {
16+
def "A LoadProfileSource should return the correct profile resolution for a given load profile"() {
17+
given:
18+
def allProfiles = LoadProfile.getAllProfiles()
19+
20+
21+
when:
22+
def resolutions = Arrays.stream(allProfiles).map { it -> LoadProfileSource.getResolution(it) }.toList()
23+
24+
then:
25+
resolutions.every { resolution -> resolution == 900 }
26+
}
27+
28+
29+
def "A LoadProfileSource should read in all build-in BDEWStandardLoadProfiles"() {
1630
when:
1731
def profiles = LoadProfileSource.bdewLoadProfiles
1832

@@ -22,7 +36,7 @@ class LoadProfileSourceTest extends Specification {
2236
profiles.values().every { it.timeSeries.entries.size() == 96 }
2337
}
2438

25-
def "A LoadProfileSourceTest should read in the build-in RandomLoadProfile"() {
39+
def "A LoadProfileSource should read in the build-in RandomLoadProfile"() {
2640
when:
2741
def random = LoadProfileSource.randomLoadProfile.timeSeries
2842

0 commit comments

Comments
 (0)