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

jensdeppe 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 4d8ae71  GEODE-5088: Remove getContentAsString from CommandResult 
(#1809)
4d8ae71 is described below

commit 4d8ae7117b4e1c40793dea252014bd12e6951cad
Author: Jens Deppe <[email protected]>
AuthorDate: Tue Apr 17 07:54:21 2018 -0700

    GEODE-5088: Remove getContentAsString from CommandResult (#1809)
---
 .../internal/cli/result/CommandResult.java         |  4 ----
 .../commands/CreateDefinedIndexesCommandTest.java  |  8 ++++----
 .../cli/commands/CreateIndexCommandTest.java       | 14 +++++++-------
 .../cli/commands/CreateRegionCommandTest.java      | 22 +++++++++++-----------
 .../cli/commands/ShowMetricsJUnitTest.java         |  6 +++---
 .../ClusterConfigImportDUnitTest.java              |  6 +++---
 .../security/GfshCommandsSecurityTest.java         | 10 +++++-----
 .../internal/security/MultiGfshDUnitTest.java      |  2 +-
 .../geode/test/junit/rules/GfshCommandRule.java    |  2 +-
 9 files changed, 35 insertions(+), 39 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
index b6e8903..31a57d4 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
@@ -445,10 +445,6 @@ public class CommandResult implements Result {
     return gfJsonObject.getJSONObject(ResultData.RESULT_CONTENT);
   }
 
-  public String getContentAsString() {
-    return getContent().toString();
-  }
-
   public String getMessageFromContent() {
     return getContent().getString("message");
   }
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandTest.java
index f03dd9c..8ef228d 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateDefinedIndexesCommandTest.java
@@ -69,7 +69,7 @@ public class CreateDefinedIndexesCommandTest {
   public void noDefinitions() throws Exception {
     result = gfshParser.executeCommandWithInstance(command, "create defined 
indexes");
     assertThat(result.getStatus()).isEqualTo(OK);
-    assertThat(result.getContentAsString()).contains("No indexes defined");
+    assertThat(result.getMessageFromContent()).contains("No indexes defined");
   }
 
   @Test
@@ -79,7 +79,7 @@ public class CreateDefinedIndexesCommandTest {
     doReturn(Collections.EMPTY_SET).when(command).findMembers(any(), any());
     result = gfshParser.executeCommandWithInstance(command, "create defined 
indexes");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("No Members Found");
+    assertThat(result.getMessageFromContent()).contains("No Members Found");
   }
 
   @Test
@@ -122,7 +122,7 @@ public class CreateDefinedIndexesCommandTest {
     assertThat(result.getStatus()).isEqualTo(OK);
     assertThat(result.failedToPersist()).isFalse();
     verify(command, Mockito.times(1)).persistClusterConfiguration(any(), 
any());
-    assertThat(result.getContentAsString()).contains("Indexes successfully 
created");
+    assertThat(result.getMessageFromContent()).contains("Indexes successfully 
created");
   }
 
   @Test
@@ -164,6 +164,6 @@ public class CreateDefinedIndexesCommandTest {
     // The command will receive 4 results from 2 members, but we need to 
persist only 2 (#regions)
     // of them.
     verify(command, Mockito.times(2)).persistClusterConfiguration(any(), 
any());
-    assertThat(result.getContentAsString()).contains("Indexes successfully 
created");
+    assertThat(result.getMessageFromContent()).contains("Indexes successfully 
created");
   }
 }
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateIndexCommandTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateIndexCommandTest.java
index 132068f..b3645e9 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateIndexCommandTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateIndexCommandTest.java
@@ -64,14 +64,14 @@ public class CreateIndexCommandTest {
     result = gfshParser.executeCommandWithInstance(command,
         "create index --expression=abc --region=abc");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 
   @Test
   public void missingExpression() throws Exception {
     result = gfshParser.executeCommandWithInstance(command, "create index 
--name=abc --region=abc");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 
   @Test
@@ -79,7 +79,7 @@ public class CreateIndexCommandTest {
     result =
         gfshParser.executeCommandWithInstance(command, "create index 
--name=abc --expression=abc");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 
   @Test
@@ -87,7 +87,7 @@ public class CreateIndexCommandTest {
     result = gfshParser.executeCommandWithInstance(command,
         "create index --name=abc --expression=abc --region=abc --type=abc");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 
   @Test
@@ -96,7 +96,7 @@ public class CreateIndexCommandTest {
     result = gfshParser.executeCommandWithInstance(command,
         "create index --name=abc --expression=abc --region=abc --type=range");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("No Members Found");
+    assertThat(result.getMessageFromContent()).contains("No Members Found");
   }
 
   @Test
@@ -105,7 +105,7 @@ public class CreateIndexCommandTest {
     result = gfshParser.executeCommandWithInstance(command,
         "create index --name=abc --expression=abc --region=abc --type=hash");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("No Members Found");
+    assertThat(result.getMessageFromContent()).contains("No Members Found");
   }
 
   @Test
@@ -114,7 +114,7 @@ public class CreateIndexCommandTest {
     result = gfshParser.executeCommandWithInstance(command,
         "create index --name=abc --expression=abc --region=abc");
     assertThat(result.getStatus()).isEqualTo(ERROR);
-    assertThat(result.getContentAsString()).contains("No Members Found");
+    assertThat(result.getMessageFromContent()).contains("No Members Found");
   }
 
   @Test
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
index e855b82..e20fdba 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
@@ -82,7 +82,7 @@ public class CreateRegionCommandTest {
   public void missingName() throws Exception {
     CommandResult result = parser.executeCommandWithInstance(command, "create 
region");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 
   @Test
@@ -90,7 +90,7 @@ public class CreateRegionCommandTest {
     CommandResult result =
         parser.executeCommandWithInstance(command, "create region 
--name=region");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("One of \\\"type\\\" or \\\"template-region\\\" is 
required.");
   }
 
@@ -99,7 +99,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE 
--template-region=regionB");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("Only one of type & template-region can be specified.");
   }
 
@@ -108,7 +108,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE 
--eviction-action=invalidAction");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("eviction-action must be 'local-destroy' or 
'overflow-to-disk'");
   }
 
@@ -117,7 +117,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE 
--eviction-max-memory=1000 --eviction-entry-count=200");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("eviction-max-memory and eviction-entry-count cannot both be 
specified.");
   }
 
@@ -126,7 +126,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE 
--eviction-max-memory=1000");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString()).contains("eviction-action must be 
specified.");
+    assertThat(result.getMessageFromContent()).contains("eviction-action must 
be specified.");
   }
 
   @Test
@@ -134,7 +134,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE --eviction-entry-count=1 
--eviction-object-sizer=abc --eviction-action=local-destroy");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("eviction-object-sizer cannot be specified with 
eviction-entry-count");
   }
 
@@ -147,7 +147,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --template-region=regionA");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("Could not retrieve region attributes for given path");
   }
 
@@ -330,7 +330,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE --compressor=abc-def");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString()).contains("abc-def is an invalid 
Compressor.");
+    assertThat(result.getMessageFromContent()).contains("abc-def is an invalid 
Compressor.");
   }
 
   @Test
@@ -338,7 +338,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE --key-type=abc-def");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 
   @Test
@@ -346,7 +346,7 @@ public class CreateRegionCommandTest {
     CommandResult result = parser.executeCommandWithInstance(command,
         "create region --name=region --type=REPLICATE --value-type=abc-def");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 
   @Test
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsJUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsJUnitTest.java
index 4a2f0b1..f1e9841 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsJUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsJUnitTest.java
@@ -38,7 +38,7 @@ public class ShowMetricsJUnitTest {
     CommandResult result =
         parser.executeCommandWithInstance(command, "show metrics --port=0 
--region=regionA");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("The --region and --port parameters are mutually exclusive");
   }
 
@@ -47,7 +47,7 @@ public class ShowMetricsJUnitTest {
     ShowMetricsCommand command = spy(ShowMetricsCommand.class);
     CommandResult result = parser.executeCommandWithInstance(command, "show 
metrics --port=0");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString()).contains(
+    assertThat(result.getMessageFromContent()).contains(
         "If the --port parameter is specified, then the --member parameter 
must also be specified.");
   }
 
@@ -57,6 +57,6 @@ public class ShowMetricsJUnitTest {
     CommandResult result = parser.executeCommandWithInstance(command, "show 
metrics --port=abc");
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
     // When relying on Spring's converters, any command that does not parse is 
"Invalid"
-    assertThat(result.getContentAsString()).contains("Invalid command");
+    assertThat(result.getMessageFromContent()).contains("Invalid command");
   }
 }
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index 7250a2b..717b1e9 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -80,7 +80,7 @@ public class ClusterConfigImportDUnitTest extends 
ClusterConfigTestBase {
         .executeCommand("import cluster-configuration --zip-file-name=" + 
clusterConfigZipPath);
 
     assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
-    assertThat(result.getContentAsString()).contains("existing regions: " + 
regionName);
+    assertThat(result.getMessageFromContent()).contains("existing regions: " + 
regionName);
   }
 
   @Test
@@ -92,9 +92,9 @@ public class ClusterConfigImportDUnitTest extends 
ClusterConfigTestBase {
 
     CommandResult result = gfshConnector
         .executeCommand("import cluster-configuration --zip-file-name=" + 
clusterConfigZipPath);
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("Successfully applied the imported cluster configuration on 
server-1");
-    assertThat(result.getContentAsString())
+    assertThat(result.getMessageFromContent())
         .contains("Successfully applied the imported cluster configuration on 
server-2");
     new ClusterConfig(CLUSTER).verify(server1);
     new ClusterConfig(CLUSTER, GROUP2).verify(server2);
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index e3d13b1..f3dc402 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -137,7 +137,7 @@ public class GfshCommandsSecurityTest {
 
       // for permitted commands, if any error happens, it's not an 
Unauthorized error
       if (result.getStatus() == Result.Status.ERROR) {
-        assertThat(result.getContentAsString()).doesNotContain("not 
authorized");
+        assertThat(result.getMessageFromContent()).doesNotContain("not 
authorized");
       }
     }
 
@@ -152,7 +152,7 @@ public class GfshCommandsSecurityTest {
       // for some commands there are pre execution checks to check for user 
input error, will skip
       // those commands
       if (errorCode == ResultBuilder.ERRORCODE_USER_ERROR) {
-        LogService.getLogger().info("Skip user error: " + 
result.getContentAsString());
+        LogService.getLogger().info("Skip user error: " + 
result.getMessageFromContent());
         continue;
       }
 
@@ -178,7 +178,7 @@ public class GfshCommandsSecurityTest {
     CommandResult result =
         gfshConnection.executeCommand("create disk-store --name=disk1 
--dir=disk1");
 
-    assertThat(result.getContentAsString()).contains("not authorized for 
CLUSTER:MANAGE:DISK");
+    assertThat(result.getMessageFromContent()).contains("not authorized for 
CLUSTER:MANAGE:DISK");
   }
 
   @Test
@@ -195,7 +195,7 @@ public class GfshCommandsSecurityTest {
     CommandResult result =
         gfshConnection.executeCommand("create region --name=region2 
--type=PARTITION_PERSISTENT");
 
-    assertThat(result.getContentAsString()).contains("not authorized for 
CLUSTER:WRITE:DISK");
+    assertThat(result.getMessageFromContent()).contains("not authorized for 
CLUSTER:WRITE:DISK");
   }
 
   @Test
@@ -204,7 +204,7 @@ public class GfshCommandsSecurityTest {
     CommandResult result =
         gfshConnection.executeCommand("create region --name=region2 
--type=PARTITION_PERSISTENT");
 
-    assertThat(result.getContentAsString()).contains("not authorized for 
DATA:MANAGE");
+    assertThat(result.getMessageFromContent()).contains("not authorized for 
DATA:MANAGE");
   }
 
 }
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiGfshDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiGfshDUnitTest.java
index e50b981..d846197 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiGfshDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/security/MultiGfshDUnitTest.java
@@ -98,7 +98,7 @@ public class MultiGfshDUnitTest {
         // for some commands there are pre execution checks to check for user 
input error, will skip
         // those commands
         if (errorCode == ResultBuilder.ERRORCODE_USER_ERROR) {
-          LogService.getLogger().info("Skip user error: " + 
result.getContentAsString());
+          LogService.getLogger().info("Skip user error: " + 
result.getMessageFromContent());
           continue;
         }
 
diff --git 
a/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java
 
b/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java
index 3e80333..527662b 100644
--- 
a/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java
+++ 
b/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshCommandRule.java
@@ -228,7 +228,7 @@ public class GfshCommandRule extends 
DescribedExternalResource {
       throw new RuntimeException(e);
     }
     if (StringUtils.isBlank(gfsh.outputString) && result != null
-        && !result.getContentAsString().isEmpty()) {
+        && !result.getMessageFromContent().isEmpty()) {
       if (result.getStatus() == Result.Status.ERROR) {
         gfsh.outputString = result.toString();
       } else {

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to