@Test public void testBasic() throws ClassNotFoundException, InstantiationException, IllegalAccessException { InterceptorBuilderFactory factory = new InterceptorBuilderFactory(); Interceptor.Builder builder = InterceptorBuilderFactory.newInstance( InterceptorType.TIMESTAMP.toString()); Interceptor interceptor = builder.build(); Event event = EventBuilder.withBody("test event", Charsets.UTF_8); Assert.assertNull(event.getHeaders().get(Constants.TIMESTAMP)); Long now = System.currentTimeMillis(); event = interceptor.intercept(event); String timestampStr = event.getHeaders().get(Constants.TIMESTAMP); Assert.assertNotNull(timestampStr); Assert.assertTrue(Long.parseLong(timestampStr) >= now); }
@Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(TIMESTAMP)) { } else { long now = System.currentTimeMillis(); headers.put(TIMESTAMP, Long.toString(now)); } return event; }
TimestampInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(TIMESTAMP)) { } else { long now = System.currentTimeMillis(); headers.put(TIMESTAMP, Long.toString(now)); } return event; } }
TimestampInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(TIMESTAMP)) { } else { long now = System.currentTimeMillis(); headers.put(TIMESTAMP, Long.toString(now)); } return event; } private  TimestampInterceptor(boolean preserveExisting); }
TimestampInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(TIMESTAMP)) { } else { long now = System.currentTimeMillis(); headers.put(TIMESTAMP, Long.toString(now)); } return event; } private  TimestampInterceptor(boolean preserveExisting); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close(); }
TimestampInterceptor implements Interceptor { @Override public Event intercept(Event event) { Map<String, String> headers = event.getHeaders(); if (preserveExisting && headers.containsKey(TIMESTAMP)) { } else { long now = System.currentTimeMillis(); headers.put(TIMESTAMP, Long.toString(now)); } return event; } private  TimestampInterceptor(boolean preserveExisting); @Override void initialize(); @Override Event intercept(Event event); @Override List<Event> intercept(List<Event> events); @Override void close();  }