Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: BOUHOURS Antoine <[email protected]>
  • Loading branch information
antoinebhs committed Oct 17, 2024
1 parent 82c42c5 commit e2f0202
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <geoffroy.jamgotchian at rte-france.com>
*/
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));
}
}

0 comments on commit e2f0202

Please sign in to comment.