Skip to content

Commit e50a021

Browse files
committed
Add basic tests on PreloadingNetworkStoreClient
Signed-off-by: BOUHOURS Antoine <[email protected]>
1 parent 10ed186 commit e50a021

File tree

2 files changed

+463
-0
lines changed

2 files changed

+463
-0
lines changed

network-store-client/src/test/java/com/powsybl/network/store/client/PreloadingAllCollectionsTest.java

+33
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66
*/
77
package com.powsybl.network.store.client;
88

9+
import com.powsybl.iidm.network.VariantManagerConstants;
910
import com.powsybl.network.store.iidm.impl.CachedNetworkStoreClient;
1011
import com.powsybl.network.store.iidm.impl.OfflineNetworkStoreClient;
12+
import com.powsybl.network.store.model.NetworkAttributes;
13+
import com.powsybl.network.store.model.Resource;
1114
import com.powsybl.network.store.model.ResourceType;
1215
import org.junit.Test;
1316

17+
import java.time.ZonedDateTime;
18+
import java.util.List;
1419
import java.util.UUID;
1520
import java.util.concurrent.ForkJoinPool;
1621

@@ -30,4 +35,32 @@ public void testWithAllCollections() {
3035
client.getSubstations(networkUuid, 0);
3136
assertFalse(client.shouldLoadAllCollectionsNeededForBusView(ResourceType.SUBSTATION));
3237
}
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+
}
3366
}

0 commit comments

Comments
 (0)