### Question:
AuthenticationRealmAwareFilter implements Filter { String prepareRealmRegex(String realmUrlPattern) { String realmRegex = BASE_REALM_REGEX; int lastIndex = realmUrlPattern.lastIndexOf('}'); if (lastIndex != (realmUrlPattern.length() - 1)) { char lastChar = realmUrlPattern.charAt(lastIndex + 1); realmRegex = "([^" + lastChar + "]{2,})"; } return realmRegex; } @Autowired  AuthenticationRealmAwareFilter(OidcAuthenticationHelper oidcAuthenticationHelper); @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain); @Override void destroy(); @Value("${security.oidc.AuthenticationRealmAwareFilter.enable:true}") void setEnableFilter(boolean enableFilter); @Value("${security.oidc.AuthenticationRealmAwareFilter.realmUrlPattern:}") void setRealmUrlPattern(String realmUrlPattern); @Value("${security.oidc.AuthenticationRealmAwareFilter.filterApplyUrlRegex:}") void setFilterApplyUrlRegex(String filterApplyUrlRegex); @Value("${security.oidc.AuthenticationRealmAwareFilter.realmParamName:realm}") void setRealmParamName(String realmParamName); @Value("${security.oidc.AuthenticationRealmAwareFilter.isRealmMandatory:true}") void setRealmMandatory(boolean realmMandatory); @Value("#{'${security.oidc.AuthenticationRealmAwareFilter.filterApplyUrlList:}'.split(',')}") void setFilterApplyUrlList(List<String> filterApplyUrlList); @Value("#{'${security.oidc.AuthenticationRealmAwareFilter.filterIgnoreUrlList:}'.split(',')}") void setFilterIgnoreUrls(List<String> filterIgnoreUrlList); @Override String toString(); static final String BASE_REALM_REGEX; }### Answer:
@Test void prepareRealmRegex() { String realmRegex = authenticationRealmAwareFilter.prepareRealmRegex("/security/{realm}"); assertThat(realmRegex, is(BASE_REALM_REGEX)); realmRegex = authenticationRealmAwareFilter.prepareRealmRegex("/security/tenant-{realm}"); assertThat(realmRegex, is(BASE_REALM_REGEX)); realmRegex = authenticationRealmAwareFilter.prepareRealmRegex("/security/realm-{realm}/*"); assertThat(realmRegex, is("([^/]{2,})")); realmRegex = authenticationRealmAwareFilter.prepareRealmRegex("/security/{realm}-tenant/*"); assertThat(realmRegex, is("([^-]{2,})")); }