File tree Expand file tree Collapse file tree 3 files changed +61
-2
lines changed
main/java/de/inoxio/spring/cloudwatchmetrics
test/java/de/inoxio/spring/cloudwatchmetrics Expand file tree Collapse file tree 3 files changed +61
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ plugins {
1212}
1313
1414group = " de.inoxio"
15- version = " 1.0.0 "
15+ version = " 1.0.1 "
1616description = " A java-spring library to push metrics to cloudwatch"
1717
1818apply {
@@ -32,6 +32,7 @@ dependencies {
3232 // test
3333 testImplementation(" org.springframework.boot:spring-boot-starter-test" )
3434 testImplementation(" org.mockito:mockito-core:2.23.0" )
35+ testImplementation(" nl.jqno.equalsverifier:equalsverifier:3.0" )
3536}
3637
3738java {
Original file line number Diff line number Diff line change 11package de .inoxio .spring .cloudwatchmetrics ;
22
3- public class MetricKeyPair {
3+ import java .util .Objects ;
4+
5+ public final class MetricKeyPair {
46
57 private final String name ;
68 private final double value ;
@@ -18,6 +20,30 @@ public double getValue() {
1820 return value ;
1921 }
2022
23+ @ Override
24+ public boolean equals (final Object o ) {
25+ if (this == o ) {
26+ return true ;
27+ }
28+ if (o == null || getClass () != o .getClass ()) {
29+ return false ;
30+ }
31+
32+ final var that = (MetricKeyPair ) o ;
33+
34+ return Double .compare (that .value , value ) == 0 && Objects .equals (name , that .name );
35+ }
36+
37+ @ Override
38+ public int hashCode () {
39+ return Objects .hash (name , value );
40+ }
41+
42+ @ Override
43+ public String toString () {
44+ return "MetricKeyPair{" + "name='" + name + '\'' + ", value=" + value + '}' ;
45+ }
46+
2147 public static final class MetricKeyPairBuilder {
2248
2349 private String name ;
Original file line number Diff line number Diff line change 1+ package de .inoxio .spring .cloudwatchmetrics ;
2+
3+ import static org .hamcrest .MatcherAssert .assertThat ;
4+ import static org .hamcrest .Matchers .is ;
5+
6+ import static de .inoxio .spring .cloudwatchmetrics .MetricKeyPair .MetricKeyPairBuilder .metricKeyPairBuilder ;
7+
8+ import org .junit .Test ;
9+
10+ import nl .jqno .equalsverifier .EqualsVerifier ;
11+
12+ public class MetricKeyPairTest {
13+
14+ @ Test
15+ public void shouldTestEqualsAndHashcode () {
16+ EqualsVerifier .forClass (MetricKeyPair .class ).verify ();
17+ }
18+
19+ @ Test
20+ public void shouldConvertObjectToString () {
21+
22+ // given
23+ final var metricKeyPair = metricKeyPairBuilder ().name ("name" ).value (1.0 ).build ();
24+
25+ // when
26+ final var toString = metricKeyPair .toString ();
27+
28+ // then
29+ assertThat (toString , is ("MetricKeyPair{name='name', value=1.0}" ));
30+ }
31+
32+ }
You can’t perform that action at this time.
0 commit comments