55
66import java .util .function .BiConsumer ;
77
8- import com .codahale .metrics .health .HealthCheckRegistry ;
98import org .jooby .Env ;
109import org .jooby .Jooby ;
1110import org .jooby .Route ;
2524import com .codahale .metrics .MetricRegistry ;
2625import com .codahale .metrics .Reporter ;
2726import com .codahale .metrics .health .HealthCheck ;
27+ import com .codahale .metrics .health .HealthCheckRegistry ;
2828import com .google .inject .Binder ;
2929import com .google .inject .binder .AnnotatedBindingBuilder ;
3030import com .google .inject .binder .LinkedBindingBuilder ;
@@ -59,6 +59,7 @@ public class MetricsTest {
5959 expect (binder .bind (MetricRegistryInitializer .class )).andReturn (mrABB );
6060 };
6161
62+ @ SuppressWarnings ("unchecked" )
6263 private Block bindHealthCheckRegistry = unit -> {
6364 HealthCheckRegistry registry = unit .get (HealthCheckRegistry .class );
6465
@@ -72,7 +73,7 @@ public class MetricsTest {
7273 @ SuppressWarnings ("unchecked" )
7374 private Block bindHealthCheckRegistryInitializer = unit -> {
7475 AnnotatedBindingBuilder <HealthCheckRegistryInitializer > hcrABB = unit
75- .mock (AnnotatedBindingBuilder .class );
76+ .mock (AnnotatedBindingBuilder .class );
7677 hcrABB .asEagerSingleton ();
7778
7879 Binder binder = unit .get (Binder .class );
@@ -87,7 +88,7 @@ public class MetricsTest {
8788
8889 private Block newHealthCheckRegistry = unit -> {
8990 HealthCheckRegistry registry = unit .constructor (HealthCheckRegistry .class )
90- .build ();
91+ .build ();
9192 unit .registerMock (HealthCheckRegistry .class , registry );
9293 };
9394
@@ -166,6 +167,11 @@ public void basicWithExtMetricRegistry() throws Exception {
166167 MetricRegistry registry = unit .mock (MetricRegistry .class );
167168 unit .registerMock (MetricRegistry .class , registry );
168169 })
170+ .expect (unit -> {
171+ HealthCheckRegistry registry = unit .constructor (HealthCheckRegistry .class )
172+ .build ();
173+ unit .registerMock (HealthCheckRegistry .class , registry );
174+ })
169175 .expect (mapBinderStatic )
170176 .expect (mapbinder (Metric .class , (unit , binder ) -> {
171177 }))
@@ -191,31 +197,31 @@ public void basicWithExtMetricRegistry() throws Exception {
191197 @ Test
192198 public void basicWithExtHealthCheckRegistry () throws Exception {
193199 new MockUnit (Env .class , Config .class , Binder .class )
194- .expect (newMetricRegistry )
195- .expect (unit -> {
196- HealthCheckRegistry registry = unit .mock (HealthCheckRegistry .class );
197- unit .registerMock (HealthCheckRegistry .class , registry );
198- })
199- .expect (mapBinderStatic )
200- .expect (mapbinder (Metric .class , (unit , binder ) -> {
201- }))
202- .expect (mapbinder (HealthCheck .class , (unit , binder ) -> {
203- }))
204- .expect (multibinderStatic )
205- .expect (routes )
206- .expect (setbinder (Reporter .class , (unit , binder ) -> {
207-
208- }))
209- .expect (bindMetricRegistry )
210- .expect (bindMetricRegistryInitializer )
211- .expect (bindHealthCheckRegistry )
212- .expect (bindHealthCheckRegistryInitializer )
213- .expect (onStop )
214- .run (unit -> {
215- HealthCheckRegistry registry = unit .get (HealthCheckRegistry .class );
216- new Metrics (registry )
217- .configure (unit .get (Env .class ), unit .get (Config .class ), unit .get (Binder .class ));
218- });
200+ .expect (newMetricRegistry )
201+ .expect (unit -> {
202+ HealthCheckRegistry registry = unit .mock (HealthCheckRegistry .class );
203+ unit .registerMock (HealthCheckRegistry .class , registry );
204+ })
205+ .expect (mapBinderStatic )
206+ .expect (mapbinder (Metric .class , (unit , binder ) -> {
207+ }))
208+ .expect (mapbinder (HealthCheck .class , (unit , binder ) -> {
209+ }))
210+ .expect (multibinderStatic )
211+ .expect (routes )
212+ .expect (setbinder (Reporter .class , (unit , binder ) -> {
213+
214+ }))
215+ .expect (bindMetricRegistry )
216+ .expect (bindMetricRegistryInitializer )
217+ .expect (bindHealthCheckRegistry )
218+ .expect (bindHealthCheckRegistryInitializer )
219+ .expect (onStop )
220+ .run (unit -> {
221+ HealthCheckRegistry registry = unit .get (HealthCheckRegistry .class );
222+ new Metrics (registry )
223+ .configure (unit .get (Env .class ), unit .get (Config .class ), unit .get (Binder .class ));
224+ });
219225 }
220226
221227 @ Test
@@ -305,7 +311,8 @@ public void threadDump() throws Exception {
305311 .expect (unit -> {
306312 Router routes = unit .get (Router .class );
307313
308- route (unit , routes , "/sys/thread-dump" , unit .constructor (ThreadDumpHandler .class ).build ());
314+ route (unit , routes , "/sys/thread-dump" ,
315+ unit .constructor (ThreadDumpHandler .class ).build ());
309316 })
310317 .expect (setbinder (Reporter .class , (unit , binder ) -> {
311318
0 commit comments