Test disks extraction. @throws IOException Signals that an I/O exception has occurred.
()
| 49 | * Signals that an I/O exception has occurred. |
| 50 | */ |
| 51 | @Test |
| 52 | void testDisks() throws IOException { |
| 53 | SystemInfo si = new SystemInfo(); |
| 54 | |
| 55 | for (HWDiskStore disk : si.getHardware().getDiskStores()) { |
| 56 | assertThat(disk, is(notNullValue())); |
| 57 | List<HWPartition> parts = disk.getPartitions(); |
| 58 | List<HWPartition> partList = new ArrayList<>(parts.size()); |
| 59 | for (HWPartition part : parts) { |
| 60 | partList.add(new HWPartition(part.getIdentification(), part.getName(), part.getType(), part.getUuid(), |
| 61 | part.getSize(), part.getMajor(), part.getMinor(), part.getMountPoint())); |
| 62 | } |
| 63 | |
| 64 | assertThat("Disk name should not be null", disk.getName(), is(notNullValue())); |
| 65 | assertThat("Disk model should not be null", disk.getModel(), is(notNullValue())); |
| 66 | assertThat("Disk serial number should not be null", disk.getSerial(), is(notNullValue())); |
| 67 | assertThat("Disk size should be greater or equal 0", disk.getSize(), is(greaterThanOrEqualTo(0L))); |
| 68 | assertThat("Number of read operations from the disk should be greater or equal to 0", disk.getReads(), |
| 69 | is(greaterThanOrEqualTo(0L))); |
| 70 | assertThat("Number of read bytes should be greater or equal to 0", disk.getReadBytes(), |
| 71 | is(greaterThanOrEqualTo(0L))); |
| 72 | assertThat("Number of write operations from the disk should be greater or equal to 0", disk.getWrites(), |
| 73 | is(greaterThanOrEqualTo(0L))); |
| 74 | assertThat("Number of write bytes should be greater or equal to 0", disk.getWriteBytes(), |
| 75 | is(greaterThanOrEqualTo(0L))); |
| 76 | assertThat("Transfer times should be greater or equal 0", disk.getTransferTime(), |
| 77 | is(greaterThanOrEqualTo(0L))); |
| 78 | assertThat("Update time for statistics should be greater or equal 0", disk.getTimeStamp(), |
| 79 | is(greaterThanOrEqualTo(0L))); |
| 80 | assertThat("toString method should contain the disk name", disk.toString(), containsString(disk.getName())); |
| 81 | |
| 82 | long oldReads = disk.getReads(); |
| 83 | long oldReadBytes = disk.getReadBytes(); |
| 84 | if (oldReads > 0) { |
| 85 | assertThat("Updating the disk statistics should work for " + disk.getName(), disk.updateAttributes(), |
| 86 | is(true)); |
| 87 | assertThat("Number of reads from the disk has not been updated", disk.getReads(), |
| 88 | is(greaterThanOrEqualTo(oldReads))); |
| 89 | assertThat("Number of read bytes from the disk has not been updated", disk.getReadBytes(), |
| 90 | is(greaterThanOrEqualTo(oldReadBytes))); |
| 91 | } |
| 92 | for (HWPartition partition : disk.getPartitions()) { |
| 93 | assertThat("Identification of partition is null", partition.getIdentification(), is(notNullValue())); |
| 94 | assertThat("Name of partition is null", partition.getName(), is(notNullValue())); |
| 95 | assertThat("Type of partition is null", partition.getType(), is(notNullValue())); |
| 96 | assertThat("UUID of partition is null", partition.getUuid(), is(notNullValue())); |
| 97 | assertThat("Mount point of partition is null", partition.getMountPoint(), is(notNullValue())); |
| 98 | assertThat("Partition size of partition " + partition.getName() + " is < 0", partition.getSize(), |
| 99 | is(greaterThanOrEqualTo(0L))); |
| 100 | assertThat("Major device ID of partition " + partition.getName() + "is < 0", partition.getMajor(), |
| 101 | is(greaterThanOrEqualTo(0))); |
| 102 | assertThat("Minor device ID of partition " + partition.getName() + "is < 0", partition.getMinor(), |
| 103 | is(greaterThanOrEqualTo(0))); |
| 104 | assertThat("Partition's toString() method should contain the partitions identification.", |
| 105 | partition.toString(), containsString(partition.getIdentification())); |
| 106 | } |
| 107 | } |
| 108 | } |
nothing calls this directly
no test coverage detected