sabbey37 commented on a change in pull request #5756:
URL: https://github.com/apache/geode/pull/5756#discussion_r526224249



##########
File path: 
geode-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/server/AbstractInfoIntegrationTest.java
##########
@@ -182,10 +295,9 @@ public void 
shouldNotReturnKeySpaceSection_givenServerWithNoKeys() {
   }
 
   @Test
-  public void shouldThrowExceptionIfGivenMoreThanOneParameter() {
+  public void shouldThrowException_ifGivenMoreThanOneParameter() {
     assertThatThrownBy(
         () -> jedis.sendCommand(
             Protocol.Command.INFO, "Server", 
"Cluster")).hasMessageContaining("ERR syntax error");

Review comment:
       If you end up making changes anyway, we could also change this to 
`hasMessage()` instead of `hasMessageContaining()` so we check the exact 
message.

##########
File path: 
geode-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/server/AbstractInfoIntegrationTest.java
##########
@@ -98,71 +152,130 @@ public void shouldReturnClusterEnabledProperty() {
     assertThat(actualResult).contains(expectedResult);
   }
 
-  final List<String> SERVER_PROPERTIES =
-      Arrays.asList(
-          "# Server",
-          "redis_version:",
-          "tcp_port:",
-          "redis_mode:");
-
-  final List<String> PERSISTENCE_PROPERTIES =
-      Arrays.asList(
-          "# Persistence",
-          "loading:");
-
-  final List<String> CLUSTER_PROPERTIES =
-      Arrays.asList(
-          "# Cluster",
-          "cluster_enabled:");
-
   @Test
-  public void shouldReturnServerSectionsGivenServerSectionParameter() {
+  public void shouldReturnServerSections_givenServerSectionParameter() {
+    List<String> nonServerProperties = getAllProperties();
+    nonServerProperties.removeAll(SERVER_PROPERTIES);
+
     String actualResult = jedis.info("server");
 
     assertThat(actualResult).contains(SERVER_PROPERTIES);
-    assertThat(actualResult).doesNotContain(CLUSTER_PROPERTIES);
-    assertThat(actualResult).doesNotContain(PERSISTENCE_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonServerProperties);
   }
 
   @Test
-  public void shouldReturnClusterSectionsGivenClusterSectionParameter() {
+  public void shouldReturnClusterSections_givenClusterSectionParameter() {
+    List<String> nonClusterProperties = getAllProperties();
+    nonClusterProperties.removeAll(CLUSTER_PROPERTIES);
+
     String actualResult = jedis.info("cluster");
 
     assertThat(actualResult).contains(CLUSTER_PROPERTIES);
-    assertThat(actualResult).doesNotContain(SERVER_PROPERTIES);
-    assertThat(actualResult).doesNotContain(PERSISTENCE_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonClusterProperties);
   }
 
   @Test
-  public void 
shouldReturnPersistenceSectionsGivenPersistenceSectionParameter() {
+  public void 
shouldReturnPersistenceSections_givenPersistenceSectionParameter() {
+    List<String> nonPersistenceProperties = getAllProperties();
+    nonPersistenceProperties.removeAll(PERSISTENCE_PROPERTIES);
+
     String actualResult = jedis.info("persistence");
 
     assertThat(actualResult).contains(PERSISTENCE_PROPERTIES);
-    assertThat(actualResult).doesNotContain(SERVER_PROPERTIES);
-    assertThat(actualResult).doesNotContain(CLUSTER_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonPersistenceProperties);
+  }
+
+  @Test
+  public void shouldReturnStatsSections_givenStatsSectionParameter() {
+    List<String> nonStatsProperties = getAllProperties();
+    nonStatsProperties.removeAll(STATS_PROPERTIES);
+
+    String actualResult = jedis.info("stats");
+
+    assertThat(actualResult).contains(STATS_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonStatsProperties);
+  }
+
+  @Test
+  public void shouldReturnClientsSections_givenClientsSectionParameter() {
+    List<String> nonClientsProperties = getAllProperties();
+    nonClientsProperties.removeAll(CLIENTS_PROPERTIES);
+
+    String actualResult = jedis.info("clients");
+
+    assertThat(actualResult).contains(CLIENTS_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonClientsProperties);
   }
 
   @Test
-  public void shouldReturnEmptyStringGivenUnknownParameter() {
+  public void shouldReturnMemorySections_givenMemorySectionParameter() {
+    List<String> nonMemoryProperties = getAllProperties();
+    nonMemoryProperties.removeAll(MEMORY_PROPERTIES);
+
+    String actualResult = jedis.info("memory");
+
+    assertThat(actualResult).contains(MEMORY_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonMemoryProperties);
+  }
+
+  @Test
+  public void shouldReturnKeySpaceSections_givenKeySpaceKeyspaceParameter() {
+    List<String> nonKeyspaceProperties = getAllProperties();
+    nonKeyspaceProperties.removeAll(KEYSPACE_PROPERTIES);
+
+    jedis.set("key", "value");
+    String actualResult = jedis.info("keyspace");
+
+    assertThat(actualResult).contains(KEYSPACE_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonKeyspaceProperties);
+  }
+
+  @Test
+  public void 
shouldReturnReplicationSections_givenKeySpaceReplicationParameter() {
+    List<String> nonReplicationProperties = getAllProperties();
+    nonReplicationProperties.removeAll(REPLICATION_PROPERTIES);
+
+    String actualResult = jedis.info("replication");
+
+    assertThat(actualResult).contains(REPLICATION_PROPERTIES);
+    assertThat(actualResult).doesNotContain(nonReplicationProperties);
+  }
+
+  @Test
+  public void shouldReturnEmptyString_givenUnknownParameter() {
     String actualResult = jedis.info("nonesuch");
     assertThat(actualResult).isEqualTo("");
   }
 
-
   @Test
-  public void shouldReturnDefaultsGivenDefaultParameter() {
+  public void shouldReturnDefaults_givenDefaultParameter() {
+    jedis.set("key", "value");
     String actualResult = jedis.info("default");
-    assertThat(actualResult).contains(CLUSTER_PROPERTIES);
-    assertThat(actualResult).contains(SERVER_PROPERTIES);
-    assertThat(actualResult).contains(PERSISTENCE_PROPERTIES);
+    assertThat(actualResult)
+        .contains(getAllProperties());
   }
 
   @Test
-  public void shouldReturnDefaultsGivenAllParameter() {
+  public void shouldReturnDefaults_givenAllParameters() {
+    jedis.set("key", "value"); // make sure keyspace is there
     String actualResult = jedis.info("all");
-    assertThat(actualResult).contains(CLUSTER_PROPERTIES);
-    assertThat(actualResult).contains(SERVER_PROPERTIES);
-    assertThat(actualResult).contains(PERSISTENCE_PROPERTIES);
+    assertThat(actualResult)
+        .contains(getAllProperties());
+  }
+
+  private List<String> getAllProperties() {
+    List<String> allProperties = new ArrayList<>();
+
+    allProperties.addAll(STATS_PROPERTIES);
+    allProperties.addAll(KEYSPACE_PROPERTIES);
+    allProperties.addAll(MEMORY_PROPERTIES);
+    allProperties.addAll(CLIENTS_PROPERTIES);
+    allProperties.addAll(CLUSTER_PROPERTIES);
+    allProperties.addAll(PERSISTENCE_PROPERTIES);
+    allProperties.addAll(SERVER_PROPERTIES);
+    allProperties.addAll(REPLICATION_PROPERTIES);
+
+    return allProperties;
   }

Review comment:
       It seems like you could do away with this method and just have 
`allProperties` as a constant since the properties that are added to the list 
never change.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to