This is an automated email from the ASF dual-hosted git repository.

jchen21 pushed a commit to branch feature/GEODE-6273
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/feature/GEODE-6273 by this 
push:
     new 995a8d5  Use "cluster" instead of null for group
995a8d5 is described below

commit 995a8d558ae4851eca79f2e45ab78145cefc04ae
Author: Jianxia Chen <[email protected]>
AuthorDate: Thu Jan 31 10:38:17 2019 -0800

    Use "cluster" instead of null for group
    
    Authored-by: Jianxia Chen <[email protected]>
---
 .../jdbc/internal/cli/DescribeMappingCommand.java  | 27 ++++++++++------------
 .../util/DescribeMappingCommandTest.java           |  4 ++--
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git 
a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommand.java
 
b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommand.java
index 8144778..e8a42f1 100644
--- 
a/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommand.java
+++ 
b/geode-connectors/src/main/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommand.java
@@ -56,7 +56,7 @@ public class DescribeMappingCommand extends GfshCommand {
   private static final String DESCRIBE_MAPPING__REGION_NAME__HELP =
       "Region name of the JDBC mapping to be described.";
   private static final String CREATE_MAPPING__GROUPS_NAME__HELP =
-      "Server Group of the JDBC mapping to be described.";
+      "Server Group(s) of the JDBC mapping to be described.";
 
   public static final String RESULT_SECTION_NAME = "MappingDescription";
 
@@ -77,17 +77,14 @@ public class DescribeMappingCommand extends GfshCommand {
 
     try {
       ConfigurationPersistenceService configService = 
checkForClusterConfiguration();
-      if (groups != null) {
-        for (String group : groups) {
-          CacheConfig cacheConfig = getCacheConfig(configService, group);
-          RegionConfig regionConfig = checkForRegion(regionName, cacheConfig, 
group);
-          describeMappingResults
-              .addAll(getMappingsFromRegionConfig(cacheConfig, regionConfig, 
group));
-        }
-      } else {
-        CacheConfig cacheConfig = getCacheConfig(configService, null);
-        RegionConfig regionConfig = checkForRegion(regionName, cacheConfig, 
null);
-        describeMappingResults.addAll(getMappingsFromRegionConfig(cacheConfig, 
regionConfig, null));
+      if (groups == null) {
+        groups = new String[] {ConfigurationPersistenceService.CLUSTER_CONFIG};
+      }
+      for (String group : groups) {
+        CacheConfig cacheConfig = getCacheConfig(configService, group);
+        RegionConfig regionConfig = checkForRegion(regionName, cacheConfig, 
group);
+        describeMappingResults
+            .addAll(getMappingsFromRegionConfig(cacheConfig, regionConfig, 
group));
       }
     } catch (PreconditionException ex) {
       return ResultModel.createError(ex.getMessage());
@@ -108,7 +105,7 @@ public class DescribeMappingCommand extends GfshCommand {
     CacheConfig result = configService.getCacheConfig(group);
     if (result == null) {
       throw new PreconditionException(
-          "Cache Configuration not found" + ((group == null) ? "." : " for 
group " + group + "."));
+          "Cache Configuration not found" + 
((group.equals(ConfigurationPersistenceService.CLUSTER_CONFIG)) ? "." : " for 
group " + group + "."));
     }
     return result;
   }
@@ -162,7 +159,7 @@ public class DescribeMappingCommand extends GfshCommand {
     for (int i = 0; i < describeMappingResult.size(); i++) {
       DataResultModel sectionModel = resultModel.addData(RESULT_SECTION_NAME + 
String.valueOf(i));
       DescribeMappingResult result = describeMappingResult.get(i);
-      if (result.getGroupName() != null) {
+      if 
(!result.getGroupName().equals(ConfigurationPersistenceService.CLUSTER_CONFIG)) 
{
         sectionModel.addData("Mapping for group", result.getGroupName());
       }
       result.getAttributeMap().forEach(sectionModel::addData);
@@ -184,7 +181,7 @@ public class DescribeMappingCommand extends GfshCommand {
     RegionConfig regionConfig = findRegionConfig(cacheConfig, regionName);
     if (regionConfig == null) {
       String groupClause = "A region named " + regionName + " must already 
exist"
-          + (groupName != null ? " for group " + groupName + "." : ".");
+          + (!groupName.equals(ConfigurationPersistenceService.CLUSTER_CONFIG) 
? " for group " + groupName + "." : ".");
       throw new PreconditionException(groupClause);
     }
     return regionConfig;
diff --git 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/org/apache/geode/connectors/util/DescribeMappingCommandTest.java
 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/org/apache/geode/connectors/util/DescribeMappingCommandTest.java
index 798c226..147f5e7 100644
--- 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/org/apache/geode/connectors/util/DescribeMappingCommandTest.java
+++ 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/org/apache/geode/connectors/util/DescribeMappingCommandTest.java
@@ -66,7 +66,7 @@ public class DescribeMappingCommandTest {
     clusterConfig = mock(CacheConfig.class);
     regionConfig = mock(RegionConfig.class);
     
when(command.getConfigurationPersistenceService()).thenReturn(configurationPersistenceService);
-    
when(configurationPersistenceService.getCacheConfig(null)).thenReturn(clusterConfig);
+    
when(configurationPersistenceService.getCacheConfig(ConfigurationPersistenceService.CLUSTER_CONFIG)).thenReturn(clusterConfig);
     ArrayList<RegionConfig> regionConfigList = new ArrayList<RegionConfig>();
     regionConfigList.add(regionConfig);
     when(clusterConfig.getRegions()).thenReturn(regionConfigList);
@@ -109,7 +109,7 @@ public class DescribeMappingCommandTest {
     regionMapping.setSchema("mySchema");
     ArrayList<CacheElement> elements = new ArrayList<>();
     elements.add(regionMapping);
-    
when(configurationPersistenceService.getCacheConfig(null)).thenReturn(null);
+    
when(configurationPersistenceService.getCacheConfig(ConfigurationPersistenceService.CLUSTER_CONFIG)).thenReturn(null);
 
     gfsh.executeAndAssertThat(command, COMMAND).statusIsError()
         .containsOutput("Cache Configuration not found.");

Reply via email to