use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class CompatibilityModeChangeConstraintTest method passWhenNoChanges.
@Test
public void passWhenNoChanges() throws Exception {
final EventTypeTestBuilder builder = new EventTypeTestBuilder();
final EventType oldET = builder.compatibilityMode(CompatibilityMode.NONE).build();
final EventType newET = builder.compatibilityMode(CompatibilityMode.NONE).build();
final CompatibilityModeChangeConstraint constraint = new CompatibilityModeChangeConstraint();
assertThat(constraint.validate(oldET, newET), isAbsent());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class CompatibilityModeChangeConstraintTest method canPromoteFromNoneToForward.
@Test
public void canPromoteFromNoneToForward() throws Exception {
final EventTypeTestBuilder builder = new EventTypeTestBuilder();
final EventType oldET = builder.compatibilityMode(CompatibilityMode.NONE).build();
final EventType newET = builder.compatibilityMode(CompatibilityMode.FORWARD).build();
final CompatibilityModeChangeConstraint constraint = new CompatibilityModeChangeConstraint();
assertThat(constraint.validate(oldET, newET), isAbsent());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class TimelineService method scheduleTimelineCleanup.
private void scheduleTimelineCleanup(final Timeline timeline) throws InconsistentStateException {
try {
final EventType eventType = eventTypeCache.getEventType(timeline.getEventType());
final Long retentionTime = eventType.getOptions().getRetentionTime();
if (retentionTime == null) {
throw new InconsistentStateException("Event type should has information about its retention time");
}
final Date cleanupDate = new Date(System.currentTimeMillis() + retentionTime);
timeline.setCleanedUpAt(cleanupDate);
} catch (final InternalNakadiException | NoSuchEventTypeException e) {
throw new InconsistentStateException("Unexpected error occurred when scheduling timeline cleanup", e);
}
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method throwsExceptionIfPathNotPresent.
@Test(expected = EnrichmentException.class)
public void throwsExceptionIfPathNotPresent() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
event.remove("metadata");
strategy.enrich(TestUtils.createBatchItem(event), eventType);
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class MetadataEnrichmentStrategyTest method whenFlowIsEmptyStringOverrideIt.
@Test
public void whenFlowIsEmptyStringOverrideIt() throws Exception {
final EventType eventType = buildDefaultEventType();
final JSONObject event = buildBusinessEvent();
event.getJSONObject("metadata").put("flow_id", "");
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