geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [geode] branch develop updated: GEODE-6612: do not show null value or empty list in the management v2 … (#3462)
Date Mon, 15 Apr 2019 19:18:31 GMT
This is an automated email from the ASF dual-hosted git repository.

jinmeiliao pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 1631f86  GEODE-6612: do not show null value or empty list in the management v2 …
(#3462)
1631f86 is described below

commit 1631f86dcab96de665829c261980d4895a0ffc15
Author: jinmeiliao <jiliao@pivotal.io>
AuthorDate: Mon Apr 15 12:18:20 2019 -0700

    GEODE-6612: do not show null value or empty list in the management v2 … (#3462)
---
 .../main/java/org/apache/geode/util/internal/GeodeJsonMapper.java | 2 ++
 .../management/internal/api/ClusterManagementResultTest.java      | 8 ++++++++
 .../geode/cache/configuration/CacheElementJsonMappingTest.java    | 2 +-
 .../geode/management/client/MemberManagementServiceDUnitTest.java | 4 +---
 .../geode/management/internal/rest/ManagementLoggingFilter.java   | 1 -
 .../src/main/webapp/WEB-INF/geode-management-servlet.xml          | 2 +-
 6 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/geode-common/src/main/java/org/apache/geode/util/internal/GeodeJsonMapper.java
b/geode-common/src/main/java/org/apache/geode/util/internal/GeodeJsonMapper.java
index 7fd8f91..2b0b632 100644
--- a/geode-common/src/main/java/org/apache/geode/util/internal/GeodeJsonMapper.java
+++ b/geode-common/src/main/java/org/apache/geode/util/internal/GeodeJsonMapper.java
@@ -15,6 +15,7 @@
 
 package org.apache.geode.util.internal;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.databind.MapperFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -32,6 +33,7 @@ public class GeodeJsonMapper {
     ObjectMapper mapper = new ObjectMapper();
     mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
     mapper.configure(MapperFeature.USE_BASE_TYPE_AS_DEFAULT_IMPL, true);
+    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
     return mapper;
   }
 }
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java
b/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java
index 07d6825..868c15f 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/api/ClusterManagementResultTest.java
@@ -25,6 +25,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import org.apache.geode.management.api.ClusterManagementResult;
+import org.apache.geode.util.internal.GeodeJsonMapper;
 
 public class ClusterManagementResultTest {
   private ClusterManagementResult result;
@@ -103,6 +104,13 @@ public class ClusterManagementResultTest {
     result.addMemberStatus("member-2", false, "message-2");
     assertThat(result.isSuccessful()).isFalse();
     assertThat(result.getStatusCode()).isEqualTo(ERROR);
+  }
 
+  @Test
+  public void deserialize() throws Exception {
+    String json = "{\"statusCode\":\"OK\"}";
+    ClusterManagementResult result =
+        GeodeJsonMapper.getMapper().readValue(json, ClusterManagementResult.class);
+    assertThat(result.getResult()).isNotNull().isEmpty();
   }
 }
diff --git a/geode-management/src/test/java/org/apache/geode/cache/configuration/CacheElementJsonMappingTest.java
b/geode-management/src/test/java/org/apache/geode/cache/configuration/CacheElementJsonMappingTest.java
index 10f6c83..c244e00 100644
--- a/geode-management/src/test/java/org/apache/geode/cache/configuration/CacheElementJsonMappingTest.java
+++ b/geode-management/src/test/java/org/apache/geode/cache/configuration/CacheElementJsonMappingTest.java
@@ -106,6 +106,6 @@ public class CacheElementJsonMappingTest {
     assertThat(region.getConfigGroup()).isEqualTo("cluster");
 
     String json = mapper.writeValueAsString(region);
-    assertThat(json).contains("\"group\":null");
+    assertThat(json).doesNotContain("\"group\"");
   }
 }
diff --git a/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java
b/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java
index 7069977..5a762f9 100644
--- a/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java
+++ b/geode-web-management/src/distributedTest/java/org/apache/geode/management/client/MemberManagementServiceDUnitTest.java
@@ -18,7 +18,6 @@ package org.apache.geode.management.client;
 
 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
 import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.iterableWithSize;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -104,8 +103,7 @@ public class MemberManagementServiceDUnitTest {
   public void noMatchWithFilter() throws Exception {
     webContext.perform(get("/v2/members?id=server"))
         .andExpect(status().isOk())
-        .andExpect(jsonPath("$.statusCode", is("OK")))
-        .andExpect(jsonPath("$.result", iterableWithSize(0)));
+        .andExpect(jsonPath("$.statusCode", is("OK")));
   }
 
   @Test
diff --git a/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/ManagementLoggingFilter.java
b/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/ManagementLoggingFilter.java
index 7f02b79..3e43dc1 100644
--- a/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/ManagementLoggingFilter.java
+++ b/geode-web-management/src/main/java/org/apache/geode/management/internal/rest/ManagementLoggingFilter.java
@@ -82,7 +82,6 @@ public class ManagementLoggingFilter extends OncePerRequestFilter {
     String responsePattern = "Management Response: Status=%s; response=%s";
     String payload = getContentAsString(wrappedResponse.getContentAsByteArray(),
         wrappedResponse.getCharacterEncoding());
-    payload = payload.replaceAll(System.lineSeparator(), "");
     logger.info(String.format(responsePattern, response.getStatus(), payload));
   }
 
diff --git a/geode-web-management/src/main/webapp/WEB-INF/geode-management-servlet.xml b/geode-web-management/src/main/webapp/WEB-INF/geode-management-servlet.xml
index a2cc948..639e763 100644
--- a/geode-web-management/src/main/webapp/WEB-INF/geode-management-servlet.xml
+++ b/geode-web-management/src/main/webapp/WEB-INF/geode-management-servlet.xml
@@ -58,7 +58,6 @@
   
   <bean id="objectMapper" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"
         p:failOnEmptyBeans="true"
-        p:indentOutput="true"
         p:simpleDateFormat="MM/dd/yyyy"
     >
     <property name="featuresToEnable">
@@ -74,6 +73,7 @@
         <util:constant static-field="com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES"/>
       </array>
     </property>
+    <property name="serializationInclusion" value="NON_EMPTY"/>
   </bean>
 
   <bean class="org.apache.geode.management.internal.rest.security.RestSecurityConfiguration"/>


Mime
View raw message