Skip to content

Commit

Permalink
fixes sproutsocial#20 -- message for unhealthy checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dexhorthy committed Nov 15, 2016
1 parent 8e2b3fd commit cdbc997
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.sproutsocial.metrics.healthchecks;

import java.util.Optional;
import java.util.Set;

import com.codahale.metrics.Gauge;
import com.codahale.metrics.health.HealthCheck;
import com.google.common.collect.ImmutableSet;

import java.util.Optional;
import java.util.Set;

/**
* Created on 4/19/15
*
Expand Down Expand Up @@ -48,6 +48,6 @@ protected Result check() throws Exception {
}

private String getUnhealthyMessage(T value) {
return "value=" + value + "&ceiling=" + ceiling;
return "value=" + value + "&ceiling=" + ceiling.get();
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.sproutsocial.metrics.healthchecks;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

import java.util.Optional;

import com.codahale.metrics.Gauge;
import com.codahale.metrics.health.HealthCheck;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import com.codahale.metrics.Gauge;
import java.util.Optional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

/**
* Created on 4/19/15
Expand Down Expand Up @@ -60,7 +61,10 @@ public void testUnhealthy() throws Exception {

healthCheck = HealthChecks.forDoubleGauge(doubleGauge, Optional.of(5d));

assertFalse(healthCheck.check().isHealthy());
HealthCheck.Result result = healthCheck.check();

assertFalse(result.isHealthy());
assertEquals("value=10.0&ceiling=5.0", result.getMessage());
}

@Test
Expand Down

0 comments on commit cdbc997

Please sign in to comment.