use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostWithNullAuthorizationListThen422.
@Test
public void whenPostWithNullAuthorizationListThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.setAuthorization(new ResourceAuthorization(null, null, null));
postEventType(eventType).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(containsString("Field \\\"authorization.admins\\\" may not be null"))).andExpect(content().string(containsString("Field \\\"authorization.readers\\\" may not be null"))).andExpect(content().string(containsString("Field \\\"authorization.writers\\\" may not be null")));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostNullOptions201.
@Test
public void whenPostNullOptions201() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.setOptions(null);
postEventType(eventType).andExpect(status().isCreated());
final ArgumentCaptor<EventTypeBase> argument = ArgumentCaptor.forClass(EventTypeBase.class);
verify(eventTypeRepository).saveEventType(argument.capture());
assertEquals(TOPIC_RETENTION_TIME_MS, argument.getValue().getOptions().getRetentionTime().longValue());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostWithNoCategoryThenReturn422.
@Test
public void whenPostWithNoCategoryThenReturn422() 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");
postETAndExpect422WithProblem(jsonObject.toString(), expectedProblem);
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostWithNullAuthAttributesFieldsThen422.
@Test
public void whenPostWithNullAuthAttributesFieldsThen422() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.setAuthorization(new ResourceAuthorization(ImmutableList.of(new ResourceAuthorizationAttribute("type1", "value1")), ImmutableList.of(new ResourceAuthorizationAttribute(null, "value2")), ImmutableList.of(new ResourceAuthorizationAttribute("type3", null))));
postEventType(eventType).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json")).andExpect(content().string(containsString("Field \\\"authorization.readers[0].data_type\\\" may not be null"))).andExpect(content().string(containsString("Field \\\"authorization.writers[0].value\\\" may not be null")));
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTwithPartitionStrategyChangeFromRandomToHashAndEmptyKeyThen422.
@Test
public void whenPUTwithPartitionStrategyChangeFromRandomToHashAndEmptyKeyThen422() throws Exception {
final EventType eventType = EventTypeTestBuilder.builder().partitionStrategy(PartitionStrategy.RANDOM_STRATEGY).build();
final EventType randomEventType = EventTypeTestBuilder.builder().name(eventType.getName()).partitionStrategy(PartitionStrategy.HASH_STRATEGY).partitionKeyFields(Collections.emptyList()).createdAt(eventType.getCreatedAt()).build();
doReturn(eventType).when(eventTypeRepository).findByName(any());
putEventType(randomEventType, eventType.getName()).andExpect(status().isUnprocessableEntity());
}
Aggregations