1
2
3
4
5 package oshi.driver.unix.aix;
6
7 import static org.hamcrest.MatcherAssert.assertThat;
8 import static org.hamcrest.Matchers.anEmptyMap;
9 import static org.hamcrest.Matchers.greaterThan;
10 import static org.hamcrest.Matchers.not;
11 import static org.junit.jupiter.api.Assertions.assertNotNull;
12 import static org.junit.jupiter.api.Assertions.assertTrue;
13
14 import java.util.List;
15 import java.util.Map;
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.Pair;
23 import oshi.util.tuples.Triplet;
24
25 @EnabledOnOs(OS.AIX)
26 class LsDevicesTest {
27 @Test
28 void testQueryLsDevices() {
29 Map<String, Pair<Integer, Integer>> majMinMap = Ls.queryDeviceMajorMinor();
30 assertThat("Device Major Minor Map shouldn't be empty", majMinMap, not(anEmptyMap()));
31
32 boolean foundNonNull = false;
33 boolean foundPartitions = false;
34 for (String device : majMinMap.keySet()) {
35 Pair<String, String> modSer = Lscfg.queryModelSerial(device);
36 if (modSer.getA() != null || modSer.getB() != null) {
37 foundNonNull = true;
38 List<HWPartition> lvs = Lspv.queryLogicalVolumes(device, majMinMap);
39 if (!lvs.isEmpty()) {
40 foundPartitions = true;
41 }
42 }
43 if (foundNonNull && foundPartitions) {
44 break;
45 }
46 }
47 assertTrue(foundNonNull, "At least one device model/serial should be non null");
48 assertTrue(foundPartitions, "At least one device should have partitions");
49
50 List<String> lscfg = Lscfg.queryAllDevices();
51 assertThat("Output of lscfg should be nonempty", lscfg.size(), greaterThan(0));
52
53 Triplet<String, String, String> modSerVer = Lscfg.queryBackplaneModelSerialVersion(lscfg);
54
55 if (!(modSerVer.getA() == null && modSerVer.getB() == null && modSerVer.getC() == null)) {
56 assertNotNull(modSerVer.getA(), "Backplane Model should not be null");
57 assertNotNull(modSerVer.getB(), "Backplane Serial should not be null");
58 assertNotNull(modSerVer.getC(), "Backplane Version should not be null");
59 }
60 }
61 }