RequestTracingFilter implements Filter { protected List<String> initializeUserIdHeaderKeys(FilterConfig filterConfig) { String userIdHeaderKeysListString = filterConfig.getInitParameter(USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME); if (userIdHeaderKeysListString != null) { List<String> parsedList = new ArrayList<>(); for (String headerKey : userIdHeaderKeysListString.split(",")) { String trimmedHeaderKey = headerKey.trim(); if (trimmedHeaderKey.length() > 0) parsedList.add(trimmedHeaderKey); } return Collections.unmodifiableList(parsedList); } return null; }  @Override @SuppressWarnings("RedundantThrows") void init(FilterConfig filterConfig); @Override void destroy(); @Override void doFilter(ServletRequest request,
                         ServletResponse response,
                         FilterChain filterChain); static final String FILTER_HAS_ALREADY_EXECUTED_ATTRIBUTE; @Deprecated
    static final String ERROR_REQUEST_URI_ATTRIBUTE; static final String USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME; static final String TAG_AND_SPAN_NAMING_STRATEGY_INIT_PARAM_NAME; static final String TAG_AND_SPAN_NAMING_ADAPTER_INIT_PARAM_NAME; }
@Test @UseDataProvider("userIdHeaderKeysInitParamDataProvider") public void initializeUserIdHeaderKeys_gets_user_id_header_key_list_from_init_params( String userIdHeaderKeysInitParamValue, List<String> expectedUserIdHeaderKeysList ) { RequestTracingFilter filter = new RequestTracingFilter(); doReturn(userIdHeaderKeysInitParamValue) .when(filterConfigMock) .getInitParameter(RequestTracingFilter.USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME); List<String> actualUserIdHeaderKeysList = filter.initializeUserIdHeaderKeys(filterConfigMock); assertThat(actualUserIdHeaderKeysList).isEqualTo(expectedUserIdHeaderKeysList); if (actualUserIdHeaderKeysList != null) { Exception caughtEx = null; try { actualUserIdHeaderKeysList.add("foo"); } catch (Exception ex) { caughtEx = ex; } assertThat(caughtEx).isNotNull(); assertThat(caughtEx).isInstanceOf(UnsupportedOperationException.class); } }