Skip to content

Commit

Permalink
Warnings removal
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 4, 2024
1 parent 2445f78 commit f7780a4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,44 +157,45 @@ public void testSerOptDefault() throws Exception {
assertEquals("{\"myString\":null}", value);
}

public void testSerOptNull() throws Exception {
OptionalData data = new OptionalData();
data.myString = null;
String value = mapperWithModule().setSerializationInclusion(
JsonInclude.Include.NON_NULL).writeValueAsString(data);
assertEquals("{}", value);
}
public void testSerOptNull() throws Exception {
OptionalData data = new OptionalData();
data.myString = null;
String value = mapperWithModule().setSerializationInclusion(
JsonInclude.Include.NON_NULL).writeValueAsString(data);
assertEquals("{}", value);
}

public void testSerOptDisableAsNull() throws Exception {
final OptionalData data = new OptionalData();
data.myString = Optional.empty();
@SuppressWarnings("deprecation")
public void testSerOptDisableAsNull() throws Exception {
final OptionalData data = new OptionalData();
data.myString = Optional.empty();

Jdk8Module mod = new Jdk8Module().configureAbsentsAsNulls(false);
ObjectMapper mapper = new ObjectMapper().registerModule(mod)
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Jdk8Module mod = new Jdk8Module().configureAbsentsAsNulls(false);
ObjectMapper mapper = new ObjectMapper().registerModule(mod)
.setSerializationInclusion(JsonInclude.Include.NON_NULL);

assertEquals("{\"myString\":null}", mapper.writeValueAsString(data));
assertEquals("{\"myString\":null}", mapper.writeValueAsString(data));

// but do exclude with NON_EMPTY
mapper = new ObjectMapper().registerModule(mod)
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
assertEquals("{}", mapper.writeValueAsString(data));
// but do exclude with NON_EMPTY
mapper = new ObjectMapper().registerModule(mod)
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
assertEquals("{}", mapper.writeValueAsString(data));

// and with new (2.6) NON_ABSENT
mapper = new ObjectMapper().registerModule(mod)
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
assertEquals("{}", mapper.writeValueAsString(data));
}
// and with new (2.6) NON_ABSENT
mapper = new ObjectMapper().registerModule(mod)
.setSerializationInclusion(JsonInclude.Include.NON_ABSENT);
assertEquals("{}", mapper.writeValueAsString(data));
}

public void testSerOptNonEmpty() throws Exception {
OptionalData data = new OptionalData();
data.myString = null;
String value = mapperWithModule().setSerializationInclusion(
JsonInclude.Include.NON_EMPTY).writeValueAsString(data);
assertEquals("{}", value);
}
public void testSerOptNonEmpty() throws Exception {
OptionalData data = new OptionalData();
data.myString = null;
String value = mapperWithModule().setSerializationInclusion(
JsonInclude.Include.NON_EMPTY).writeValueAsString(data);
assertEquals("{}", value);
}

public void testWithTypingEnabled() throws Exception {
public void testWithTypingEnabled() throws Exception {
final ObjectMapper objectMapper = mapperWithModule();
// ENABLE TYPING
objectMapper.activateDefaultTyping(new NoCheckSubTypeValidator(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static BigDecimal toBigDecimal(long seconds, int nanoseconds)
}
return BigDecimal.valueOf(seconds).setScale(9);
}
return NumberInput.parseBigDecimal(toDecimal(seconds, nanoseconds));
return NumberInput.parseBigDecimal(toDecimal(seconds, nanoseconds), false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ protected T _fromString(JsonParser p, DeserializationContext ctxt,
return _fromLong(ctxt, NumberInput.parseLong(string));
}
if (dots == 1) {
return _fromDecimal(ctxt, NumberInput.parseBigDecimal(string));
return _fromDecimal(ctxt, NumberInput.parseBigDecimal(string, false));
}
} catch (NumberFormatException e) {
// fall through to default handling, to get error there
Expand Down

0 comments on commit f7780a4

Please sign in to comment.