From cefbcca32311c3a3821deaf27ff3a135e08a5b71 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Mon, 8 Jan 2024 13:30:34 +0100 Subject: [PATCH 1/5] Fixing `CsvSystemParticipantSourceTest` --- .../io/source/csv/CsvRawGridSourceTest.groovy | 9 +- .../csv/CsvSystemParticipantSourceTest.groovy | 282 ++++++++++++++---- 2 files changed, 219 insertions(+), 72 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy index 5049b4bb7..039333f66 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy @@ -171,9 +171,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { then: "everything is fine" actualSet.size() == expectedSet.size() - actualSet.every { - it.success - } + Try.scanCollection(actualSet, List).success actualSet.stream().map { it.data.get() }.toList().containsAll(expectedSet) } @@ -371,9 +369,8 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { then: "everything is fine" actualSet.size() == expectedSet.size() - actualSet.every { - it.success - } + Try.scanCollection(actualSet, List).success + actualSet.stream().map { it.data.get() }.toList().containsAll(expectedSet) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy index 4881b9212..47d16e306 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy @@ -197,12 +197,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(nodes as Set, operators as Set, types as Set, thermalBuses as Set), SourceException) - if (heatPumps.success) { - heatPumps.data.get().size() == resultingSize - heatPumps.data.get() == resultingSet as Set - } else { - heatPumps.exception.get().class == SourceException - } + heatPumps.success + heatPumps.data.get().size() == resultingSize + heatPumps.data.get() == resultingSet as Set where: nodes | operators | types | thermalBuses || resultingSize || resultingSet @@ -210,12 +207,31 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.hpInput.node] | [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 || [ new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from an invalid heat pump input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(nodes as Set, operators as Set, types as Set, thermalBuses as Set), SourceException) + + heatPumps.failure + heatPumps.exception.get().class == SourceException + + where: + nodes | operators | types | thermalBuses || resultingSize || resultingSet [] | [] | [] | [] || 0 || [] [sptd.hpInput.node] | [] | [] | [] || 0 || [] [sptd.hpInput.node] | [sptd.hpInput.operator] | [] | [] || 0 || [] [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 || [] } + def "A SystemParticipantSource with csv input should return data from a valid chp input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( @@ -227,12 +243,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(nodes as Set, operators as Set, types as Set, thermalBuses as Set, thermalStorages as Set), SourceException) - if (chpUnits.success) { - chpUnits.data.get().size() == resultingSize - chpUnits.data.get() == resultingSet as Set - } else { - chpUnits.exception.get().class == SourceException - } + chpUnits.success + chpUnits.data.get().size() == resultingSize + chpUnits.data.get() == resultingSet as Set where: nodes | operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet @@ -244,6 +257,25 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat ] as List || 1 || [ new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from a invalid chp input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(nodes as Set, operators as Set, types as Set, thermalBuses as Set, thermalStorages as Set), SourceException) + + chpUnits.failure + chpUnits.exception.get().class == SourceException + + + where: + nodes | operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet [] | [] | [] | [] | [] as List || 0 || [] [sptd.chpInput.node] | [] | [] | [] | [] as List || 0 || [] [sptd.chpInput.node] | [sptd.chpInput.operator] | [] | [] | [] as List || 0 || [] @@ -261,12 +293,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(nodes as Set, operators as Set, types as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators | types || resultingSize || resultingSet @@ -274,6 +303,25 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.evInput.node] | [] | [sptd.evInput.type] || 1 || [ new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid ev input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(nodes as Set, operators as Set, types as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + + where: + nodes | operators | types || resultingSize || resultingSet [sptd.evInput.node] | [sptd.evInput.operator] | [] || 0 || [] [sptd.evInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -290,12 +338,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(nodes as Set, operators as Set, types as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators | types || resultingSize || resultingSet @@ -303,6 +348,24 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.wecInput.node] | [] | [sptd.wecInput.type] || 1 || [ new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid wec input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(nodes as Set, operators as Set, types as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + where: + nodes | operators | types || resultingSize || resultingSet [sptd.wecInput.node] | [sptd.wecInput.operator] | [] || 0 || [] [sptd.wecInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -319,12 +382,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(nodes as Set, operators as Set, types as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators | types || resultingSize || resultingSet @@ -332,6 +392,24 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.storageInput.node] | [] | [sptd.storageInput.type] || 1 || [ new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid storage input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(nodes as Set, operators as Set, types as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + where: + nodes | operators | types || resultingSize || resultingSet [sptd.storageInput.node] | [sptd.storageInput.operator] | [] || 0 || [] [sptd.storageInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -348,12 +426,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(nodes as Set, operators as Set, types as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators | types || resultingSize || resultingSet @@ -361,6 +436,24 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.bmInput.node] | [] | [sptd.bmInput.type] || 1 || [ new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid bm input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(nodes as Set, operators as Set, types as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + where: + nodes | operators | types || resultingSize || resultingSet [sptd.bmInput.node] | [sptd.bmInput.operator] | [] || 0 || [] [sptd.bmInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -377,12 +470,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getEvCS(nodes as Set, operators as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators || resultingSize || resultingSet @@ -390,6 +480,24 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.evcsInput.node] | [] || 1 || [ new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid ev charging station input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getEvCS(nodes as Set, operators as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + where: + nodes | operators || resultingSize || resultingSet []| [sptd.evcsInput.operator]|| 0 || [] []| []|| 0 || [] } @@ -405,12 +513,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(nodes as Set, operators as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators || resultingSize || resultingSet @@ -418,6 +523,25 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.loadInput.node] | [] || 1 || [ new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid load input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(nodes as Set, operators as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + + where: + nodes | operators || resultingSize || resultingSet [] | [sptd.loadInput.operator] || 0 || [] [] | [] || 0 || [] } @@ -433,12 +557,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(nodes as Set, operators as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators || resultingSize || resultingSet @@ -446,6 +567,24 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat [sptd.pvInput.node] | [] || 1 || [ new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated) ] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid pv input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(nodes as Set, operators as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + where: + nodes | operators || resultingSize || resultingSet [] | [sptd.pvInput.operator] || 0 || [] [] | [] || 0 || [] } @@ -461,24 +600,35 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat expect: def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(nodes as Set, operators as Set), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.success + sysParts.data.get().size() == resultingSize + sysParts.data.get() == resultingSet as Set where: nodes | operators || resultingSize || resultingSet - [sptd.fixedFeedInInput.node] | [ - sptd.fixedFeedInInput.operator - ] as List || 1 || [sptd.fixedFeedInInput] + [sptd.fixedFeedInInput.node] | [sptd.fixedFeedInInput.operator] as List || 1 || [sptd.fixedFeedInInput] [sptd.fixedFeedInInput.node] | [] as List || 1 || [ new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated) ] - [] | [ - sptd.fixedFeedInInput.operator - ] as List || 0 || [] + } + + def "A SystemParticipantSource with csv input should throw an exception from invalid fixedFeedIn input file as expected"() { + given: + def csvSystemParticipantSource = new SystemParticipantSource( + Mock(TypeSource), + Mock(ThermalSource), + Mock(RawGridSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + expect: + def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(nodes as Set, operators as Set), SourceException) + + sysParts.failure + sysParts.exception.get().class == SourceException + + where: + nodes | operators || resultingSize || resultingSet + [] | [sptd.fixedFeedInInput.operator] as List || 0 || [] [] | [] as List || 0 || [] } } From 370ef591b7e0b42c3d2dd5f97b2b219efd9fde13 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Mon, 8 Jan 2024 13:34:03 +0100 Subject: [PATCH 2/5] Adding info to `CHANGELOG`. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e98c95091..c0c208d4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed Couchbase integration tests that randomly failed [#755](https://github.com/ie3-institute/PowerSystemDataModel/issues/755) - Fixed hyperlink in line documentation [#965](https://github.com/ie3-institute/PowerSystemDataModel/issues/965) +- Fixed some tests no failing when they should [#958](https://github.com/ie3-institute/PowerSystemDataModel/issues/958) ### Changed - Changing from comparing strings to comparing uuids in `EntitySource.findFirstEntityByUuid` [#829](https://github.com/ie3-institute/PowerSystemDataModel/issues/829) From 1f72b4442ca0f2078f02750641de1b0bd115eb9f Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 18 Jan 2024 13:52:31 +0100 Subject: [PATCH 3/5] Adapting `CsvSystemParticipantSourceTest`. --- .../csv/CsvSystemParticipantSourceTest.groovy | 104 +++++++++--------- 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy index b2bcff625..bfa64b7a6 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy @@ -99,9 +99,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types | thermalBuses || resultingSize | resultingSet [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [sptd.hpInput] - [sptd.hpInput.node] | [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [ - new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type) - ] } def "A SystemParticipantSource with csv input should throw an exception from an invalid heat pump input file as expected"() { @@ -111,19 +108,23 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.hpInput.node]) expect: - def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(nodes as Set, operators as Set, types as Set, thermalBuses as Set), SourceException) + def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(map(operators), nodeMap, map(types), map(thermalBuses)), SourceException) heatPumps.failure heatPumps.exception.get().class == SourceException where: - nodes | operators | types | thermalBuses || resultingSize || resultingSet - [] | [] | [] | [] || 0 || [] - [sptd.hpInput.node] | [] | [] | [] || 0 || [] - [sptd.hpInput.node] | [sptd.hpInput.operator] | [] | [] || 0 || [] - [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 || [] + nodes | operators | types | thermalBuses | resultingSize || resultingSet + [sptd.hpInput.node] | [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [ + new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type) + ] + [] | [] | [] | [] || 0 | [] + [sptd.hpInput.node] | [] | [] | [] || 0 | [] + [sptd.hpInput.node] | [sptd.hpInput.operator] | [] | [] || 0 | [] + [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 | [] } def "A SystemParticipantSource with csv input should return data from a valid chp input file as expected"() { @@ -145,9 +146,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet [sptd.chpInput.operator] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || 1 || [sptd.chpInput] - [] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || 1 || [ - new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction) - ] } def "A SystemParticipantSource with csv input should throw an exception from a invalid chp input file as expected"() { @@ -157,20 +155,23 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.hpInput.node]) expect: - def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(nodes as Set, operators as Set, types as Set, thermalBuses as Set, thermalStorages as Set), SourceException) + def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(map(operators), nodeMap, map(types), map(thermalBuses), map(thermalStorages)), SourceException) chpUnits.failure chpUnits.exception.get().class == SourceException - where: - nodes | operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet - [] | [] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.node] | [] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.node] | [sptd.chpInput.operator] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.node] | [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || 0 || [] + operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet + [] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || 1 || [ + new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction) + ] + [] | [] | [] | [] as List || 0 || [] + [] | [] | [] | [] as List || 0 || [] + [sptd.chpInput.operator] | [] | [] | [] as List || 0 || [] + [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || 0 || [] } def "A SystemParticipantSource with csv input should return data from valid ev input file as expected"() { @@ -191,9 +192,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.evInput.node] | [sptd.evInput.operator] | [sptd.evInput.type] || 1 || [sptd.evInput] - [sptd.evInput.node] | [] | [sptd.evInput.type] || 1 || [ - new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type) - ] } def "A SystemParticipantSource with csv input should throw an exception from invalid ev input file as expected"() { @@ -205,7 +203,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(nodes as Set, operators as Set, types as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(map(operators), map(nodes), map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException @@ -213,6 +211,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet + [sptd.evInput.node] | [] | [sptd.evInput.type] || 1 || [ + new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type) + ] [sptd.evInput.node] | [sptd.evInput.operator] | [] || 0 || [] [sptd.evInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -236,9 +237,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.wecInput.node] | [sptd.wecInput.operator] | [sptd.wecInput.type] || 1 || [sptd.wecInput] - [sptd.wecInput.node] | [] | [sptd.wecInput.type] || 1 || [ - new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction) - ] } def "A SystemParticipantSource with csv input should throw an exception from invalid wec input file as expected"() { @@ -250,13 +248,16 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(nodes as Set, operators as Set, types as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(map(operators), map(nodes), map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: nodes | operators | types || resultingSize || resultingSet + [sptd.wecInput.node] | [] | [sptd.wecInput.type] || 1 || [ + new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction) + ] [sptd.wecInput.node] | [sptd.wecInput.operator] | [] || 0 || [] [sptd.wecInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -280,9 +281,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.storageInput.node] | [sptd.storageInput.operator] | [sptd.storageInput.type] || 1 || [sptd.storageInput] - [sptd.storageInput.node] | [] | [sptd.storageInput.type] || 1 || [ - new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type) - ] } def "A SystemParticipantSource with csv input should throw an exception from invalid storage input file as expected"() { @@ -294,13 +292,16 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(nodes as Set, operators as Set, types as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(map(operators), map(nodes), map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: nodes | operators | types || resultingSize || resultingSet + [sptd.storageInput.node] | [] | [sptd.storageInput.type] || 1 || [ + new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type) + ] [sptd.storageInput.node] | [sptd.storageInput.operator] | [] || 0 || [] [sptd.storageInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -324,9 +325,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.bmInput.node] | [sptd.bmInput.operator] | [sptd.bmInput.type] || 1 || [sptd.bmInput] - [sptd.bmInput.node] | [] | [sptd.bmInput.type] || 1 || [ - new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff) - ] + } def "A SystemParticipantSource with csv input should throw an exception from invalid bm input file as expected"() { @@ -338,13 +337,16 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(nodes as Set, operators as Set, types as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(map(operators), map(nodes), map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: nodes | operators | types || resultingSize || resultingSet + [sptd.bmInput.node] | [] | [sptd.bmInput.type] || 1 || [ + new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff) + ] [sptd.bmInput.node] | [sptd.bmInput.operator] | [] || 0 || [] [sptd.bmInput.node] | [] | [] || 0 || [] [] | [] | [] || 0 || [] @@ -368,9 +370,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.evcsInput.node] | [sptd.evcsInput.operator] || 1 || [sptd.evcsInput] - [sptd.evcsInput.node] | [] || 1 || [ - new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport) - ] } def "A SystemParticipantSource with csv input should throw an exception from invalid ev charging station input file as expected"() { @@ -382,13 +381,16 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEvCS(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getEvcs(map(operators), map(nodes)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: nodes | operators || resultingSize || resultingSet + [sptd.evcsInput.node] | [] || 1 || [ + new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport) + ] []| [sptd.evcsInput.operator]|| 0 || [] []| []|| 0 || [] } @@ -411,9 +413,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.loadInput.node] | [sptd.loadInput.operator] || 1 || [sptd.loadInput] - [sptd.loadInput.node] | [] || 1 || [ - new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated) - ] } def "A SystemParticipantSource with csv input should throw an exception from invalid load input file as expected"() { @@ -425,7 +424,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(map(operators), map(nodes)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException @@ -433,6 +432,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet + [sptd.loadInput.node] | [] || 1 || [ + new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated) + ] [] | [sptd.loadInput.operator] || 0 || [] [] | [] || 0 || [] } @@ -455,9 +457,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.pvInput.node] | [sptd.pvInput.operator] || 1 || [sptd.pvInput] - [sptd.pvInput.node] | [] || 1 || [ - new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated) - ] } def "A SystemParticipantSource with csv input should throw an exception from invalid pv input file as expected"() { @@ -469,13 +468,16 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(map(operators), map(nodes)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: nodes | operators || resultingSize || resultingSet + [sptd.pvInput.node] | [] || 1 || [ + new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated) + ] [] | [sptd.pvInput.operator] || 0 || [] [] | [] || 0 || [] } @@ -498,9 +500,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.fixedFeedInInput.node] | [sptd.fixedFeedInInput.operator] as List || 1 || [sptd.fixedFeedInInput] - [sptd.fixedFeedInInput.node] | [] as List || 1 || [ - new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated) - ] } def "A SystemParticipantSource with csv input should throw an exception from invalid fixedFeedIn input file as expected"() { @@ -512,13 +511,16 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(map(operators), map(nodes)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: nodes | operators || resultingSize || resultingSet + [sptd.fixedFeedInInput.node] | [] as List || 1 || [ + new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated) + ] [] | [sptd.fixedFeedInInput.operator] as List || 0 || [] [] | [] as List || 0 || [] } From 49e9686c012167337375439e7cbbaf94f856f53e Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Thu, 18 Jan 2024 14:25:08 +0100 Subject: [PATCH 4/5] fmt --- .../csv/CsvSystemParticipantSourceTest.groovy | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy index bfa64b7a6..d1a233813 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy @@ -119,7 +119,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types | thermalBuses | resultingSize || resultingSet [sptd.hpInput.node] | [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [ - new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type) + new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type) ] [] | [] | [] | [] || 0 | [] [sptd.hpInput.node] | [] | [] | [] || 0 | [] @@ -166,7 +166,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet [] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || 1 || [ - new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction) + new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction) ] [] | [] | [] | [] as List || 0 || [] [] | [] | [] | [] as List || 0 || [] @@ -212,7 +212,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.evInput.node] | [] | [sptd.evInput.type] || 1 || [ - new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type) + new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type) ] [sptd.evInput.node] | [sptd.evInput.operator] | [] || 0 || [] [sptd.evInput.node] | [] | [] || 0 || [] @@ -256,7 +256,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.wecInput.node] | [] | [sptd.wecInput.type] || 1 || [ - new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction) + new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction) ] [sptd.wecInput.node] | [sptd.wecInput.operator] | [] || 0 || [] [sptd.wecInput.node] | [] | [] || 0 || [] @@ -300,7 +300,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.storageInput.node] | [] | [sptd.storageInput.type] || 1 || [ - new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type) + new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type) ] [sptd.storageInput.node] | [sptd.storageInput.operator] | [] || 0 || [] [sptd.storageInput.node] | [] | [] || 0 || [] @@ -325,7 +325,6 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.bmInput.node] | [sptd.bmInput.operator] | [sptd.bmInput.type] || 1 || [sptd.bmInput] - } def "A SystemParticipantSource with csv input should throw an exception from invalid bm input file as expected"() { @@ -345,7 +344,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators | types || resultingSize || resultingSet [sptd.bmInput.node] | [] | [sptd.bmInput.type] || 1 || [ - new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff) + new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff) ] [sptd.bmInput.node] | [sptd.bmInput.operator] | [] || 0 || [] [sptd.bmInput.node] | [] | [] || 0 || [] @@ -389,10 +388,10 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.evcsInput.node] | [] || 1 || [ - new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport) + new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport) ] - []| [sptd.evcsInput.operator]|| 0 || [] - []| []|| 0 || [] + [] | [sptd.evcsInput.operator] || 0 || [] + [] | [] || 0 || [] } def "A SystemParticipantSource with csv input should return data from valid load input file as expected"() { @@ -433,7 +432,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.loadInput.node] | [] || 1 || [ - new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated) + new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated) ] [] | [sptd.loadInput.operator] || 0 || [] [] | [] || 0 || [] @@ -476,7 +475,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.pvInput.node] | [] || 1 || [ - new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated) + new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated) ] [] | [sptd.pvInput.operator] || 0 || [] [] | [] || 0 || [] @@ -519,7 +518,7 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat where: nodes | operators || resultingSize || resultingSet [sptd.fixedFeedInInput.node] | [] as List || 1 || [ - new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated) + new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated) ] [] | [sptd.fixedFeedInInput.operator] as List || 0 || [] [] | [] as List || 0 || [] From 18f7ad528a9d4ae92bacee51c911f8c3c528fe04 Mon Sep 17 00:00:00 2001 From: staudtMarius Date: Mon, 22 Jan 2024 17:25:46 +0100 Subject: [PATCH 5/5] Implementing requested changes. --- .../io/source/csv/CsvRawGridSourceTest.groovy | 14 +- .../csv/CsvSystemParticipantSourceTest.groovy | 363 +++++------------- 2 files changed, 103 insertions(+), 274 deletions(-) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy index a666895d0..876b73160 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy @@ -175,11 +175,10 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { then: "everything is fine" actualSet.size() == expectedSet.size() - Try.scanCollection(actualSet, List).success + def result = Try.scanCollection(actualSet, List) - actualSet.stream().map { - it.data.get() - }.toList().containsAll(expectedSet) + result.success + result.data.get().toList().containsAll(expectedSet) } def "The CsvRawGridSource is able to convert a stream of valid ConnectorInputEntityData to TypedConnectorInputEntityData"() { @@ -258,11 +257,10 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { then: "everything is fine" actualSet.size() == expectedSet.size() - Try.scanCollection(actualSet, List).success + def result = Try.scanCollection(actualSet, List) - actualSet.stream().map { - it.data.get() - }.toList().containsAll(expectedSet) + result.success + result.data.get().toList().containsAll(expectedSet) } def "The CsvRawGridSource is able to add the third node for a three winding transformer to a stream of candidates"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy index d1a233813..6d409422e 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy @@ -80,118 +80,106 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat "Linked node with UUID 4ca90220-74c2-4369-9afa-a18bf068840d was not found for entity AssetInputEntityData") } - def "A SystemParticipantSource with csv input should return data from a valid heat pump input file as expected"() { + def "A SystemParticipantSource with csv input should return data from valid input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - def nodeMap = map([sptd.hpInput.node]) + def nodeMap = map([sptd.participantNode]) + def operatorMap = map([sptd.operator]) + def thermalBusMap = map([sptd.thermalBus]) + def thermalStorageMap = map([sptd.thermalStorage]) expect: - def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(map(operators), nodeMap, map(types), map(thermalBuses)), SourceException) - + def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(operatorMap, nodeMap, map([sptd.hpTypeInput]), thermalBusMap), SourceException) heatPumps.success - heatPumps.data.get().size() == resultingSize - heatPumps.data.get() == resultingSet as Set + heatPumps.data.get() == [sptd.hpInput] as Set - where: - nodes | operators | types | thermalBuses || resultingSize | resultingSet - [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [sptd.hpInput] - } + def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(operatorMap, nodeMap, map([sptd.chpTypeInput]), thermalBusMap, thermalStorageMap), SourceException) + chpUnits.success + chpUnits.data.get() == [sptd.chpInput] as Set - def "A SystemParticipantSource with csv input should throw an exception from an invalid heat pump input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - def nodeMap = map([sptd.hpInput.node]) + def evs = Try.of(() -> csvSystemParticipantSource.getEvs(operatorMap, nodeMap, map([sptd.evTypeInput])), SourceException) + evs.success + evs.data.get() == [sptd.evInput] as Set - expect: - def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(map(operators), nodeMap, map(types), map(thermalBuses)), SourceException) + def wecs = Try.of(() -> csvSystemParticipantSource.getWecPlants(operatorMap, nodeMap, map([sptd.wecType])), SourceException) + wecs.success + wecs.data.get() == [sptd.wecInput] as Set - heatPumps.failure - heatPumps.exception.get().class == SourceException + def storages = Try.of(() -> csvSystemParticipantSource.getStorages(operatorMap, nodeMap, map([sptd.storageTypeInput])), SourceException) + storages.success + storages.data.get() == [sptd.storageInput] as Set - where: - nodes | operators | types | thermalBuses | resultingSize || resultingSet - [sptd.hpInput.node] | [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [ - new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type) - ] - [] | [] | [] | [] || 0 | [] - [sptd.hpInput.node] | [] | [] | [] || 0 | [] - [sptd.hpInput.node] | [sptd.hpInput.operator] | [] | [] || 0 | [] - [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 | [] - } + def bms = Try.of(() -> csvSystemParticipantSource.getBmPlants(operatorMap, nodeMap, map([sptd.bmTypeInput])), SourceException) + bms.success + bms.data.get() == [sptd.bmInput] as Set - def "A SystemParticipantSource with csv input should return data from a valid chp input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - def nodeMap = map([sptd.hpInput.node]) + def evcs = Try.of(() -> csvSystemParticipantSource.getEvcs(operatorMap, nodeMap), SourceException) + evcs.success + evcs.data.get() == [sptd.evcsInput] as Set - expect: - def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(map(operators), nodeMap, map(types), map(thermalBuses), map(thermalStorages)), SourceException) + def loads = Try.of(() -> csvSystemParticipantSource.getLoads(operatorMap, nodeMap), SourceException) + loads.success + loads.data.get() == [sptd.loadInput] as Set - chpUnits.success - chpUnits.data.get().size() == resultingSize - chpUnits.data.get() == resultingSet as Set + def pvs = Try.of(() -> csvSystemParticipantSource.getPvPlants(operatorMap, nodeMap), SourceException) + pvs.success + pvs.data.get() == [sptd.pvInput] as Set - where: - operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet - [sptd.chpInput.operator] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || 1 || [sptd.chpInput] + def fixedFeedIns = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(operatorMap, nodeMap), SourceException) + fixedFeedIns.success + fixedFeedIns.data.get() == [sptd.fixedFeedInInput] as Set } - def "A SystemParticipantSource with csv input should throw an exception from a invalid chp input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from an invalid heat pump input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - def nodeMap = map([sptd.hpInput.node]) + def nodeMap = map([sptd.participantNode]) expect: - def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(map(operators), nodeMap, map(types), map(thermalBuses), map(thermalStorages)), SourceException) + def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(map(operators), nodeMap, map(types), map(thermalBuses)), SourceException) - chpUnits.failure - chpUnits.exception.get().class == SourceException + heatPumps.failure + heatPumps.exception.get().class == SourceException where: - operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet - [] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || 1 || [ - new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction) - ] - [] | [] | [] | [] as List || 0 || [] - [] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.operator] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || 0 || [] + operators | types | thermalBuses || resultingSize | resultingSet + [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type)] + [] | [] | [] || 0 | [] + [] | [] | [] || 0 | [] + [sptd.hpInput.operator] | [] | [] || 0 | [] + [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 | [] } - def "A SystemParticipantSource with csv input should return data from valid ev input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from a invalid chp input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(map(operators), map(nodes), map(types)), SourceException) + def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(map(operators), nodeMap, map(types), map(thermalBuses), map(thermalStorages)), SourceException) - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set + chpUnits.failure + chpUnits.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.evInput.node] | [sptd.evInput.operator] | [sptd.evInput.type] || 1 || [sptd.evInput] + operators | types | thermalBuses | thermalStorages || resultingSet + [] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || [new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction)] + [] | [] | [] | [] as List || [] + [] | [] | [] | [] as List || [] + [sptd.chpInput.operator] | [] | [] | [] as List || [] + [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid ev input file as expected"() { @@ -201,42 +189,19 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(map(operators), map(nodes), map(types)), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(map(operators), nodeMap, map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException - - where: - nodes | operators | types || resultingSize || resultingSet - [sptd.evInput.node] | [] | [sptd.evInput.type] || 1 || [ - new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type) - ] - [sptd.evInput.node] | [sptd.evInput.operator] | [] || 0 || [] - [sptd.evInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] - } - - def "A SystemParticipantSource with csv input should return data from valid wec input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(map(operators), map(nodes), map(types)), SourceException) - - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - where: - nodes | operators | types || resultingSize || resultingSet - [sptd.wecInput.node] | [sptd.wecInput.operator] | [sptd.wecInput.type] || 1 || [sptd.wecInput] + operators | types || resultingSet + [] | [sptd.evInput.type] || [new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type)] + [sptd.evInput.operator] | [] || [] + [] | [] || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid wec input file as expected"() { @@ -246,41 +211,19 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(map(operators), map(nodes), map(types)), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(map(operators), nodeMap, map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.wecInput.node] | [] | [sptd.wecInput.type] || 1 || [ - new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction) - ] - [sptd.wecInput.node] | [sptd.wecInput.operator] | [] || 0 || [] - [sptd.wecInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] - } - - def "A SystemParticipantSource with csv input should return data from valid storage input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(map(operators), map(nodes), map(types)), SourceException) - - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - - where: - nodes | operators | types || resultingSize || resultingSet - [sptd.storageInput.node] | [sptd.storageInput.operator] | [sptd.storageInput.type] || 1 || [sptd.storageInput] + operators | types || resultingSet + [] | [sptd.wecInput.type] || [new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction)] + [sptd.wecInput.operator] | [] || [] + [] | [] || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid storage input file as expected"() { @@ -290,41 +233,19 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(map(operators), map(nodes), map(types)), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(map(operators), nodeMap, map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.storageInput.node] | [] | [sptd.storageInput.type] || 1 || [ - new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type) - ] - [sptd.storageInput.node] | [sptd.storageInput.operator] | [] || 0 || [] - [sptd.storageInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] - } - - def "A SystemParticipantSource with csv input should return data from valid bm input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(map(operators), map(nodes), map(types)), SourceException) - - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - - where: - nodes | operators | types || resultingSize || resultingSet - [sptd.bmInput.node] | [sptd.bmInput.operator] | [sptd.bmInput.type] || 1 || [sptd.bmInput] + operators | types || resultingSet + [] | [sptd.storageInput.type] || [new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type)] + [sptd.storageInput.operator] | [] || [] + [] | [] || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid bm input file as expected"() { @@ -334,41 +255,20 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Mock(ThermalSource), Mock(RawGridSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(map(operators), map(nodes), map(types)), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(map(operators), nodeMap, map(types)), SourceException) sysParts.failure sysParts.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.bmInput.node] | [] | [sptd.bmInput.type] || 1 || [ - new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff) - ] - [sptd.bmInput.node] | [sptd.bmInput.operator] | [] || 0 || [] - [sptd.bmInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] - } - - def "A SystemParticipantSource with csv input should return data from valid ev charging station input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEvcs(map(operators), map(nodes)), SourceException) - - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - - where: - nodes | operators || resultingSize || resultingSet - [sptd.evcsInput.node] | [sptd.evcsInput.operator] || 1 || [sptd.evcsInput] + operators | types || resultingSet + [] | [sptd.bmInput.type] || [new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff)] + [sptd.bmInput.operator] | [] || [] + [] | [] || [] + [] | [] || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid ev charging station input file as expected"() { @@ -386,32 +286,10 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.evcsInput.node] | [] || 1 || [ - new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport) - ] - [] | [sptd.evcsInput.operator] || 0 || [] - [] | [] || 0 || [] - } - - def "A SystemParticipantSource with csv input should return data from valid load input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(map(operators), map(nodes)), SourceException) - - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - - where: - nodes | operators || resultingSize || resultingSet - [sptd.loadInput.node] | [sptd.loadInput.operator] || 1 || [sptd.loadInput] + nodes | operators || resultingSet + [sptd.evcsInput.node] | [] || [new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport)] + [] | [sptd.evcsInput.operator] || [] + [] | [] || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid load input file as expected"() { @@ -428,34 +306,11 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat sysParts.failure sysParts.exception.get().class == SourceException - - where: - nodes | operators || resultingSize || resultingSet - [sptd.loadInput.node] | [] || 1 || [ - new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated) - ] - [] | [sptd.loadInput.operator] || 0 || [] - [] | [] || 0 || [] - } - - def "A SystemParticipantSource with csv input should return data from valid pv input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(map(operators), map(nodes)), SourceException) - - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - where: - nodes | operators || resultingSize || resultingSet - [sptd.pvInput.node] | [sptd.pvInput.operator] || 1 || [sptd.pvInput] + nodes | operators || resultingSet + [sptd.loadInput.node] | [] || [new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated)] + [] | [sptd.loadInput.operator] || [] + [] | [] || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid pv input file as expected"() { @@ -473,32 +328,10 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.pvInput.node] | [] || 1 || [ - new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated) - ] - [] | [sptd.pvInput.operator] || 0 || [] - [] | [] || 0 || [] - } - - def "A SystemParticipantSource with csv input should return data from valid fixedFeedIn input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(map(operators), map(nodes)), SourceException) - - sysParts.success - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - - where: - nodes | operators || resultingSize || resultingSet - [sptd.fixedFeedInInput.node] | [sptd.fixedFeedInInput.operator] as List || 1 || [sptd.fixedFeedInInput] + nodes | operators || resultingSet + [sptd.pvInput.node] | [] || [new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated)] + [] | [sptd.pvInput.operator] || [] + [] | [] || [] } def "A SystemParticipantSource with csv input should throw an exception from invalid fixedFeedIn input file as expected"() { @@ -516,11 +349,9 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.fixedFeedInInput.node] | [] as List || 1 || [ - new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated) - ] - [] | [sptd.fixedFeedInInput.operator] as List || 0 || [] - [] | [] as List || 0 || [] + nodes | operators || resultingSet + [sptd.fixedFeedInInput.node] | [] as List || [new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated)] + [] | [sptd.fixedFeedInInput.operator] as List || [] + [] | [] as List || [] } }