use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTInvalidEventTypeThen422.
@Test
public void whenPUTInvalidEventTypeThen422() throws Exception {
final EventType invalidEventType = buildDefaultEventType();
final JSONObject jsonObject = new JSONObject(TestUtils.OBJECT_MAPPER.writeValueAsString(invalidEventType));
jsonObject.remove("category");
final Problem expectedProblem = invalidProblem("category", "may not be null");
putEventType(jsonObject.toString(), invalidEventType.getName()).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(matchesProblem(expectedProblem)));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenDeleteEventTypeThatHasSubscriptionsThenConflict.
@Test
public void whenDeleteEventTypeThatHasSubscriptionsThenConflict() throws Exception {
final EventType eventType = buildDefaultEventType();
when(eventTypeRepository.findByNameO(eventType.getName())).thenReturn(Optional.of(eventType));
when(subscriptionRepository.listSubscriptions(eq(ImmutableSet.of(eventType.getName())), eq(Optional.empty()), anyInt(), anyInt())).thenReturn(ImmutableList.of(mock(Subscription.class)));
final Problem expectedProblem = Problem.valueOf(Response.Status.CONFLICT, "Can't remove event type " + eventType.getName() + ", as it has subscriptions");
deleteEventType(eventType.getName()).andExpect(status().isConflict()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(matchesProblem(expectedProblem)));
}
use of org.zalando.nakadi.domain.EventType 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.domain.EventType 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);
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostEventTypeWithCorrectNameThen201.
@Test
public void whenPostEventTypeWithCorrectNameThen201() throws Exception {
final List<String> correctNames = ImmutableList.of("myET", "my-team.cool_event_type", "event-type.391.16afg", "eventType.59fc6871-b556-65a1-8b90-3dfff9d76f34");
for (final String etName : correctNames) {
final EventType eventType = buildDefaultEventType();
eventType.setName(etName);
postEventType(eventType).andExpect(status().isCreated()).andExpect(content().string(""));
}
}
Aggregations