1
2
3
4
5 package oshi.driver.unix.freebsd.disk;
6
7 import static org.hamcrest.MatcherAssert.assertThat;
8 import static org.hamcrest.Matchers.anEmptyMap;
9 import static org.hamcrest.Matchers.not;
10 import static org.junit.jupiter.api.Assertions.assertTrue;
11
12 import java.util.List;
13 import java.util.Map;
14 import java.util.Map.Entry;
15 import java.util.Set;
16
17 import org.junit.jupiter.api.Test;
18 import org.junit.jupiter.api.condition.EnabledOnOs;
19 import org.junit.jupiter.api.condition.OS;
20
21 import oshi.hardware.HWPartition;
22 import oshi.util.tuples.Triplet;
23
24 @EnabledOnOs(OS.FREEBSD)
25 class DiskDriversTest {
26 @Test
27 void testDiskDrivers() {
28 Map<String, Triplet<String, String, Long>> diskStringMap = GeomDiskList.queryDisks();
29 assertThat("Disk string map should not be empty", diskStringMap, not(anEmptyMap()));
30
31 Map<String, List<HWPartition>> partMap = GeomPartList.queryPartitions();
32 assertThat("Partition map should not be empty", partMap, not(anEmptyMap()));
33
34 Map<String, String> deviceMap = Mount.queryPartitionToMountMap();
35 Set<String> diskNames = diskStringMap.keySet();
36 Set<String> mountedPartitions = deviceMap.keySet();
37 for (Entry<String, List<HWPartition>> entry : partMap.entrySet()) {
38 assertTrue(diskNames.contains(entry.getKey()), "Disk name should be in disk string map");
39 for (HWPartition part : entry.getValue()) {
40 if (!part.getMountPoint().isEmpty()) {
41 assertTrue(mountedPartitions.contains(entry.getKey()), "Partition name should be in mount map");
42 }
43 }
44 }
45 }
46 }