RegionConfigManager extends CacheConfigurationManager<Region> { @Override public void checkCompatibility(Region incoming, String group, Region existing) { if (incoming.getType().equals(existing.getType())) { return; } if (!incoming.getType().name().contains("PROXY") && !existing.getType().name().contains("PROXY")) { raiseIncompatibilityError(incoming, group, existing); } String incomingType = incoming.getType().name().split("_")[0]; String existingType = existing.getType().name().split("_")[0]; if (!incomingType.equals(existingType)) { raiseIncompatibilityError(incoming, group, existing); } } RegionConfigManager(ConfigurationPersistenceService service); @Override void add(Region configElement, CacheConfig existingConfig); @Override void update(Region config, CacheConfig existing); @Override void delete(Region config, CacheConfig existing); @Override List<Region> list(Region filter, CacheConfig existing); @Override Region get(Region config, CacheConfig existing); @Override void checkCompatibility(Region incoming, String group, Region existing);  }
@Test public void compatibleWithItself() throws Exception { config1.setType(RegionType.REPLICATE); manager.checkCompatibility(config1, "group", config1); }
@Test public void compatibleWithSameType() throws Exception { config1.setType(RegionType.PARTITION_PERSISTENT); config2.setType(RegionType.PARTITION_PERSISTENT); manager.checkCompatibility(config1, "group", config2); }
@Test public void compatibleWithSamePROXYType() throws Exception { config1.setType(RegionType.PARTITION_PROXY); config2.setType(RegionType.PARTITION_PROXY); manager.checkCompatibility(config1, "group", config2); }
@Test public void compatibleWithPROXYType() throws Exception { config1.setType(RegionType.PARTITION); config2.setType(RegionType.PARTITION_PROXY); manager.checkCompatibility(config1, "group", config2); }
@Test public void compatibleWithPROXYType2() throws Exception { config1.setType(RegionType.PARTITION_PROXY); config2.setType(RegionType.PARTITION); manager.checkCompatibility(config1, "group", config2); }
@Test public void compatibleWithPROXYType3() throws Exception { config1.setType(RegionType.PARTITION_PROXY); config2.setType(RegionType.PARTITION_PERSISTENT); manager.checkCompatibility(config1, "group", config2); }
@Test public void incompatible() throws Exception { config1.setType(RegionType.PARTITION_PROXY); config2.setType(RegionType.REPLICATE); assertThatThrownBy(() -> manager.checkCompatibility(config1, "group", config2)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining( "Region 'test' of type 'PARTITION_PROXY' is not compatible with group's existing Region 'test' of type 'REPLICATE'"); }
@Test public void incompatible2() throws Exception { config1.setType(RegionType.PARTITION); config2.setType(RegionType.REPLICATE); assertThatThrownBy(() -> manager.checkCompatibility(config1, "group", config2)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining( "Region 'test' of type 'PARTITION' is not compatible with group's existing Region 'test' of type 'REPLICATE'"); }
@Test public void incompatible3() throws Exception { config1.setType(RegionType.PARTITION); config2.setType(RegionType.PARTITION_PERSISTENT); assertThatThrownBy(() -> manager.checkCompatibility(config1, "group", config2)) .isInstanceOf(IllegalArgumentException.class) .hasMessageContaining( "Region 'test' of type 'PARTITION' is not compatible with group's existing Region 'test' of type 'PARTITION_PERSISTENT'"); }