From e2f02020231ebd536e96b2a409b5124cc3979b5a Mon Sep 17 00:00:00 2001 From: BOUHOURS Antoine Date: Thu, 17 Oct 2024 17:43:34 +0200 Subject: [PATCH] Add tests Signed-off-by: BOUHOURS Antoine --- .../client/PreloadingNetworkStoreClient.java | 2 +- .../client/PreloadingAllCollectionsTest.java | 45 ++++++++----------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/network-store-client/src/main/java/com/powsybl/network/store/client/PreloadingNetworkStoreClient.java b/network-store-client/src/main/java/com/powsybl/network/store/client/PreloadingNetworkStoreClient.java index 27e629089..9c5702d09 100644 --- a/network-store-client/src/main/java/com/powsybl/network/store/client/PreloadingNetworkStoreClient.java +++ b/network-store-client/src/main/java/com/powsybl/network/store/client/PreloadingNetworkStoreClient.java @@ -120,7 +120,7 @@ private void ensureAllCollectionForBusViewCached(ResourceType resourceType, UUID } } - private boolean shouldLoadAllCollectionsForBusView(ResourceType resourceType) { + boolean shouldLoadAllCollectionsForBusView(ResourceType resourceType) { return !allCollectionsNeededForBusViewLoaded && allCollectionsNeededForBusView && RESOURCE_TYPES_NEEDED_FOR_BUS_VIEW.contains(resourceType); diff --git a/network-store-client/src/test/java/com/powsybl/network/store/client/PreloadingAllCollectionsTest.java b/network-store-client/src/test/java/com/powsybl/network/store/client/PreloadingAllCollectionsTest.java index 1e9038235..427c9874d 100644 --- a/network-store-client/src/test/java/com/powsybl/network/store/client/PreloadingAllCollectionsTest.java +++ b/network-store-client/src/test/java/com/powsybl/network/store/client/PreloadingAllCollectionsTest.java @@ -6,35 +6,28 @@ */ package com.powsybl.network.store.client; +import com.powsybl.network.store.iidm.impl.CachedNetworkStoreClient; +import com.powsybl.network.store.iidm.impl.OfflineNetworkStoreClient; +import com.powsybl.network.store.model.ResourceType; +import org.junit.Test; + +import java.util.UUID; +import java.util.concurrent.ForkJoinPool; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** * @author Geoffroy Jamgotchian */ public class PreloadingAllCollectionsTest { -// @Test -// public void test() { -// var client = new PreloadingNetworkStoreClient(new CachedNetworkStoreClient(new OfflineNetworkStoreClient()), false, ForkJoinPool.commonPool()); -// UUID networkUuid = UUID.fromString("7928181c-7977-4592-ba19-88027e4254e4"); -// client.getSubstations(networkUuid, 0); -// assertTrue(client.isResourceTypeCached(networkUuid, 0, ResourceType.SUBSTATION)); -// for (ResourceType resourceType : ResourceType.values()) { -// if (resourceType != ResourceType.SUBSTATION) { -// assertFalse(client.isResourceTypeCached(networkUuid, 0, ResourceType.GENERATOR)); -// } -// } -// } -// -// @Test -// public void testWithAllCollections() { -// var client = new PreloadingNetworkStoreClient(new CachedNetworkStoreClient(new OfflineNetworkStoreClient()), true, ForkJoinPool.commonPool()); -// UUID networkUuid = UUID.fromString("7928181c-7977-4592-ba19-88027e4254e4"); -// client.getSubstations(networkUuid, 0); -// for (ResourceType resourceType : ResourceType.values()) { -// if (PreloadingNetworkStoreClient.RESOURCE_TYPES_NEEDED_FOR_BUS_VIEW.contains(resourceType)) { -// assertTrue(client.isResourceTypeCached(networkUuid, 0, resourceType)); -// } else { -// assertFalse(client.isResourceTypeCached(networkUuid, 0, resourceType)); -// } -// } -// } + @Test + public void testWithAllCollections() { + var client = new PreloadingNetworkStoreClient(new CachedNetworkStoreClient(new OfflineNetworkStoreClient()), true, ForkJoinPool.commonPool()); + UUID networkUuid = UUID.fromString("7928181c-7977-4592-ba19-88027e4254e4"); + assertTrue(client.shouldLoadAllCollectionsForBusView(ResourceType.SUBSTATION)); + client.getSubstations(networkUuid, 0); + assertFalse(client.shouldLoadAllCollectionsForBusView(ResourceType.SUBSTATION)); + } }