use of org.zalando.nakadi.validation.ValidationError in project nakadi by zalando.
the class EventPublisherTest method mockFaultValidation.
private void mockFaultValidation(final EventType eventType, final String error) throws Exception {
final EventTypeValidator faultyValidator = mock(EventTypeValidator.class);
Mockito.doReturn(eventType).when(cache).getEventType(eventType.getName());
Mockito.doReturn(faultyValidator).when(cache).getValidator(eventType.getName());
Mockito.doReturn(Optional.of(new ValidationError(error))).when(faultyValidator).validate(any());
}
use of org.zalando.nakadi.validation.ValidationError in project nakadi by zalando.
the class EventPublisher method validateSchema.
private void validateSchema(final JSONObject event, final EventType eventType) throws EventValidationException, InternalNakadiException, NoSuchEventTypeException {
final EventTypeValidator validator = eventTypeCache.getValidator(eventType.getName());
final Optional<ValidationError> validationError = validator.validate(event);
if (validationError.isPresent()) {
throw new EventValidationException(validationError.get());
}
}
Aggregations