use of org.zalando.nakadi.exceptions.InvalidEventTypeException in project nakadi by zalando.
the class EventTypeControllerTest method whenPOSTBusinessEventTypeMetadataThen422.
@Test
public void whenPOSTBusinessEventTypeMetadataThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.getSchema().setSchema("{\"type\": \"object\", \"properties\": {\"metadata\": {\"type\": \"object\"} }}");
eventType.setCategory(BUSINESS);
final Problem expectedProblem = new InvalidEventTypeException("\"metadata\" property is reserved").asProblem();
postETAndExpect422WithProblem(eventType, expectedProblem);
}
use of org.zalando.nakadi.exceptions.InvalidEventTypeException in project nakadi by zalando.
the class EventTypeControllerTest method whenPOSTInvalidSchemaThen422.
@Test
public void whenPOSTInvalidSchemaThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.getSchema().setSchema("{\"not\": {\"type\": \"object\"} }");
eventType.setCategory(BUSINESS);
final Problem expectedProblem = new InvalidEventTypeException("Invalid schema: Invalid schema found in [#]: " + "extraneous key [not] is not permitted").asProblem();
postETAndExpect422WithProblem(eventType, expectedProblem);
}
use of org.zalando.nakadi.exceptions.InvalidEventTypeException in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTDifferentEventTypeNameThen422.
@Test
public void whenPUTDifferentEventTypeNameThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
final String eventTypeName = eventType.getName();
eventType.setName("event-name-different");
final Problem expectedProblem = new InvalidEventTypeException("path does not match resource name").asProblem();
doReturn(eventType).when(eventTypeRepository).findByName(eventTypeName);
putEventType(eventType, eventTypeName).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(matchesProblem(expectedProblem)));
}
use of org.zalando.nakadi.exceptions.InvalidEventTypeException in project nakadi by zalando.
the class EventTypeControllerTest method whenEventTypeSchemaJsonIsMalformedThen422.
@Test
public void whenEventTypeSchemaJsonIsMalformedThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.getSchema().setSchema("invalid-json");
final Problem expectedProblem = new InvalidEventTypeException("schema must be a valid json: Unexpected token 'invalid' on line 1, char 1").asProblem();
postETAndExpect422WithProblem(eventType, expectedProblem);
}
use of org.zalando.nakadi.exceptions.InvalidEventTypeException in project nakadi by zalando.
the class EventTypeControllerTest method invalidEventTypeSchemaJsonSchemaThen422.
@Test
public void invalidEventTypeSchemaJsonSchemaThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
final String jsonSchemaString = Resources.toString(Resources.getResource("sample-invalid-json-schema.json"), Charsets.UTF_8);
eventType.getSchema().setSchema(jsonSchemaString);
final Problem expectedProblem = new InvalidEventTypeException("schema must be a valid json-schema").asProblem();
postETAndExpect422WithProblem(eventType, expectedProblem);
}
Aggregations