@Test public void checkTimestamp() { long now = System.currentTimeMillis(); for (Map<String, String> headers : Arrays.asList( ImmutableMap.of("@timestamp", Long.toString(now)), ImmutableMap.of("@timestamp", ISODateTimeFormat.dateTime().withZoneUTC().print(now)) )) { final TimeStampedEvent timestampedEvent = new TimeStampedEvent(EventBuilder.withBody(new byte[0], headers)); assertThat(timestampedEvent.getTimestamp()).isEqualTo(now); assertThat(timestampedEvent.getHeaders().get("@timestamp")).isEqualTo(ISODateTimeFormat.dateTime().withZoneUTC().print(now)); } DateTimeUtils.setCurrentMillisFixed(now); for (Map<String, String> headers : Arrays.asList( ImmutableMap.<String,String>of(), ImmutableMap.of("timestamp", ""), ImmutableMap.of("@timestamp", "") )) { final TimeStampedEvent timestampedEvent = new TimeStampedEvent(EventBuilder.withBody(new byte[0], headers)); assertThat(timestampedEvent.getTimestamp()).isEqualTo(now); assertThat(timestampedEvent.getHeaders().get("@timestamp")).isEqualTo(ISODateTimeFormat.dateTime().withZoneUTC().print(now)); } DateTimeUtils.setCurrentMillisSystem(); }
long getTimestamp() { return timestamp; }
TimeStampedEvent extends SimpleEvent { long getTimestamp() { return timestamp; } }
TimeStampedEvent extends SimpleEvent { long getTimestamp() { return timestamp; } TimeStampedEvent(Event base); }
TimeStampedEvent extends SimpleEvent { long getTimestamp() { return timestamp; } TimeStampedEvent(Event base);  }
TimeStampedEvent extends SimpleEvent { long getTimestamp() { return timestamp; } TimeStampedEvent(Event base);   }