WingtipsSpringBootConfiguration { @Bean @ConditionalOnWebApplication public FilterRegistrationBean wingtipsRequestTracingFilter() { if (wingtipsProperties.isWingtipsDisabled()) { return new FilterRegistrationBean(new DoNothingServletFilter()); } if (requestTracingFilter == null) { requestTracingFilter = new RequestTracingFilter(); } FilterRegistrationBean frb = new FilterRegistrationBean(requestTracingFilter); if (wingtipsProperties.getUserIdHeaderKeys() != null) { frb.addInitParameter( RequestTracingFilter.USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME, wingtipsProperties.getUserIdHeaderKeys() ); } if (wingtipsProperties.getServerSideSpanTaggingStrategy() != null) { frb.addInitParameter( RequestTracingFilter.TAG_AND_SPAN_NAMING_STRATEGY_INIT_PARAM_NAME, wingtipsProperties.getServerSideSpanTaggingStrategy() ); } if (wingtipsProperties.getServerSideSpanTaggingAdapter() != null) { frb.addInitParameter( RequestTracingFilter.TAG_AND_SPAN_NAMING_ADAPTER_INIT_PARAM_NAME, wingtipsProperties.getServerSideSpanTaggingAdapter() ); } frb.setOrder(Ordered.HIGHEST_PRECEDENCE); return frb; } @Autowired  WingtipsSpringBootConfiguration(WingtipsSpringBootProperties wingtipsProperties); @Bean @ConditionalOnWebApplication FilterRegistrationBean wingtipsRequestTracingFilter();  }
@DataProvider(value = { "true | USER_ID_HEADER_KEYS_PROP_IS_SET", "true | TAG_AND_NAMING_STRATEGY_PROP_IS_SET", "true | TAG_AND_NAMING_ADAPTER_PROP_IS_SET", "true | ALL_PROPS_ARE_SET", "false | USER_ID_HEADER_KEYS_PROP_IS_SET", "false | TAG_AND_NAMING_STRATEGY_PROP_IS_SET", "false | TAG_AND_NAMING_ADAPTER_PROP_IS_SET", "false | ALL_PROPS_ARE_SET" }, splitBy = "\\|") @Test public void wingtipsRequestTracingFilter_returns_FilterRegistrationBean_with_expected_values( boolean appFilterOverrideIsNull, PropertiesScenario scenario ) { RequestTracingFilter appFilterOverride = (appFilterOverrideIsNull) ? null : mock(RequestTracingFilter.class); WingtipsSpringBootProperties props = generateProps( false, scenario.userIdHeaderKeys, null, scenario.tagAndNamingStrategy, scenario.tagAndNamingAdapter ); WingtipsSpringBootConfiguration conf = new WingtipsSpringBootConfiguration(props); conf.requestTracingFilter = appFilterOverride; FilterRegistrationBean filterRegistrationBean = conf.wingtipsRequestTracingFilter(); if (appFilterOverride == null) { assertThat(filterRegistrationBean.getFilter()) .isNotNull() .isInstanceOf(RequestTracingFilter.class); } else { assertThat(filterRegistrationBean.getFilter()).isSameAs(appFilterOverride); } String userIdHeaderKeysFilterInitParam = filterRegistrationBean.getInitParameters().get(USER_ID_HEADER_KEYS_LIST_INIT_PARAM_NAME); String tagAndNamingStrategyFilterInitParam = filterRegistrationBean.getInitParameters().get(TAG_AND_SPAN_NAMING_STRATEGY_INIT_PARAM_NAME); String tagAndNamingAdapterFilterInitParam = filterRegistrationBean.getInitParameters().get(TAG_AND_SPAN_NAMING_ADAPTER_INIT_PARAM_NAME); assertThat(userIdHeaderKeysFilterInitParam).isEqualTo(scenario.userIdHeaderKeys); assertThat(tagAndNamingStrategyFilterInitParam).isEqualTo(scenario.tagAndNamingStrategy); assertThat(tagAndNamingAdapterFilterInitParam).isEqualTo(scenario.tagAndNamingAdapter); assertThat(filterRegistrationBean.getOrder()).isEqualTo(Ordered.HIGHEST_PRECEDENCE); }
@Test public void wingtipsRequestTracingFilter_returns_DoNothingServletFilter_if_WingtipsSpringBootProperties_indicates_disabled() { WingtipsSpringBootProperties props = generateProps(true, null, null, null, null); WingtipsSpringBootConfiguration conf = new WingtipsSpringBootConfiguration(props); FilterRegistrationBean filterRegistrationBean = conf.wingtipsRequestTracingFilter(); assertThat(filterRegistrationBean.getFilter()) .isNotNull() .isInstanceOf(DoNothingServletFilter.class); }