@Test public void testPreserve() throws ClassNotFoundException, InstantiationException, IllegalAccessException { Interceptor.Builder builder = InterceptorBuilderFactory.newInstance( InterceptorType.STATIC.toString()); Context ctx = new Context(); ctx.put(Constants.PRESERVE, "true"); ctx.put(Constants.VALUE, "replacement value"); builder.configure(ctx); Interceptor interceptor = builder.build(); Event event = EventBuilder.withBody("test", Charsets.UTF_8); event.getHeaders().put(Constants.KEY, "incumbent value"); Assert.assertNotNull(event.getHeaders().get(Constants.KEY)); event = interceptor.intercept(event); String val = event.getHeaders().get(Constants.KEY); Assert.assertNotNull(val); Assert.assertEquals("incumbent value", val); }
@Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(key)) { return event; } headers.put(key, value); return event; }
StaticInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(key)) { return event; } headers.put(key, value); return event; } }
StaticInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(key)) { return event; } headers.put(key, value); return event; } private  StaticInterceptor(boolean preserveExisting, String key,
      String value); }
StaticInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(key)) { return event; } headers.put(key, value); return event; } private  StaticInterceptor(boolean preserveExisting, String key,
      String value); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close(); }
StaticInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(key)) { return event; } headers.put(key, value); return event; } private  StaticInterceptor(boolean preserveExisting, String key,
      String value); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close();  }