DefaultDriveProvider implements DriveMetrics { @Override public Optional<DriveLoad> driveLoadByName(String name) { return hal.getDiskStores().stream() .filter(n -> n.getName().equalsIgnoreCase(name)) .map(this::createDiskLoad) .findAny(); } protected  DefaultDriveProvider(OperatingSystem operatingSystem, HardwareAbstractionLayer hal, SpeedMeasurementManager speedMeasurementManager); void register(); @Override List<Drive> drives(); @Override List<DriveLoad> driveLoads(); @Override Optional<DriveLoad> driveLoadByName(String name); @Override Optional<Drive> driveByName(String name); DriveHealth diskHealth(String name);  }
@Test public void shouldHandleNoLoadForDriveWithThatName() { Optional<DriveLoad> diskInfo = provider.driveLoadByName("/dev/sda3"); assertFalse(diskInfo.isPresent()); }
@Test public void shouldHandleSpeedMeasurementManagerReturningEmpty() { when(measurementManager.getCurrentSpeedForName(DEV_SDA1)).thenReturn(Optional.empty()); Optional<DriveLoad> diskInfo = provider.driveLoadByName(DEV_SDA1); assertTrue(diskInfo.isPresent()); }