@@ -16,6 +16,8 @@ import spock.lang.Shared
1616import spock.lang.Specification
1717import tech.units.indriya.quantity.Quantities
1818
19+ import static edu.ie3.simona.api.mapping.DataType.*
20+
1921class ExtEntityMappingTest extends Specification {
2022 @Shared
2123 UUID loadUuid = UUID . fromString(" 22bea5fc-2cb2-4c61-beb9-b476e0107f52" )
@@ -30,36 +32,17 @@ class ExtEntityMappingTest extends Specification {
3032 UUID emUuid = UUID . fromString(" 60dbc7e4-9718-4bbd-913a-dd26925e68a3" )
3133
3234 @Shared
33- ExtEntityEntry extResultEntry = new ExtEntityEntry (
34- loadUuid,
35- " Load" ,
36- Optional . empty(),
37- DataType . RESULT
38- )
35+ ExtEntityEntry extResultEntry = new ExtEntityEntry (loadUuid, " Load" , Optional . empty(), RESULT )
3936
4037 @Shared
41- ExtEntityEntry extInputEntry = new ExtEntityEntry (
42- pvUuid,
43- " PV" ,
44- ColumnScheme . parse(" p" ),
45- DataType . PRIMARY
46- )
38+ ExtEntityEntry extInputEntry = new ExtEntityEntry (pvUuid, " PV" , ColumnScheme . parse(" p" ), PRIMARY )
4739
4840 @Shared
49- ExtEntityEntry extPrimaryResultEntry = new ExtEntityEntry (
50- prUuid,
51- " PR" ,
52- ColumnScheme . parse(" p" ),
53- DataType . PRIMARY_RESULT
54- )
41+ ExtEntityEntry extPrimaryResultEntry = new ExtEntityEntry (prUuid, " PR" , ColumnScheme . parse(" p" ), PRIMARY_RESULT )
5542
5643 @Shared
57- ExtEntityEntry extEmInputEntry = new ExtEntityEntry (
58- emUuid,
59- " Em" ,
60- Optional . empty(),
61- DataType . EM
62- )
44+ ExtEntityEntry extEmInputEntry = new ExtEntityEntry (emUuid, " Em" , Optional . empty(), EM )
45+
6346
6447 def " ExtEntityMapping can be created from a grid container correctly" () {
6548 given :
@@ -118,15 +101,14 @@ class ExtEntityMappingTest extends Specification {
118101 def mapping = new ExtEntityMapping (grid)
119102
120103 when :
121- def updated = mapping. include(DataType . RESULT , [" ffi" ], Optional . empty())
104+ def updated = mapping. include(RESULT , [" ffi" ], Optional . empty())
122105
123106 then :
124107 // only the included ids will be returned, other grid ids will be ignored
125- mapping. getAssets(DataType . RESULT ) == [node. uuid, participant. uuid, em. uuid]
126- updated. getAssets(DataType . RESULT ) == [participant. uuid]
108+ mapping. getAssets(RESULT ) == [node. uuid, participant. uuid, em. uuid]
109+ updated. getAssets(RESULT ) == [participant. uuid]
127110 }
128111
129-
130112 def " ExtEntityMapping should return the data types correctly" () {
131113 when :
132114 def extEntryMapping = new ExtEntityMapping (assets)
@@ -137,13 +119,13 @@ class ExtEntityMappingTest extends Specification {
137119
138120 where :
139121 assets | expectedTypes
140- [extResultEntry] | [DataType . RESULT ]
141- [extInputEntry] | [DataType . PRIMARY ]
142- [extPrimaryResultEntry] | [DataType . PRIMARY_RESULT ]
143- [extEmInputEntry] | [DataType . EM ]
144- [extResultEntry, extInputEntry] | [DataType . RESULT , DataType . PRIMARY ]
145- [extInputEntry, extEmInputEntry] | [DataType . PRIMARY , DataType . EM ]
146- [extResultEntry, extInputEntry, extPrimaryResultEntry, extEmInputEntry] | [DataType . RESULT , DataType . PRIMARY , DataType . PRIMARY_RESULT , DataType . EM ]
122+ [extResultEntry] | [RESULT ]
123+ [extInputEntry] | [PRIMARY ]
124+ [extPrimaryResultEntry] | [PRIMARY_RESULT ]
125+ [extEmInputEntry] | [EM ]
126+ [extResultEntry, extInputEntry] | [RESULT , PRIMARY ]
127+ [extInputEntry, extEmInputEntry] | [PRIMARY , EM ]
128+ [extResultEntry, extInputEntry, extPrimaryResultEntry, extEmInputEntry] | [RESULT , PRIMARY , PRIMARY_RESULT , EM ]
147129 }
148130
149131 def " ExtEntityMapping should return all SIMONA uuid mapping correctly" () {
@@ -162,32 +144,67 @@ class ExtEntityMappingTest extends Specification {
162144 inputMap. get(" Em" ) == emUuid
163145 }
164146
165- def " ExtEntityMapping should return SIMONA uuid mapping correctly" () {
147+ def " ExtEntityMapping should return all external id mapping correctly" () {
166148 given :
167149 def extAssetList = List . of(extResultEntry, extInputEntry, extPrimaryResultEntry, extEmInputEntry)
168150 def extEntryMapping = new ExtEntityMapping (extAssetList)
169151
170152 when :
171- def actual = extEntryMapping. getAssets(DataType . PRIMARY )
153+ def inputMap = extEntryMapping. getExtUuid2IdMapping()
154+
155+ then :
156+ inputMap. size() == 4
157+ inputMap. get(loadUuid) == " Load"
158+ inputMap. get(pvUuid) == " PV"
159+ inputMap. get(prUuid) == " PR"
160+ inputMap. get(emUuid) == " Em"
161+ }
162+
163+ def " ExtEntityMapping should return SIMONA uuid mapping correctly" () {
164+ given :
165+ def extAssetList = [extResultEntry, extInputEntry, extPrimaryResultEntry, extEmInputEntry]
166+ def extEntryMapping = new ExtEntityMapping (extAssetList)
167+
168+ when :
169+ def actual = extEntryMapping. getAssets(PRIMARY )
172170
173171 then :
174172 actual. size() == 1
175173 actual. getFirst() == pvUuid
176174 }
177175
178- def " ExtEntityMapping should return all external id mapping correctly" () {
176+ def " ExtEntityMapping should return assets uuids correctly" () {
179177 given :
180- def extAssetList = List . of(extResultEntry, extInputEntry, extPrimaryResultEntry, extEmInputEntry)
181- def extEntryMapping = new ExtEntityMapping (extAssetList)
178+ def node = new NodeInput (UUID . fromString(" 4476402e-d0e7-4975-935b-6861a00a2a5e" ), " node" , Quantities . getQuantity(1d , PowerSystemUnits . PU ), false , NodeInput . DEFAULT_GEO_POSITION , GermanVoltageLevelUtils . LV , 1 )
179+ def em = new EmInput (UUID . fromString(" d7c054b2-f5a8-4f88-99e1-59c734fc4655" ), " em" , " " , null )
180+ def participant = new FixedFeedInInput (UUID . fromString(" 4392e420-dc91-4867-a85f-b05d53896dd2" ), " ffi" , node, null , em, Quantities . getQuantity(10 , PowerSystemUnits . KILOVOLTAMPERE ), 0.9 )
181+
182+ List<AssetInput > gridAssets = [node]
183+ List<SystemParticipantInput > participantInputs = [participant]
184+
185+ def grid = new SubGridContainer (
186+ " test grid" ,
187+ 1 ,
188+ new RawGridElements (gridAssets),
189+ new SystemParticipants (participantInputs),
190+ new GraphicElements ([])
191+ )
182192
183193 when :
184- def inputMap = extEntryMapping. getExtUuid2IdMapping()
194+ def mapping = new ExtEntityMapping (grid). include(includedType, includedExtAssets, Optional . empty())
195+ def actual = mapping. getAssets(requestedType)
185196
186197 then :
187- inputMap. size() == 4
188- inputMap. get(loadUuid) == " Load"
189- inputMap. get(pvUuid) == " PV"
190- inputMap. get(prUuid) == " PR"
191- inputMap. get(emUuid) == " Em"
198+ actual. size() == expectedSize
199+ actual == expectedUuids
200+
201+ where :
202+ includedType | includedExtAssets | requestedType | expectedSize | expectedUuids
203+ PRIMARY | [] | PRIMARY | 1 | [UUID . fromString(" 4392e420-dc91-4867-a85f-b05d53896dd2" )]
204+ PRIMARY_RESULT | [" ffi" ] | RESULT | 1 | [UUID . fromString(" 4392e420-dc91-4867-a85f-b05d53896dd2" )]
205+ RESULT | [] | RESULT | 3 | [UUID . fromString(" 4476402e-d0e7-4975-935b-6861a00a2a5e" ), UUID . fromString(" 4392e420-dc91-4867-a85f-b05d53896dd2" ), UUID . fromString(" d7c054b2-f5a8-4f88-99e1-59c734fc4655" )]
206+ RESULT | [] | PRIMARY_RESULT | 1 | [UUID . fromString(" 4392e420-dc91-4867-a85f-b05d53896dd2" )]
207+ RESULT | [" ffi" , " node" ] | RESULT | 2 | [UUID . fromString(" 4476402e-d0e7-4975-935b-6861a00a2a5e" ), UUID . fromString(" 4392e420-dc91-4867-a85f-b05d53896dd2" )]
208+
192209 }
193210}
0 commit comments