Skip to content

Commit

Permalink
Minor post-merge cleanup wrt #3053
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 10, 2023
1 parent d8922be commit 642bcea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ public enum EnumFeature implements DatatypeFeature
* Enum values: if enabled, return value of <code>Enum.name().toLowerCase()</code>
* is used; if disabled, return value of <code>Enum.name()</code> is used.
*<p>
* NOTE: this feature CAN NOT be changed on per-call basis: it will have to
* be set on {@code ObjectMapper} before use
*<p>
* Feature is disabled by default.
*
* @since 2.15
*/
WRITE_ENUMS_TO_LOWERCASE(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ public void testEnumWithJsonKey() throws Exception
assertEquals(a2q("{'key:a':'value:b'}"), MAPPER.writeValueAsString(input2));
}

// [databind#3053]
public void testEnumFeature_WRITE_ENUMS_TO_LOWERCASE_isDisabledByDefault() {
ObjectReader READER = MAPPER.reader();
assertFalse(READER.isEnabled(EnumFeature.WRITE_ENUMS_TO_LOWERCASE));
Expand All @@ -343,12 +344,8 @@ public void testEnumFeature_WRITE_ENUMS_TO_LOWERCASE() throws Exception {
ObjectMapper m = jsonMapperBuilder()
.configure(EnumFeature.WRITE_ENUMS_TO_LOWERCASE, true)
.build();
assertEquals("\"b\"", m.writeValueAsString(TestEnum.B));

// [databind#749] but should also be able to dynamically disable
assertEquals("\"B\"",
m.writer().without(EnumFeature.WRITE_ENUMS_TO_LOWERCASE)
.writeValueAsString(LowerCaseEnum.B));
assertEquals(q("b"), m.writeValueAsString(TestEnum.B));
// NOTE: cannot be dynamically changed
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void testEnumResolver()
assertEquals(ABC.C, enums.get(2));
}

// [databind#3053]
@SuppressWarnings("unchecked")
public void testConstructFromNameLowerCased() {
SerializationConfig cfg = MAPPER.getSerializationConfig()
Expand Down

0 comments on commit 642bcea

Please sign in to comment.