IndexConverter extends ConfigurationConverter<Index, RegionConfig.Index> { @Override protected Index fromNonNullXmlObject(RegionConfig.Index regionConfigIndex) { Index index = new Index(); index.setName(regionConfigIndex.getName()); index.setExpression(regionConfigIndex.getExpression()); index.setRegionPath(regionConfigIndex.getFromClause()); Boolean keyIndex = regionConfigIndex.isKeyIndex(); if (keyIndex != null && keyIndex) { index.setIndexType(IndexType.KEY); } else if (HASH.equalsIgnoreCase(regionConfigIndex.getType())) { index.setIndexType(IndexType.HASH_DEPRECATED); } else { index.setIndexType(IndexType.RANGE); } return index; }    }
@Test public void fromNonNullXmlObject_copiesSimpleProperties() { RegionConfig.Index regionConfigIndex = new RegionConfig.Index(); regionConfigIndex.setName("region config index name"); regionConfigIndex.setExpression("region config index expression"); regionConfigIndex.setFromClause("region config index from clause"); Index index = indexConverter.fromNonNullXmlObject(regionConfigIndex); assertSoftly(softly -> { softly.assertThat(index.getExpression()) .isEqualTo(regionConfigIndex.getExpression()); softly.assertThat(index.getName()) .isEqualTo(regionConfigIndex.getName()); softly.assertThat(index.getRegionPath()) .isEqualTo(regionConfigIndex.getFromClause()); }); }
@Test public void fromNonNullXmlObject_mapsHashIndexTypeToHashDeprecatedIndexType() { RegionConfig.Index regionConfigIndex = new RegionConfig.Index(); regionConfigIndex.setType("hash"); Index index = indexConverter.fromNonNullXmlObject(regionConfigIndex); assertThat(index.getIndexType()) .as("type") .isEqualTo(HASH_DEPRECATED); }
@Test public void fromNonNullXmlObject_mapsRangeIndexTypeToFunctionalIndexType() { RegionConfig.Index regionConfigIndex = new RegionConfig.Index(); regionConfigIndex.setType("range"); Index index = indexConverter.fromNonNullXmlObject(regionConfigIndex); assertThat(index.getIndexType()) .as("type") .isEqualTo(RANGE); }
@Test public void fromNonNullXmlObject_mapsKeyIndexTypeToPrimaryKeyIndexType() { RegionConfig.Index regionConfigIndex = new RegionConfig.Index(); regionConfigIndex.setType("key"); Index index = indexConverter.fromNonNullXmlObject(regionConfigIndex); assertThat(index.getIndexType()) .as("type") .isEqualTo(KEY); }