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

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

Github user jaredjstewart commented on a diff in the pull request:

    https://github.com/apache/geode/pull/671#discussion_r130668398
  
    --- Diff: 
geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
 ---
    @@ -1143,4 +721,26 @@ private boolean 
isAttributePersistent(RegionAttributes attributes) {
         return attributes != null && attributes.getDataPolicy() != null
             && attributes.getDataPolicy().toString().contains("PERSISTENT");
       }
    +
    +  private static boolean regionExists(InternalCache cache, String 
regionPath) {
    --- End diff --
    
    I don't see any tests that validate the behavior of this method.  I think 
we can simplify it to: 
    ```
    private static boolean regionExists(InternalCache cache, String regionPath) 
{
        if (regionPath == null || Region.SEPARATOR.equals(regionPath)) {
          return false;
        }
        
        ManagementService managementService = 
ManagementService.getExistingManagementService(cache);
        DistributedSystemMXBean dsMBean = 
managementService.getDistributedSystemMXBean();
    
        String[] allRegionPaths = dsMBean.listAllRegionPaths();
        return Arrays.stream(allRegionPaths).anyMatch(regionPath::equals);
      }
    ```
    
    But it would be nice to have a test that would fail with this 
implementation:
    ```
    private static boolean regionExists(InternalCache cache, String regionPath) 
{
    return true;
    }
    ```


> Refactor CreateAlterDestroyRegionCommands
> -----------------------------------------
>
>                 Key: GEODE-3255
>                 URL: https://issues.apache.org/jira/browse/GEODE-3255
>             Project: Geode
>          Issue Type: Sub-task
>          Components: gfsh
>            Reporter: Emily Yeh
>            Assignee: Emily Yeh
>
> {{CreateAlterDestroyRegionCommands.java}} is a large class that contains 
> multiple commands. Each command should be refactored into a separate class, 
> and the methods shared by the commands should be refactored into a new and 
> appropriately named class of their own.



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

Reply via email to