1
1
/*
2
- * Copyright 2017 the original author or authors.
2
+ * Copyright 2012- 2017 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
21
21
import org .springframework .boot .actuate .metrics .CounterService ;
22
22
import org .springframework .boot .actuate .metrics .Metric ;
23
23
24
- import static org .junit .Assert .assertEquals ;
25
- import static org .junit .Assert .assertNotNull ;
26
- import static org .junit .Assert .assertNull ;
24
+ import static org .assertj .core .api .Assertions .assertThat ;
27
25
28
26
/**
29
- * Standard tests for {@link BufferCounterService}.
27
+ * Tests for {@link BufferCounterService}.
30
28
*
31
29
* @author Venil Noronha
32
30
*/
@@ -36,56 +34,52 @@ public class BufferCounterServiceTests {
36
34
37
35
private CounterService service = new BufferCounterService (this .counters );
38
36
39
- private BufferMetricReader reader = new BufferMetricReader (this .counters , new GaugeBuffers ());
37
+ private BufferMetricReader reader = new BufferMetricReader (this .counters ,
38
+ new GaugeBuffers ());
40
39
41
40
@ Test
42
41
public void matchExtendedPrefix () {
43
42
this .service .increment ("foo" );
44
- Metric <?> fooMetric = this .reader .findOne ("foo" );
43
+ assertThat ( this .reader .findOne ("foo" )). isNull ( );
45
44
Metric <?> counterFooMetric = this .reader .findOne ("counter.foo" );
46
- assertNull (fooMetric );
47
- assertNotNull (counterFooMetric );
48
- assertEquals (1L , counterFooMetric .getValue ());
45
+ assertThat (counterFooMetric ).isNotNull ();
46
+ assertThat (counterFooMetric .getValue ()).isEqualTo (1L );
49
47
}
50
48
51
49
@ Test
52
50
public void matchCounterPrefix () {
53
51
this .service .increment ("counterfoo" );
54
- Metric <?> counterfooMetric = this .reader .findOne ("counterfoo" );
52
+ assertThat ( this .reader .findOne ("counterfoo" )). isNull ( );
55
53
Metric <?> counterCounterfooMetric = this .reader .findOne ("counter.counterfoo" );
56
- assertNull (counterfooMetric );
57
- assertNotNull (counterCounterfooMetric );
58
- assertEquals (1L , counterCounterfooMetric .getValue ());
54
+ assertThat (counterCounterfooMetric ).isNotNull ();
55
+ assertThat (counterCounterfooMetric .getValue ()).isEqualTo (1L );
59
56
}
60
57
61
58
@ Test
62
59
public void matchCounterDotPrefix () {
63
60
this .service .increment ("counter.foo" );
61
+ assertThat (this .reader .findOne ("counter.counter.foo" )).isNull ();
64
62
Metric <?> counterFooMetric = this .reader .findOne ("counter.foo" );
65
- Metric <?> counterCounterFooMetric = this .reader .findOne ("counter.counter.foo" );
66
- assertNull (counterCounterFooMetric );
67
- assertNotNull (counterFooMetric );
68
- assertEquals (1L , counterFooMetric .getValue ());
63
+ assertThat (counterFooMetric ).isNotNull ();
64
+ assertThat (counterFooMetric .getValue ()).isEqualTo (1L );
69
65
}
70
66
71
67
@ Test
72
68
public void matchMeterPrefix () {
73
69
this .service .increment ("meterfoo" );
74
- Metric <?> meterfooMetric = this .reader .findOne ("meterfoo" );
70
+ assertThat ( this .reader .findOne ("meterfoo" )). isNull ( );
75
71
Metric <?> counterMeterfooMetric = this .reader .findOne ("counter.meterfoo" );
76
- assertNull (meterfooMetric );
77
- assertNotNull (counterMeterfooMetric );
78
- assertEquals (1L , counterMeterfooMetric .getValue ());
72
+ assertThat (counterMeterfooMetric ).isNotNull ();
73
+ assertThat (counterMeterfooMetric .getValue ()).isEqualTo (1L );
79
74
}
80
75
81
76
@ Test
82
77
public void matchMeterDotPrefix () {
83
78
this .service .increment ("meter.foo" );
79
+ assertThat (this .reader .findOne ("counter.meter.foo" )).isNull ();
84
80
Metric <?> meterFooMetric = this .reader .findOne ("meter.foo" );
85
- Metric <?> counterMeterFooMetric = this .reader .findOne ("counter.meter.foo" );
86
- assertNull (counterMeterFooMetric );
87
- assertNotNull (meterFooMetric );
88
- assertEquals (1L , meterFooMetric .getValue ());
81
+ assertThat (meterFooMetric ).isNotNull ();
82
+ assertThat (meterFooMetric .getValue ()).isEqualTo (1L );
89
83
}
90
84
91
85
}
0 commit comments