Exclude null and empty properties from /autoconfig

pull/300/head
Dave Syer 11 years ago
parent a21397dbe2
commit 2bd6026a2a

@ -32,6 +32,8 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonPropertyOrder; import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/** /**
@ -60,6 +62,7 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
* Adapts {@link AutoConfigurationReport} to a JSON friendly structure. * Adapts {@link AutoConfigurationReport} to a JSON friendly structure.
*/ */
@JsonPropertyOrder({ "positiveMatches", "negativeMatches" }) @JsonPropertyOrder({ "positiveMatches", "negativeMatches" })
@JsonInclude(Include.NON_EMPTY)
public static class Report { public static class Report {
private MultiValueMap<String, MessageAndCondition> positiveMatches; private MultiValueMap<String, MessageAndCondition> positiveMatches;

@ -112,9 +112,7 @@ public class AutoConfigurationReportTests {
this.beanFactory.setParentBeanFactory(new DefaultListableBeanFactory()); this.beanFactory.setParentBeanFactory(new DefaultListableBeanFactory());
AutoConfigurationReport.get((ConfigurableListableBeanFactory) this.beanFactory AutoConfigurationReport.get((ConfigurableListableBeanFactory) this.beanFactory
.getParentBeanFactory()); .getParentBeanFactory());
this.report = AutoConfigurationReport.get(this.beanFactory); // NB: overrides this.report = AutoConfigurationReport.get(this.beanFactory);
// setup
assertThat(this.report, not(nullValue())); assertThat(this.report, not(nullValue()));
assertThat(this.report, not(sameInstance(this.report.getParent()))); assertThat(this.report, not(sameInstance(this.report.getParent())));
assertThat(this.report.getParent(), not(nullValue())); assertThat(this.report.getParent(), not(nullValue()));

Loading…
Cancel
Save