use of org.zalando.nakadi.domain.BatchItem in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method whenFlowIdIsPresentDoNotOverride.
@Test
public void whenFlowIdIsPresentDoNotOverride() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
event.getJSONObject("metadata").put("flow_id", "something");
final BatchItem batch = createBatchItem(event);
FlowIdUtils.push("something-else");
strategy.enrich(batch, eventType);
assertThat(batch.getEvent().getJSONObject("metadata").getString("flow_id"), equalTo("something"));
}
use of org.zalando.nakadi.domain.BatchItem in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method setFlowId.
@Test
public void setFlowId() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
final BatchItem batch = createBatchItem(event);
assertThat(event.getJSONObject("metadata").optString("flow_id"), isEmptyString());
final String flowId = randomString();
FlowIdUtils.push(flowId);
strategy.enrich(batch, eventType);
assertThat(batch.getEvent().getJSONObject("metadata").getString("flow_id"), equalTo(flowId));
}
use of org.zalando.nakadi.domain.BatchItem 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()));
}
use of org.zalando.nakadi.domain.BatchItem in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method setPartition.
@Test
public void setPartition() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
final String partition = randomString();
final BatchItem batch = createBatchItem(event);
batch.setPartition(partition);
strategy.enrich(batch, eventType);
assertThat(batch.getEvent().getJSONObject("metadata").getString("partition"), equalTo(partition));
}
use of org.zalando.nakadi.domain.BatchItem in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method whenFlowIsNullOverrideIt.
@Test
public void whenFlowIsNullOverrideIt() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
event.getJSONObject("metadata").put("flow_id", (Object) null);
final BatchItem batch = createBatchItem(event);
final String flowId = randomString();
FlowIdUtils.push(flowId);
strategy.enrich(batch, eventType);
assertThat(batch.getEvent().getJSONObject("metadata").getString("flow_id"), equalTo(flowId));
}
Aggregations