|
|
@ -58,19 +58,23 @@ public class DiskSpaceHealthIndicatorTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void diskSpaceIsUp() throws Exception {
|
|
|
|
public void diskSpaceIsUp() throws Exception {
|
|
|
|
given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES + 10);
|
|
|
|
given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES + 10);
|
|
|
|
|
|
|
|
given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10);
|
|
|
|
Health health = this.healthIndicator.health();
|
|
|
|
Health health = this.healthIndicator.health();
|
|
|
|
assertEquals(Status.UP, health.getStatus());
|
|
|
|
assertEquals(Status.UP, health.getStatus());
|
|
|
|
assertEquals(THRESHOLD_BYTES, health.getDetails().get("threshold"));
|
|
|
|
assertEquals(THRESHOLD_BYTES, health.getDetails().get("threshold"));
|
|
|
|
assertEquals(THRESHOLD_BYTES + 10, health.getDetails().get("free"));
|
|
|
|
assertEquals(THRESHOLD_BYTES + 10, health.getDetails().get("free"));
|
|
|
|
|
|
|
|
assertEquals(THRESHOLD_BYTES * 10, health.getDetails().get("total"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void diskSpaceIsDown() throws Exception {
|
|
|
|
public void diskSpaceIsDown() throws Exception {
|
|
|
|
given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES - 10);
|
|
|
|
given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES - 10);
|
|
|
|
|
|
|
|
given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10);
|
|
|
|
Health health = this.healthIndicator.health();
|
|
|
|
Health health = this.healthIndicator.health();
|
|
|
|
assertEquals(Status.DOWN, health.getStatus());
|
|
|
|
assertEquals(Status.DOWN, health.getStatus());
|
|
|
|
assertEquals(THRESHOLD_BYTES, health.getDetails().get("threshold"));
|
|
|
|
assertEquals(THRESHOLD_BYTES, health.getDetails().get("threshold"));
|
|
|
|
assertEquals(THRESHOLD_BYTES - 10, health.getDetails().get("free"));
|
|
|
|
assertEquals(THRESHOLD_BYTES - 10, health.getDetails().get("free"));
|
|
|
|
|
|
|
|
assertEquals(THRESHOLD_BYTES * 10, health.getDetails().get("total"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private DiskSpaceHealthIndicatorProperties createProperties(File path, long threshold) {
|
|
|
|
private DiskSpaceHealthIndicatorProperties createProperties(File path, long threshold) {
|
|
|
|