use of org.zalando.problem.Problem in project nakadi by zalando.
the class EventTypeControllerTest method whenPostEventTypeWithTooLongNameThen422.
@Test
public void whenPostEventTypeWithTooLongNameThen422() throws Exception {
final EventType invalidEventType = buildDefaultEventType();
invalidEventType.setName(TestUtils.randomValidStringOfLength(256));
final Problem expectedProblem = invalidProblem("name", "the length of the name must be >= 1 and <= 255");
postETAndExpect422WithProblem(invalidEventType, expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class ExceptionHandlingTest method testIllegalClientIdException.
@Test
public void testIllegalClientIdException() {
final ExceptionHandling exceptionHandling = new ExceptionHandling();
final NativeWebRequest mockedRequest = Mockito.mock(NativeWebRequest.class);
Mockito.when(mockedRequest.getHeader(Matchers.any())).thenReturn("");
final ResponseEntity<Problem> problemResponseEntity = exceptionHandling.handleIllegalClientIdException(new IllegalClientIdException("You don't have access to this event type"), mockedRequest);
Assert.assertEquals(problemResponseEntity.getStatusCode(), HttpStatus.FORBIDDEN);
Assert.assertEquals(problemResponseEntity.getBody().getDetail().get(), "You don't have access to this event type");
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenEventTypeDoesNotExistThenUnprocessableEntity.
@Test
public void whenEventTypeDoesNotExistThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
when(subscriptionService.createSubscription(any())).thenThrow(new NoEventTypeException("msg"));
final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "msg");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenCreateSubscriptionWithEmptyConsumerGroupThenUnprocessableEntity.
@Test
public void whenCreateSubscriptionWithEmptyConsumerGroupThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().withConsumerGroup("").buildSubscriptionBase();
final Problem expectedProblem = invalidProblem("consumer_group", "must contain at least one character");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
use of org.zalando.problem.Problem in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenOwningApplicationIsNullThenUnprocessableEntity.
@Test
public void whenOwningApplicationIsNullThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().withOwningApplication(null).buildSubscriptionBase();
final Problem expectedProblem = invalidProblem("owning_application", "may not be null");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
Aggregations