6
6
*/
7
7
package com .powsybl .network .store .client ;
8
8
9
+ import com .powsybl .iidm .network .VariantManagerConstants ;
9
10
import com .powsybl .network .store .iidm .impl .CachedNetworkStoreClient ;
10
11
import com .powsybl .network .store .iidm .impl .OfflineNetworkStoreClient ;
12
+ import com .powsybl .network .store .model .NetworkAttributes ;
13
+ import com .powsybl .network .store .model .Resource ;
11
14
import com .powsybl .network .store .model .ResourceType ;
12
15
import org .junit .Test ;
13
16
17
+ import java .time .ZonedDateTime ;
18
+ import java .util .List ;
14
19
import java .util .UUID ;
15
20
import java .util .concurrent .ForkJoinPool ;
16
21
@@ -30,4 +35,32 @@ public void testWithAllCollections() {
30
35
client .getSubstations (networkUuid , 0 );
31
36
assertFalse (client .shouldLoadAllCollectionsNeededForBusView (ResourceType .SUBSTATION ));
32
37
}
38
+
39
+ @ Test
40
+ public void testWithAllCollectionsDeleteNetwork () {
41
+ var client = new PreloadingNetworkStoreClient (new CachedNetworkStoreClient (new OfflineNetworkStoreClient ()), true , ForkJoinPool .commonPool ());
42
+ UUID networkUuid = UUID .fromString ("7928181c-7977-4592-ba19-88027e4254e4" );
43
+ Resource <NetworkAttributes > n1 = Resource .networkBuilder ()
44
+ .id ("n1" )
45
+ .attributes (NetworkAttributes .builder ()
46
+ .uuid (networkUuid )
47
+ .variantId (VariantManagerConstants .INITIAL_VARIANT_ID )
48
+ .caseDate (ZonedDateTime .parse ("2015-01-01T00:00:00.000Z" ))
49
+ .build ())
50
+ .build ();
51
+ client .createNetworks (List .of (n1 ));
52
+ assertTrue (client .shouldLoadAllCollectionsNeededForBusView (ResourceType .SUBSTATION ));
53
+ client .getSubstations (networkUuid , 0 );
54
+ assertFalse (client .shouldLoadAllCollectionsNeededForBusView (ResourceType .SUBSTATION ));
55
+ // When we delete the network, we should load again all collection needed for bus view on next get
56
+ client .deleteNetwork (networkUuid );
57
+ assertTrue (client .shouldLoadAllCollectionsNeededForBusView (ResourceType .SUBSTATION ));
58
+ client .createNetworks (List .of (n1 ));
59
+ assertTrue (client .shouldLoadAllCollectionsNeededForBusView (ResourceType .SUBSTATION ));
60
+ client .getSubstations (networkUuid , 0 );
61
+ assertFalse (client .shouldLoadAllCollectionsNeededForBusView (ResourceType .SUBSTATION ));
62
+ // When we delete the network variant, we should load again all collection needed for bus view on next get
63
+ client .deleteNetwork (networkUuid , 0 );
64
+ assertTrue (client .shouldLoadAllCollectionsNeededForBusView (ResourceType .SUBSTATION ));
65
+ }
33
66
}
0 commit comments