[ 
https://issues.apache.org/jira/browse/GEODE-4161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16312236#comment-16312236
 ] 

ASF GitHub Bot commented on GEODE-4161:
---------------------------------------

dschneider-pivotal closed pull request #1225: GEODE-4161: fix gfsh describe 
jdbc-mapping
URL: https://github.com/apache/geode/pull/1225
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 b48f51dd7b..3076fa4098 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
@@ -102,9 +102,11 @@ private void fillResultData(RegionMapping mapping, 
CompositeResultData resultDat
 
     TabularResultData tabularResultData = 
sectionResult.addTable(FIELD_TO_COLUMN_TABLE);
     tabularResultData.setHeader("Field to Column Mappings:");
-    mapping.getFieldToColumnMap().entrySet().forEach((entry) -> {
-      tabularResultData.accumulate("Field", entry.getKey());
-      tabularResultData.accumulate("Column", entry.getValue());
-    });
+    if (mapping.getFieldToColumnMap() != null) {
+      mapping.getFieldToColumnMap().entrySet().forEach((entry) -> {
+        tabularResultData.accumulate("Field", entry.getKey());
+        tabularResultData.accumulate("Column", entry.getValue());
+      });
+    }
   }
 }
diff --git 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommandIntegrationTest.java
 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommandIntegrationTest.java
index fcc366f7ac..3aadfa5712 100644
--- 
a/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommandIntegrationTest.java
+++ 
b/geode-connectors/src/test/java/org/apache/geode/connectors/jdbc/internal/cli/DescribeMappingCommandIntegrationTest.java
@@ -110,4 +110,35 @@ public void displaysMappingInformationWhenMappingExists() 
throws Exception {
       
assertThat(tableContent.get("Column").toString()).contains(entry.getValue());
     });
   }
+
+  @Test
+  public void 
displaysMappingInformationWhenMappingWithNoFieldToColumnsExists() throws 
Exception {
+    regionMapping = new RegionMappingBuilder().withRegionName(REGION_NAME)
+        .withConnectionConfigName("connection").withTableName("testTable")
+        
.withPdxClassName("myPdxClass").withPrimaryKeyInValue(true).withFieldToColumnMappings(null)
+        .build();
+    service.createRegionMapping(regionMapping);
+    Result result = command.describeMapping(REGION_NAME);
+
+    assertThat(result.getStatus()).isSameAs(Result.Status.OK);
+    CommandResult commandResult = (CommandResult) result;
+    GfJsonObject sectionContent = commandResult.getTableContent()
+        .getJSONObject(SECTION_DATA_ACCESSOR + "-" + RESULT_SECTION_NAME);
+
+    assertThat(sectionContent.get(CREATE_MAPPING__REGION_NAME))
+        .isEqualTo(regionMapping.getRegionName());
+    assertThat(sectionContent.get(CREATE_MAPPING__CONNECTION_NAME))
+        .isEqualTo(regionMapping.getConnectionConfigName());
+    assertThat(sectionContent.get(CREATE_MAPPING__TABLE_NAME))
+        .isEqualTo(regionMapping.getTableName());
+    assertThat(sectionContent.get(CREATE_MAPPING__PDX_CLASS_NAME))
+        .isEqualTo(regionMapping.getPdxClassName());
+    assertThat(sectionContent.get(CREATE_MAPPING__VALUE_CONTAINS_PRIMARY_KEY))
+        .isEqualTo(regionMapping.isPrimaryKeyInValue());
+
+    GfJsonObject tableContent = sectionContent
+        .getJSONObject(TABLE_DATA_ACCESSOR + "-" + 
FIELD_TO_COLUMN_TABLE).getJSONObject("content");
+    assertThat(tableContent.get("Field")).isNull();
+    assertThat(tableContent.get("Column")).isNull();
+  }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> gfsh describe jdbc-mapping command errors describing a valid mapping
> --------------------------------------------------------------------
>
>                 Key: GEODE-4161
>                 URL: https://issues.apache.org/jira/browse/GEODE-4161
>             Project: Geode
>          Issue Type: Bug
>          Components: regions
>    Affects Versions: 1.4.0
>            Reporter: Fred Krone
>            Assignee: Darrel Schneider
>
> Steps to reproduce issue:
> 1) create a jdbc-mapping
> 2) describe that jdbc-mapping
> 3) you get an error even though the mapping exists (via list mapping, etc)
> gfsh>describe jdbc-mapping --region=employee
> Could not process command due to error. Error while processing command 
> <describe jdbc-mapping --region=employee> Reason : null



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to