1919import co .elastic .clients .elasticsearch .ElasticsearchClient ;
2020import co .elastic .clients .json .JsonpMapper ;
2121import co .elastic .clients .json .SimpleJsonpMapper ;
22+ import co .elastic .clients .json .jackson .Jackson3JsonpMapper ;
2223import co .elastic .clients .json .jackson .JacksonJsonpMapper ;
2324import co .elastic .clients .json .jsonb .JsonbJsonpMapper ;
2425import co .elastic .clients .transport .ElasticsearchTransport ;
2526import co .elastic .clients .transport .rest5_client .Rest5ClientTransport ;
2627import co .elastic .clients .transport .rest5_client .low_level .Rest5Client ;
2728import com .fasterxml .jackson .databind .ObjectMapper ;
2829import org .junit .jupiter .api .Test ;
30+ import tools .jackson .databind .json .JsonMapper ;
2931
3032import org .springframework .boot .autoconfigure .AutoConfigurations ;
3133import org .springframework .boot .jackson .autoconfigure .JacksonAutoConfiguration ;
@@ -65,15 +67,15 @@ void withRestClientAutoConfigurationShouldDefineClientAndSupportingBeans() {
6567
6668 @ Test
6769 void withoutJsonbOrJacksonShouldDefineSimpleMapper () {
68- this .contextRunner .withClassLoader (new FilteredClassLoader (ObjectMapper .class ))
70+ this .contextRunner .withClassLoader (new FilteredClassLoader (JsonMapper . class , ObjectMapper .class ))
6971 .withUserConfiguration (RestClientConfiguration .class )
7072 .run ((context ) -> assertThat (context ).hasSingleBean (JsonpMapper .class )
7173 .hasSingleBean (SimpleJsonpMapper .class ));
7274 }
7375
7476 @ Test
7577 void withJsonbShouldDefineJsonbMapper () {
76- this .contextRunner .withClassLoader (new FilteredClassLoader (ObjectMapper .class ))
78+ this .contextRunner .withClassLoader (new FilteredClassLoader (JsonMapper . class , ObjectMapper .class ))
7779 .withConfiguration (AutoConfigurations .of (JsonbAutoConfiguration .class ))
7880 .withUserConfiguration (RestClientConfiguration .class )
7981 .run ((context ) -> assertThat (context ).hasSingleBean (JsonpMapper .class )
@@ -83,6 +85,16 @@ void withJsonbShouldDefineJsonbMapper() {
8385 @ Test
8486 void withJacksonShouldDefineJacksonMapper () {
8587 this .contextRunner .withConfiguration (AutoConfigurations .of (JacksonAutoConfiguration .class ))
88+ .withUserConfiguration (RestClientConfiguration .class )
89+ .run ((context ) -> assertThat (context ).hasSingleBean (JsonpMapper .class )
90+ .hasSingleBean (Jackson3JsonpMapper .class ));
91+ }
92+
93+ @ Test
94+ @ Deprecated (since = "4.0.0" , forRemoval = true )
95+ void withoutJackson3ShouldDefineJackson2Mapper () {
96+ this .contextRunner .withClassLoader (new FilteredClassLoader (JsonMapper .class ))
97+ .withConfiguration (AutoConfigurations .of (JacksonAutoConfiguration .class ))
8698 .withUserConfiguration (RestClientConfiguration .class )
8799 .run ((context ) -> assertThat (context ).hasSingleBean (JsonpMapper .class )
88100 .hasSingleBean (JacksonJsonpMapper .class ));
@@ -94,7 +106,7 @@ void withJacksonAndJsonbShouldDefineJacksonMapper() {
94106 .withConfiguration (AutoConfigurations .of (JsonbAutoConfiguration .class , JacksonAutoConfiguration .class ))
95107 .withUserConfiguration (RestClientConfiguration .class )
96108 .run ((context ) -> assertThat (context ).hasSingleBean (JsonpMapper .class )
97- .hasSingleBean (JacksonJsonpMapper .class ));
109+ .hasSingleBean (Jackson3JsonpMapper .class ));
98110 }
99111
100112 @ Test
@@ -122,6 +134,20 @@ void withCustomTransportClientShouldUseIt() {
122134 @ Test
123135 void jacksonJsonpMapperDoesNotUseGlobalObjectMapper () {
124136 this .contextRunner .withConfiguration (AutoConfigurations .of (JacksonAutoConfiguration .class ))
137+ .withUserConfiguration (RestClientConfiguration .class )
138+ .withBean (ObjectMapper .class )
139+ .run ((context ) -> {
140+ JsonMapper jsonMapper = context .getBean (JsonMapper .class );
141+ Jackson3JsonpMapper jacksonJsonpMapper = context .getBean (Jackson3JsonpMapper .class );
142+ assertThat (jacksonJsonpMapper .objectMapper ()).isNotSameAs (jsonMapper );
143+ });
144+ }
145+
146+ @ Test
147+ @ Deprecated (since = "4.0.0" , forRemoval = true )
148+ void jackson2JsonpMapperDoesNotUseGlobalObjectMapper () {
149+ this .contextRunner .withClassLoader (new FilteredClassLoader (JsonMapper .class ))
150+ .withConfiguration (AutoConfigurations .of (JacksonAutoConfiguration .class ))
125151 .withUserConfiguration (RestClientConfiguration .class )
126152 .withBean (ObjectMapper .class )
127153 .run ((context ) -> {
0 commit comments