Skip to content

Commit a52fea2

Browse files
committed
Improve test coverage
1 parent 9411b18 commit a52fea2

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/test/java/ee/bitweb/core/object_mapper/ObjectMapperPropertiesTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void shouldHaveCorrectPrefixConstant() {
2020
void shouldHaveDefaultAutoConfigurationAsFalse() {
2121
ObjectMapperProperties properties = new ObjectMapperProperties();
2222

23-
assertFalse(properties.getAutoConfiguration());
23+
assertFalse(properties.isAutoConfiguration());
2424
}
2525

2626
@Test
@@ -30,7 +30,7 @@ void shouldAllowSettingAutoConfigurationToTrue() {
3030

3131
properties.setAutoConfiguration(true);
3232

33-
assertTrue(properties.getAutoConfiguration());
33+
assertTrue(properties.isAutoConfiguration());
3434
}
3535

3636
@Test
@@ -41,6 +41,6 @@ void shouldAllowSettingAutoConfigurationBackToFalse() {
4141

4242
properties.setAutoConfiguration(false);
4343

44-
assertFalse(properties.getAutoConfiguration());
44+
assertFalse(properties.isAutoConfiguration());
4545
}
4646
}

src/test/java/ee/bitweb/core/object_mapper/deserializer/TrimmedStringDeserializerTest.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package 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;
55
import org.junit.jupiter.api.BeforeEach;
66
import org.junit.jupiter.api.DisplayName;
77
import org.junit.jupiter.api.Tag;
@@ -17,12 +17,13 @@
1717
@Tag("unit")
1818
class 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

Comments
 (0)