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

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

pdxrunner commented on a change in pull request #1040: GEODE-3539: cleanup 
GfshCommand and refactor tests
URL: https://github.com/apache/geode/pull/1040#discussion_r150106964
 
 

 ##########
 File path: 
geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandTest.java
 ##########
 @@ -73,4 +83,35 @@ public void whenNoRegionIsFoundOnAnyMembers() throws 
Exception {
     result = parser.executeCommandWithInstance(command, "destroy region 
--name=test --if-exists");
     assertThat(result.getStatus()).isEqualTo(Result.Status.OK);
   }
+
+  @Test
+  public void multipleResultReturnedWithOneError() throws Exception {
+    // mock this to pass the member search call
+    doReturn(Collections.singleton(DistributedMember.class)).when(command)
+        .findMembersForRegion(any(), any());
+
+    ResultCollector collector = mock(ResultCollector.class);
+    doReturn(collector).when(command).executeFunction(any(), any(), 
any(Set.class));
+
+    List<CliFunctionResult> functionResults = new ArrayList<>();
+    doReturn(functionResults).when(collector).getResult();
+    CliFunctionResult result1 = mock(CliFunctionResult.class);
+    CliFunctionResult result2 = mock(CliFunctionResult.class);
+    functionResults.add(result1);
+    functionResults.add(result2);
+
+    when(result1.isSuccessful()).thenReturn(true);
+    when(result1.getMessage()).thenReturn("result1 message");
+    when(result1.getXmlEntity()).thenReturn(mock(XmlEntity.class));
+
+    when(result2.isSuccessful()).thenReturn(false);
+    when(result2.getMessage()).thenReturn("result2 message");
+
+    result = parser.executeCommandWithInstance(command, "destroy region 
--name=test");
+    assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+    assertThat(result.getContent().toString()).contains("result2 message");
+
+    // verify that xmlEntiry returned by the result1 is not saved to Cluster 
config
+    verify(command, never()).persistClusterConfiguration(any(), any());
+  }
 
 Review comment:
   Could have a couple more tests, this one multiple-results tests looks like 
it misses coverage of some conditional clauses in the foreach in 
`DestroyRegionCommand.destroyRegion`: 1) a result contains a throwable 2) a 
not-successfull result has a null message.

----------------------------------------------------------------
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]


> Add more test coverage for p2p commands
> ---------------------------------------
>
>                 Key: GEODE-3539
>                 URL: https://issues.apache.org/jira/browse/GEODE-3539
>             Project: Geode
>          Issue Type: Improvement
>          Components: gfsh
>            Reporter: Jinmei Liao
>
> Add more command tests that would eventually get rid of the legacy tests.



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

Reply via email to