11package com .oembedler .moon .graphql .boot .test .instrumentation ;
22
33import com .oembedler .moon .graphql .boot .GraphQLInstrumentationAutoConfiguration ;
4- import com .oembedler .moon .graphql .boot .GraphQLWebAutoConfiguration ;
4+ import com .oembedler .moon .graphql .boot .metrics .MetricsInstrumentation ;
5+ import com .oembedler .moon .graphql .boot .metrics .TracingNoResolversInstrumentation ;
56import com .oembedler .moon .graphql .boot .test .AbstractAutoConfigurationTest ;
67import graphql .analysis .MaxQueryComplexityInstrumentation ;
78import graphql .analysis .MaxQueryDepthInstrumentation ;
8- import graphql .execution .AsyncExecutionStrategy ;
9- import graphql .execution .ExecutionStrategy ;
109import graphql .execution .instrumentation .Instrumentation ;
1110import graphql .execution .instrumentation .tracing .TracingInstrumentation ;
1211import graphql .schema .GraphQLObjectType ;
1312import graphql .schema .GraphQLSchema ;
14- import graphql .servlet .AbstractGraphQLHttpServlet ;
13+ import io .micrometer .core .instrument .MeterRegistry ;
14+ import io .micrometer .core .instrument .simple .SimpleMeterRegistry ;
1515import org .junit .Assert ;
1616import org .junit .Test ;
1717import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
@@ -36,6 +36,11 @@ GraphQLSchema schema() {
3636 return GraphQLSchema .newSchema ().query (GraphQLObjectType .newObject ().name ("Query" ).build ()).build ();
3737 }
3838
39+ @ Bean
40+ MeterRegistry meterRegistry () {
41+ return new SimpleMeterRegistry ();
42+ }
43+
3944 }
4045
4146 @ Test (expected = NoSuchBeanDefinitionException .class )
@@ -45,16 +50,9 @@ public void noDefaultInstrumentations() {
4550 this .getContext ().getBean (Instrumentation .class );
4651 }
4752
48- @ Test (expected = NoSuchBeanDefinitionException .class )
49- public void tracingInstrumentationDisabled () {
50- load (DefaultConfiguration .class , "graphql.servlet.tracingEnabled=false" );
51-
52- this .getContext ().getBean (TracingInstrumentation .class );
53- }
54-
5553 @ Test
5654 public void tracingInstrumentationEnabled () {
57- load (DefaultConfiguration .class , "graphql.servlet.tracingEnabled =true" );
55+ load (DefaultConfiguration .class , "graphql.servlet.tracing-enabled =true" );
5856
5957 Assert .assertNotNull (this .getContext ().getBean (TracingInstrumentation .class ));
6058 }
@@ -72,4 +70,46 @@ public void maxQueryDepthEnabled() {
7270
7371 Assert .assertNotNull (this .getContext ().getBean (MaxQueryDepthInstrumentation .class ));
7472 }
73+
74+ @ Test (expected = NoSuchBeanDefinitionException .class )
75+ public void actuatorMetricsEnabledAndTracingEnabled () {
76+ load (DefaultConfiguration .class , "graphql.servlet.tracing-enabled=true" , "graphql.servlet.actuator-metrics=true" );
77+
78+ Assert .assertNotNull (this .getContext ().getBean (TracingInstrumentation .class ));
79+ this .getContext ().getBean (TracingInstrumentation .class );
80+ }
81+
82+ @ Test
83+ public void tracingInstrumentationDisabledndMetricsEnabled () {
84+ load (DefaultConfiguration .class , "graphql.servlet.tracing-enabled=false" , "graphql.servlet.actuator-metrics=true" );
85+
86+ Assert .assertNotNull (this .getContext ().getBean (MetricsInstrumentation .class ));
87+ Assert .assertNotNull (this .getContext ().getBean (TracingNoResolversInstrumentation .class ));
88+ }
89+
90+ @ Test (expected = NoSuchBeanDefinitionException .class )
91+ public void tracingInstrumentationEnabledAndMetricsDisabled () {
92+ load (DefaultConfiguration .class , "graphql.servlet.tracing-enabled=true" , "graphql.servlet.actuator-metrics=false" );
93+
94+ Assert .assertNotNull (this .getContext ().getBean (TracingInstrumentation .class ));
95+ this .getContext ().getBean (MetricsInstrumentation .class );
96+ }
97+
98+ @ Test (expected = NoSuchBeanDefinitionException .class )
99+ public void tracingInstrumentationDisabledAndMetricsDisabled () {
100+ load (DefaultConfiguration .class , "graphql.servlet.tracing-enabled=false" , "graphql.servlet.actuator-metrics=false" );
101+
102+ this .getContext ().getBean (MetricsInstrumentation .class );
103+ this .getContext ().getBean (TracingNoResolversInstrumentation .class );
104+ this .getContext ().getBean (TracingInstrumentation .class );
105+ }
106+
107+
108+
109+ @ Test (expected = NoSuchBeanDefinitionException .class )
110+ public void actuatorMetricsDisabled () {
111+ load (DefaultConfiguration .class , "graphql.servlet.actuator-metrics=false" );
112+
113+ this .getContext ().getBean (MetricsInstrumentation .class );
114+ }
75115}
0 commit comments