11package ee .bitweb .core .object_mapper .deserializer ;
22
3- import com . fasterxml . jackson .core .JsonProcessingException ;
4- import com . fasterxml . jackson .databind .ObjectMapper ;
3+ import tools . jackson .core .JacksonException ;
4+ import tools . jackson .databind .json . JsonMapper ;
55import org .junit .jupiter .api .BeforeEach ;
66import org .junit .jupiter .api .DisplayName ;
77import org .junit .jupiter .api .Tag ;
1717@ Tag ("unit" )
1818class TrimmedStringDeserializerTest {
1919
20- private ObjectMapper mapper ;
20+ private JsonMapper mapper ;
2121
2222 @ BeforeEach
2323 void setUp () {
24- mapper = new ObjectMapper ();
25- TrimmedStringDeserializer .addToObjectMapper (mapper );
24+ mapper = JsonMapper .builder ()
25+ .addModule (TrimmedStringDeserializer .createModule ())
26+ .build ();
2627 }
2728
2829 static Stream <Arguments > stringTrimmingCases () {
@@ -39,7 +40,7 @@ static Stream<Arguments> stringTrimmingCases() {
3940
4041 @ ParameterizedTest (name = "Should handle {2}" )
4142 @ MethodSource ("stringTrimmingCases" )
42- void shouldTrimStrings (String input , String expected , String description ) throws JsonProcessingException {
43+ void shouldTrimStrings (String input , String expected , String description ) throws JacksonException {
4344 String json = "\" " + escapeJson (input ) + "\" " ;
4445
4546 String result = mapper .readValue (json , String .class );
@@ -49,15 +50,15 @@ void shouldTrimStrings(String input, String expected, String description) throws
4950
5051 @ Test
5152 @ DisplayName ("Should return null for null value" )
52- void shouldReturnNullForNullValue () throws JsonProcessingException {
53+ void shouldReturnNullForNullValue () throws JacksonException {
5354 String result = mapper .readValue ("null" , String .class );
5455
5556 assertNull (result );
5657 }
5758
5859 @ Test
5960 @ DisplayName ("Should trim string fields in object" )
60- void shouldTrimStringFieldsInObject () throws JsonProcessingException {
61+ void shouldTrimStringFieldsInObject () throws JacksonException {
6162 String json = "{\" name\" : \" John Doe \" , \" email\" : \" john@example.com \" }" ;
6263
6364 TestObject result = mapper .readValue (json , TestObject .class );
@@ -70,7 +71,7 @@ void shouldTrimStringFieldsInObject() throws JsonProcessingException {
7071
7172 @ Test
7273 @ DisplayName ("Should trim strings in array" )
73- void shouldTrimStringsInArray () throws JsonProcessingException {
74+ void shouldTrimStringsInArray () throws JacksonException {
7475 String json = "[\" first \" , \" second \" , \" third \" ]" ;
7576
7677 String [] result = mapper .readValue (json , String [].class );
0 commit comments