use of org.zalando.nakadi.utils.TestUtils.createBatchItem in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method setReceivedAtWithSystemTimeInUTC.
@Test
public void setReceivedAtWithSystemTimeInUTC() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
final BatchItem batch = TestUtils.createBatchItem(event);
assertThat(event.getJSONObject("metadata").optString("received_at"), isEmptyString());
try {
DateTimeUtils.setCurrentMillisFixed(0);
strategy.enrich(batch, eventType);
} finally {
DateTimeUtils.setCurrentMillisSystem();
}
assertThat(batch.getEvent().getJSONObject("metadata").getString("received_at"), equalTo("1970-01-01T00:00:00.000Z"));
}
use of org.zalando.nakadi.utils.TestUtils.createBatchItem in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method setEventTypeName.
@Test
public void setEventTypeName() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
final BatchItem batch = TestUtils.createBatchItem(event);
assertThat(event.getJSONObject("metadata").optString("event_type"), isEmptyString());
strategy.enrich(batch, eventType);
assertThat(batch.getEvent().getJSONObject("metadata").getString("event_type"), equalTo(eventType.getName()));
}
Aggregations