Skip to content

Commit e2f0202

Browse files
committed
Add tests
Signed-off-by: BOUHOURS Antoine <[email protected]>
1 parent 82c42c5 commit e2f0202

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

network-store-client/src/main/java/com/powsybl/network/store/client/PreloadingNetworkStoreClient.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private void ensureAllCollectionForBusViewCached(ResourceType resourceType, UUID
120120
}
121121
}
122122

123-
private boolean shouldLoadAllCollectionsForBusView(ResourceType resourceType) {
123+
boolean shouldLoadAllCollectionsForBusView(ResourceType resourceType) {
124124
return !allCollectionsNeededForBusViewLoaded
125125
&& allCollectionsNeededForBusView
126126
&& RESOURCE_TYPES_NEEDED_FOR_BUS_VIEW.contains(resourceType);

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

+19-26
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,28 @@
66
*/
77
package com.powsybl.network.store.client;
88

9+
import com.powsybl.network.store.iidm.impl.CachedNetworkStoreClient;
10+
import com.powsybl.network.store.iidm.impl.OfflineNetworkStoreClient;
11+
import com.powsybl.network.store.model.ResourceType;
12+
import org.junit.Test;
13+
14+
import java.util.UUID;
15+
import java.util.concurrent.ForkJoinPool;
16+
17+
import static org.junit.Assert.assertFalse;
18+
import static org.junit.Assert.assertTrue;
19+
920
/**
1021
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
1122
*/
1223
public class PreloadingAllCollectionsTest {
1324

14-
// @Test
15-
// public void test() {
16-
// var client = new PreloadingNetworkStoreClient(new CachedNetworkStoreClient(new OfflineNetworkStoreClient()), false, ForkJoinPool.commonPool());
17-
// UUID networkUuid = UUID.fromString("7928181c-7977-4592-ba19-88027e4254e4");
18-
// client.getSubstations(networkUuid, 0);
19-
// assertTrue(client.isResourceTypeCached(networkUuid, 0, ResourceType.SUBSTATION));
20-
// for (ResourceType resourceType : ResourceType.values()) {
21-
// if (resourceType != ResourceType.SUBSTATION) {
22-
// assertFalse(client.isResourceTypeCached(networkUuid, 0, ResourceType.GENERATOR));
23-
// }
24-
// }
25-
// }
26-
//
27-
// @Test
28-
// public void testWithAllCollections() {
29-
// var client = new PreloadingNetworkStoreClient(new CachedNetworkStoreClient(new OfflineNetworkStoreClient()), true, ForkJoinPool.commonPool());
30-
// UUID networkUuid = UUID.fromString("7928181c-7977-4592-ba19-88027e4254e4");
31-
// client.getSubstations(networkUuid, 0);
32-
// for (ResourceType resourceType : ResourceType.values()) {
33-
// if (PreloadingNetworkStoreClient.RESOURCE_TYPES_NEEDED_FOR_BUS_VIEW.contains(resourceType)) {
34-
// assertTrue(client.isResourceTypeCached(networkUuid, 0, resourceType));
35-
// } else {
36-
// assertFalse(client.isResourceTypeCached(networkUuid, 0, resourceType));
37-
// }
38-
// }
39-
// }
25+
@Test
26+
public void testWithAllCollections() {
27+
var client = new PreloadingNetworkStoreClient(new CachedNetworkStoreClient(new OfflineNetworkStoreClient()), true, ForkJoinPool.commonPool());
28+
UUID networkUuid = UUID.fromString("7928181c-7977-4592-ba19-88027e4254e4");
29+
assertTrue(client.shouldLoadAllCollectionsForBusView(ResourceType.SUBSTATION));
30+
client.getSubstations(networkUuid, 0);
31+
assertFalse(client.shouldLoadAllCollectionsForBusView(ResourceType.SUBSTATION));
32+
}
4033
}

0 commit comments

Comments
 (0)