MappingCommandUtils { public static RegionConfig checkForRegion(String regionName, CacheConfig cacheConfig, String groupName) throws PreconditionException { RegionConfig regionConfig = findRegionConfig(cacheConfig, regionName); if (regionConfig == null) { String groupClause = "A region named " + regionName + " must already exist" + (!groupName.equals(ConfigurationPersistenceService.CLUSTER_CONFIG) ? " for group " + groupName + "." : "."); throw new PreconditionException(groupClause); } return regionConfig; }  static CacheConfig getCacheConfig(ConfigurationPersistenceService configService,
      String group); static RegionConfig checkForRegion(String regionName, CacheConfig cacheConfig,
      String groupName); static ArrayList<RegionMapping> getMappingsFromRegionConfig(CacheConfig cacheConfig,
      RegionConfig regionConfig,
      String group); static boolean isMappingSynchronous(CacheConfig cacheConfig, RegionConfig regionConfig); static CacheConfig.AsyncEventQueue findAsyncEventQueue(CacheConfig cacheConfig,
      RegionConfig regionConfig); static boolean isAccessor(RegionAttributesType attributesType); static boolean isPartition(RegionAttributesType attributesType); static String createAsyncEventQueueName(String regionPath);  }
@Test public void checkForRegionReturnsCorrectRegionConfig() throws PreconditionException { List<RegionConfig> regionsList = new ArrayList<>(); regionsList.add(regionConfig); when(regionConfig.getName()).thenReturn(TESTREGION); when(cacheConfig.getRegions()).thenReturn(regionsList); RegionConfig result = MappingCommandUtils.checkForRegion(TESTREGION, cacheConfig, GROUPNAME); assertThat(result).isEqualTo(regionConfig); }