CreateIndexCommand extends GfshCommand { String getValidRegionName(String regionPath) { String regionName = regionPath.trim().split(" ")[0]; regionName = StringUtils.removeStart(regionName, SEPARATOR); if (regionName.contains(".")) { regionName = regionName.substring(0, regionName.indexOf('.')); } return regionName; }  @CliCommand(value = CliStrings.CREATE_INDEX, help = CliStrings.CREATE_INDEX__HELP) @CliMetaData(relatedTopic = {CliStrings.TOPIC_GEODE_REGION, CliStrings.TOPIC_GEODE_DATA}) @ResourceOperation(resource = ResourcePermission.Resource.CLUSTER, operation = ResourcePermission.Operation.MANAGE, target = ResourcePermission.Target.QUERY) @SuppressWarnings("deprecation") ResultModel createIndex(@CliOption(key = CliStrings.CREATE_INDEX__NAME, mandatory = true,
      help = CliStrings.CREATE_INDEX__NAME__HELP) final String indexName,

      @CliOption(key = CliStrings.CREATE_INDEX__EXPRESSION, mandatory = true,
          help = CliStrings.CREATE_INDEX__EXPRESSION__HELP) final String indexedExpression,

      @CliOption(key = CliStrings.CREATE_INDEX__REGION, mandatory = true,
          optionContext = ConverterHint.REGION_PATH,
          help = CliStrings.CREATE_INDEX__REGION__HELP) String regionPath,

      @CliOption(key = {CliStrings.MEMBER, CliStrings.MEMBERS},
          optionContext = ConverterHint.MEMBERIDNAME,
          help = CliStrings.CREATE_INDEX__MEMBER__HELP) final String[] memberNameOrID,

      @CliOption(key = CliStrings.CREATE_INDEX__TYPE, unspecifiedDefaultValue = "range",
          optionContext = ConverterHint.INDEX_TYPE,
          help = CliStrings.CREATE_INDEX__TYPE__HELP) final org.apache.geode.cache.query.IndexType indexType,

      @CliOption(key = {CliStrings.GROUP, CliStrings.GROUPS},
          optionContext = ConverterHint.MEMBERGROUP,
          help = CliStrings.CREATE_INDEX__GROUP__HELP) String[] groups);  }
@Test public void getValidRegionName() { assertThat(command.getValidRegionName("regionB")).isEqualTo("regionB"); assertThat(command.getValidRegionName(SEPARATOR + "regionB")).isEqualTo("regionB"); assertThat(command.getValidRegionName(SEPARATOR + "regionB b")).isEqualTo("regionB"); assertThat(command.getValidRegionName(SEPARATOR + "regionB.entrySet()")) .isEqualTo("regionB"); assertThat(command.getValidRegionName(SEPARATOR + "regionA.B.entrySet() A")) .isEqualTo("regionA"); assertThat(command.getValidRegionName(SEPARATOR + "regionA.fieldName.entrySet() B")) .isEqualTo("regionA"); }