Index extends AbstractConfiguration<IndexInfo> implements RegionScoped { @JsonIgnore public String getRegionName() { if (regionPath == null) { return null; } String regionName = regionPath.trim().split(" ")[0]; regionName = StringUtils.removeStart(regionName, SEPARATOR); if (regionName.contains(".")) { regionName = regionName.substring(0, regionName.indexOf('.')); } return regionName; }  String getName(); void setName(String name); String getExpression(); void setExpression(String expression); String getRegionPath(); void setRegionPath(String regionPath); IndexType getIndexType(); void setIndexType(IndexType indexType); @JsonIgnore String getRegionName(); @Override @JsonIgnore String getId(); @Override Links getLinks(); @Override boolean equals(Object o); @Override int hashCode(); static final String INDEXES; }
@Test public void getRegionName() { assertSoftly(softly -> { index.setRegionPath(null); softly.assertThat(index.getRegionName()).isNull(); index.setRegionPath("regionA"); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); index.setRegionPath(" regionA "); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); index.setRegionPath(SEPARATOR + "regionA"); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); index.setRegionPath(SEPARATOR + "regionA.method()"); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); index.setRegionPath(SEPARATOR + "regionA.method() a"); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); index.setRegionPath(SEPARATOR + "regionA.fieled.method() a"); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); index.setRegionPath(SEPARATOR + "regionA a"); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); index.setRegionPath(SEPARATOR + "regionA a, a.foo"); softly.assertThat(index.getRegionName()).isEqualTo("regionA"); }); }