use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class SchemaServiceTest method testIllegalVersionNumber.
@Test
public void testIllegalVersionNumber() throws Exception {
final EventType eventType = buildDefaultEventType();
Mockito.when(schemaRepository.getSchemaVersion(eventType.getName() + "wrong", eventType.getSchema().getVersion().toString())).thenThrow(NoSuchSchemaException.class);
final Result<EventTypeSchema> result = schemaService.getSchemaVersion(eventType.getName() + "wrong", eventType.getSchema().getVersion().toString());
Assert.assertFalse(result.isSuccessful());
Assert.assertEquals(Response.Status.NOT_FOUND, result.getProblem().getStatus());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class TimelineServiceTest method testGetTimeline.
@Test
public void testGetTimeline() throws Exception {
final EventType eventType = EventTypeTestBuilder.builder().build();
final Timeline timeline = Timeline.createTimeline(eventType.getName(), 0, null, "topic", new Date());
timeline.setSwitchedAt(new Date());
Mockito.when(eventTypeCache.getTimelinesOrdered(eventType.getName())).thenReturn(Collections.singletonList(timeline));
final Timeline actualTimeline = timelineService.getActiveTimeline(eventType);
Assert.assertEquals(timeline, actualTimeline);
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class JSONSchemaValidationTest method validationOfBusinessEventShouldRequiredMetadata.
@Test
public void validationOfBusinessEventShouldRequiredMetadata() {
final EventType et = EventTypeTestBuilder.builder().name("some-event-type").schema(basicSchema()).build();
et.setCategory(EventCategory.BUSINESS);
final JSONObject event = new JSONObject("{ \"foo\": \"bar\" }");
final Optional<ValidationError> error = EventValidation.forType(et).validate(event);
assertThat(error.get().getMessage(), equalTo("#: required key [metadata] not found"));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class JSONSchemaValidationTest method requireMetadataEventTypeToBeTheSameAsEventTypeName.
@Test
public void requireMetadataEventTypeToBeTheSameAsEventTypeName() {
final EventType et = EventTypeTestBuilder.builder().name("some-event-type").schema(basicSchema()).build();
et.setCategory(EventCategory.BUSINESS);
final JSONObject event = businessEvent();
event.getJSONObject("metadata").put("event_type", "different-from-event-name");
final Optional<ValidationError> error = EventValidation.forType(et).validate(event);
assertThat(error.get().getMessage(), equalTo("#/metadata/event_type: different-from-event-name " + "is not a valid enum value"));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class JSONSchemaValidationTest method requireEidToBeFormattedAsUUID.
@Test
public void requireEidToBeFormattedAsUUID() {
final EventType et = EventTypeTestBuilder.builder().name("some-event-type").schema(basicSchema()).build();
et.setCategory(EventCategory.BUSINESS);
final JSONObject event = businessEvent();
event.getJSONObject("metadata").put("eid", "x");
final Optional<ValidationError> error = EventValidation.forType(et).validate(event);
assertThat(error.get().getMessage(), equalTo("#/metadata/eid: string [x] does not match pattern " + "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"));
}
Aggregations