Merge branch '2.1.x'

This commit is contained in:
Stephane Nicoll
2019-03-29 14:09:01 +01:00
2 changed files with 12 additions and 2 deletions

View File

@@ -84,7 +84,8 @@ public class GsonAutoConfiguration {
.toCall(builder::generateNonExecutableJson);
map.from(properties::getExcludeFieldsWithoutExposeAnnotation)
.toCall(builder::excludeFieldsWithoutExposeAnnotation);
map.from(properties::getSerializeNulls).toCall(builder::serializeNulls);
map.from(properties::getSerializeNulls).whenTrue()
.toCall(builder::serializeNulls);
map.from(properties::getEnableComplexMapKeySerialization)
.toCall(builder::enableComplexMapKeySerialization);
map.from(properties::getDisableInnerClassSerialization)

View File

@@ -80,7 +80,7 @@ public class GsonAutoConfigurationTests {
}
@Test
public void serializeNulls() {
public void serializeNullsTrue() {
this.contextRunner.withPropertyValues("spring.gson.serialize-nulls:true")
.run((context) -> {
Gson gson = context.getBean(Gson.class);
@@ -88,6 +88,15 @@ public class GsonAutoConfigurationTests {
});
}
@Test
public void serializeNullsFalse() {
this.contextRunner.withPropertyValues("spring.gson.serialize-nulls:false")
.run((context) -> {
Gson gson = context.getBean(Gson.class);
assertThat(gson.serializeNulls()).isFalse();
});
}
@Test
public void enableComplexMapKeySerialization() {
this.contextRunner