1414 * limitations under the License.
1515 */
1616
17- package org .springframework .boot .actuate .autoconfigure . metrics .mongo ;
17+ package org .springframework .boot .mongodb . actuate .metrics .autoconfigure ;
1818
1919import java .util .List ;
2020
2929import io .micrometer .core .instrument .binder .mongodb .MongoConnectionPoolTagsProvider ;
3030import io .micrometer .core .instrument .binder .mongodb .MongoMetricsCommandListener ;
3131import io .micrometer .core .instrument .binder .mongodb .MongoMetricsConnectionPoolListener ;
32+ import io .micrometer .core .instrument .simple .SimpleMeterRegistry ;
3233import org .assertj .core .api .InstanceOfAssertFactories ;
3334import org .junit .jupiter .api .Test ;
3435
35- import org .springframework .boot .actuate .autoconfigure .metrics .test .MetricsRun ;
3636import org .springframework .boot .autoconfigure .AutoConfigurations ;
3737import org .springframework .boot .mongodb .autoconfigure .MongoAutoConfiguration ;
3838import org .springframework .boot .test .context .FilteredClassLoader ;
@@ -57,7 +57,7 @@ class MongoMetricsAutoConfigurationTests {
5757
5858 @ Test
5959 void whenThereIsAMeterRegistryThenMetricsCommandListenerIsAdded () {
60- this .contextRunner .with ( MetricsRun . simple () )
60+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
6161 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
6262 .run ((context ) -> {
6363 assertThat (context ).hasSingleBean (MongoMetricsCommandListener .class );
@@ -72,7 +72,7 @@ void whenThereIsAMeterRegistryThenMetricsCommandListenerIsAdded() {
7272
7373 @ Test
7474 void whenThereIsAMeterRegistryThenMetricsConnectionPoolListenerIsAdded () {
75- this .contextRunner .with ( MetricsRun . simple () )
75+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
7676 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
7777 .run ((context ) -> {
7878 assertThat (context ).hasSingleBean (MongoMetricsConnectionPoolListener .class );
@@ -98,7 +98,7 @@ void whenThereIsNoMeterRegistryThenNoMetricsConnectionPoolListenerIsAdded() {
9898 @ Test
9999 void whenThereIsACustomMetricsCommandTagsProviderItIsUsed () {
100100 final MongoCommandTagsProvider customTagsProvider = mock (MongoCommandTagsProvider .class );
101- this .contextRunner .with ( MetricsRun . simple () )
101+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
102102 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
103103 .withBean ("customMongoCommandTagsProvider" , MongoCommandTagsProvider .class , () -> customTagsProvider )
104104 .run ((context ) -> assertThat (getMongoCommandTagsProviderUsedToConstructListener (context ))
@@ -108,7 +108,7 @@ void whenThereIsACustomMetricsCommandTagsProviderItIsUsed() {
108108 @ Test
109109 void whenThereIsACustomMetricsConnectionPoolTagsProviderItIsUsed () {
110110 final MongoConnectionPoolTagsProvider customTagsProvider = mock (MongoConnectionPoolTagsProvider .class );
111- this .contextRunner .with ( MetricsRun . simple () )
111+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
112112 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
113113 .withBean ("customMongoConnectionPoolTagsProvider" , MongoConnectionPoolTagsProvider .class ,
114114 () -> customTagsProvider )
@@ -118,47 +118,47 @@ void whenThereIsACustomMetricsConnectionPoolTagsProviderItIsUsed() {
118118
119119 @ Test
120120 void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsCommandListenerIsAdded () {
121- this .contextRunner .with ( MetricsRun . simple () )
121+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
122122 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
123123 .withClassLoader (new FilteredClassLoader (MongoClientSettings .class ))
124124 .run (assertThatMetricsCommandListenerNotAdded ());
125125 }
126126
127127 @ Test
128128 void whenThereIsNoMongoClientSettingsOnClasspathThenNoMetricsConnectionPoolListenerIsAdded () {
129- this .contextRunner .with ( MetricsRun . simple () )
129+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
130130 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
131131 .withClassLoader (new FilteredClassLoader (MongoClientSettings .class ))
132132 .run (assertThatMetricsConnectionPoolListenerNotAdded ());
133133 }
134134
135135 @ Test
136136 void whenThereIsNoMongoMetricsCommandListenerOnClasspathThenNoMetricsCommandListenerIsAdded () {
137- this .contextRunner .with ( MetricsRun . simple () )
137+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
138138 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
139139 .withClassLoader (new FilteredClassLoader (MongoMetricsCommandListener .class ))
140140 .run (assertThatMetricsCommandListenerNotAdded ());
141141 }
142142
143143 @ Test
144144 void whenThereIsNoMongoMetricsConnectionPoolListenerOnClasspathThenNoMetricsConnectionPoolListenerIsAdded () {
145- this .contextRunner .with ( MetricsRun . simple () )
145+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
146146 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
147147 .withClassLoader (new FilteredClassLoader (MongoMetricsConnectionPoolListener .class ))
148148 .run (assertThatMetricsConnectionPoolListenerNotAdded ());
149149 }
150150
151151 @ Test
152152 void whenMetricsCommandListenerEnabledPropertyFalseThenNoMetricsCommandListenerIsAdded () {
153- this .contextRunner .with ( MetricsRun . simple () )
153+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
154154 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
155155 .withPropertyValues ("management.metrics.mongo.command.enabled:false" )
156156 .run (assertThatMetricsCommandListenerNotAdded ());
157157 }
158158
159159 @ Test
160160 void whenMetricsConnectionPoolListenerEnabledPropertyFalseThenNoMetricsConnectionPoolListenerIsAdded () {
161- this .contextRunner .with ( MetricsRun . simple () )
161+ this .contextRunner .withBean ( SimpleMeterRegistry . class )
162162 .withConfiguration (AutoConfigurations .of (MongoAutoConfiguration .class ))
163163 .withPropertyValues ("management.metrics.mongo.connectionpool.enabled:false" )
164164 .run (assertThatMetricsConnectionPoolListenerNotAdded ());
0 commit comments