use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostWithValidAuthorizationThenCreated.
@Test
public void whenPostWithValidAuthorizationThenCreated() throws Exception {
final EventType eventType = buildDefaultEventType();
eventType.setAuthorization(new ResourceAuthorization(ImmutableList.of(new ResourceAuthorizationAttribute("type1", "value1")), ImmutableList.of(new ResourceAuthorizationAttribute("type2", "value2")), ImmutableList.of(new ResourceAuthorizationAttribute("type3", "value3"))));
doReturn(eventType).when(eventTypeRepository).saveEventType(any(EventType.class));
when(topicRepository.createTopic(anyInt(), any())).thenReturn(randomUUID.toString());
postEventType(eventType).andExpect(status().isCreated());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPUTwithPartitionStrategyChangeFromRandomToHashThenOK.
@Test
public void whenPUTwithPartitionStrategyChangeFromRandomToHashThenOK() 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.singletonList("foo")).createdAt(eventType.getCreatedAt()).build();
doReturn(eventType).when(eventTypeRepository).findByName(any());
putEventType(randomEventType, eventType.getName()).andExpect(status().isOk());
}
use of org.zalando.nakadi.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenCreateEventTypeWithUnknownApplicationThen422.
@Test
public void whenCreateEventTypeWithUnknownApplicationThen422() throws Exception {
doReturn(false).when(applicationService).exists(any());
final EventType eventType = EventTypeTestBuilder.builder().partitionKeyFields(Collections.singletonList("blabla")).build();
doReturn(eventType).when(eventTypeRepository).findByName(eventType.getName());
postEventType(eventType).andExpect(status().isUnprocessableEntity()).andExpect(content().contentType("application/problem+json"));
}
use of org.zalando.nakadi.domain.EventType 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.domain.EventType in project nakadi by zalando.
the class EventTypeControllerTest method whenPostEventTypeWithIncorrectNameThen422.
@Test
public void whenPostEventTypeWithIncorrectNameThen422() throws Exception {
final List<String> incorrectNames = ImmutableList.of("?", "56mycoolET", "abc^%!", "myET.-abc", "abc._def", "_underscore", "-event", "many..dots", ".firstDot");
for (final String etName : incorrectNames) {
final EventType invalidEventType = buildDefaultEventType();
invalidEventType.setName(etName);
final Problem expectedProblem = invalidProblem("name", "format not allowed");
postETAndExpect422WithProblem(invalidEventType, expectedProblem);
}
}
Aggregations