@Test public void should_return_null_when_header_is_configured_in_config_but_header_does_not_exist() { when(config.hasPath(anyString())).thenReturn(true); when(headers.get(anyString())).thenReturn(Optional.ofNullable(null)); Assert.assertNull(headerBasedTrackerIdFetcher.fetch(ctx)); }
@Override public String fetch(Http.Context ctx) { if ( config.hasPath(LOGTRACKER_TRACKER_PROVIDER_HEADER) && ctx.request().getHeaders().get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)).isPresent() ) { return ctx.request() .getHeaders() .get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)) .filter(StringUtils::isNotEmpty) .get(); } return null; }
HeaderBasedTrackerIdFetcher extends TrackerIdFetcher { @Override public String fetch(Http.Context ctx) { if ( config.hasPath(LOGTRACKER_TRACKER_PROVIDER_HEADER) && ctx.request().getHeaders().get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)).isPresent() ) { return ctx.request() .getHeaders() .get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)) .filter(StringUtils::isNotEmpty) .get(); } return null; } }
HeaderBasedTrackerIdFetcher extends TrackerIdFetcher { @Override public String fetch(Http.Context ctx) { if ( config.hasPath(LOGTRACKER_TRACKER_PROVIDER_HEADER) && ctx.request().getHeaders().get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)).isPresent() ) { return ctx.request() .getHeaders() .get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)) .filter(StringUtils::isNotEmpty) .get(); } return null; } @Inject  HeaderBasedTrackerIdFetcher(Config config); }
HeaderBasedTrackerIdFetcher extends TrackerIdFetcher { @Override public String fetch(Http.Context ctx) { if ( config.hasPath(LOGTRACKER_TRACKER_PROVIDER_HEADER) && ctx.request().getHeaders().get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)).isPresent() ) { return ctx.request() .getHeaders() .get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)) .filter(StringUtils::isNotEmpty) .get(); } return null; } @Inject  HeaderBasedTrackerIdFetcher(Config config); @Override String fetch(Http.Context ctx); }
HeaderBasedTrackerIdFetcher extends TrackerIdFetcher { @Override public String fetch(Http.Context ctx) { if ( config.hasPath(LOGTRACKER_TRACKER_PROVIDER_HEADER) && ctx.request().getHeaders().get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)).isPresent() ) { return ctx.request() .getHeaders() .get(config.getString(LOGTRACKER_TRACKER_PROVIDER_HEADER)) .filter(StringUtils::isNotEmpty) .get(); } return null; } @Inject  HeaderBasedTrackerIdFetcher(Config config); @Override String fetch(Http.Context ctx);  }