diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java index cd6ec2e5b92..f0ad86fd4bc 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java @@ -47,7 +47,7 @@ public class DefaultCounterService implements CounterService { @Override public void reset(String metricName) { - this.writer.increment(new Delta(wrap(metricName), 0L)); + this.writer.reset(wrap(metricName)); } private String wrap(String metricName) { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterServiceTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterServiceTests.java index ed522c12e3b..c4d731b7aab 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterServiceTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterServiceTests.java @@ -17,7 +17,10 @@ package org.springframework.boot.actuate.metrics.writer; import org.junit.Test; +import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.runners.MockitoJUnitRunner; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.mock; @@ -26,6 +29,7 @@ import static org.mockito.Mockito.verify; /** * Tests for {@link DefaultCounterService}. */ +@RunWith(MockitoJUnitRunner.class) public class DefaultCounterServiceTests { private final MetricWriter repository = mock(MetricWriter.class); @@ -33,22 +37,28 @@ public class DefaultCounterServiceTests { private final DefaultCounterService service = new DefaultCounterService( this.repository); + @Captor + private ArgumentCaptor> captor; + @Test public void incrementPrependsCounter() { this.service.increment("foo"); - @SuppressWarnings("rawtypes") - ArgumentCaptor captor = ArgumentCaptor.forClass(Delta.class); - verify(this.repository).increment(captor.capture()); - assertEquals("counter.foo", captor.getValue().getName()); + verify(this.repository).increment(this.captor.capture()); + assertEquals("counter.foo", this.captor.getValue().getName()); + assertEquals(1L, this.captor.getValue().getValue()); } @Test public void decrementPrependsCounter() { this.service.decrement("foo"); - @SuppressWarnings("rawtypes") - ArgumentCaptor captor = ArgumentCaptor.forClass(Delta.class); - verify(this.repository).increment(captor.capture()); - assertEquals("counter.foo", captor.getValue().getName()); - assertEquals(-1L, captor.getValue().getValue()); + verify(this.repository).increment(this.captor.capture()); + assertEquals("counter.foo", this.captor.getValue().getName()); + assertEquals(-1L, this.captor.getValue().getValue()); + } + + @Test + public void resetResetsCounter() throws Exception { + this.service.reset("foo"); + verify(this.repository).reset("counter.foo"); } } diff --git a/spring-boot-integration-tests/pom.xml b/spring-boot-integration-tests/pom.xml index 4809f49ec01..c3164448646 100644 --- a/spring-boot-integration-tests/pom.xml +++ b/spring-boot-integration-tests/pom.xml @@ -63,6 +63,39 @@ + + org.apache.maven.plugins + maven-antrun-plugin + + + clean-samples + clean + + run + + + + + + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + + + clean-samples + clean + + clean + + + +