Search in sources :

Example 66 with Problem

use of org.zalando.problem.Problem in project nakadi by zalando.

the class PostSubscriptionControllerTest method whenEventTypesIsNullThenUnprocessableEntity.

@Test
public void whenEventTypesIsNullThenUnprocessableEntity() throws Exception {
    final String subscription = "{\"owning_application\":\"app\",\"consumer_group\":\"myGroup\"}";
    final Problem expectedProblem = invalidProblem("event_types", "may not be null");
    checkForProblem(postSubscriptionAsJson(subscription), expectedProblem);
}
Also used : Problem(org.zalando.problem.Problem) TestUtils.invalidProblem(org.zalando.nakadi.utils.TestUtils.invalidProblem) Test(org.junit.Test)

Example 67 with Problem

use of org.zalando.problem.Problem in project nakadi by zalando.

the class SubscriptionControllerTest method whenListSubscriptionsWithNegativeOffsetThenBadRequest.

@Test
public void whenListSubscriptionsWithNegativeOffsetThenBadRequest() throws Exception {
    final Problem expectedProblem = Problem.valueOf(BAD_REQUEST, "'offset' parameter can't be lower than 0");
    checkForProblem(getSubscriptions(ImmutableSet.of("et"), "app", -5, 10), expectedProblem);
}
Also used : Problem(org.zalando.problem.Problem) ThrowableProblem(org.zalando.problem.ThrowableProblem) Test(org.junit.Test)

Example 68 with Problem

use of org.zalando.problem.Problem in project nakadi by zalando.

the class SubscriptionControllerTest method whenListSubscriptionsWithIncorrectLimitThenBadRequest.

@Test
public void whenListSubscriptionsWithIncorrectLimitThenBadRequest() throws Exception {
    final Problem expectedProblem = Problem.valueOf(BAD_REQUEST, "'limit' parameter should have value from 1 to 1000");
    checkForProblem(getSubscriptions(ImmutableSet.of("et"), "app", 0, -5), expectedProblem);
}
Also used : Problem(org.zalando.problem.Problem) ThrowableProblem(org.zalando.problem.ThrowableProblem) Test(org.junit.Test)

Example 69 with Problem

use of org.zalando.problem.Problem in project nakadi by zalando.

the class SubscriptionControllerTest method whenListSubscriptionsAndExceptionThenServiceUnavailable.

@Test
public void whenListSubscriptionsAndExceptionThenServiceUnavailable() throws Exception {
    when(subscriptionRepository.listSubscriptions(any(), any(), anyInt(), anyInt())).thenThrow(new ServiceUnavailableException("dummy message"));
    final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE, "dummy message");
    checkForProblem(getSubscriptions(), expectedProblem);
}
Also used : Problem(org.zalando.problem.Problem) ThrowableProblem(org.zalando.problem.ThrowableProblem) ServiceUnavailableException(org.zalando.nakadi.exceptions.ServiceUnavailableException) Test(org.junit.Test)

Example 70 with Problem

use of org.zalando.problem.Problem in project nakadi by zalando.

the class SubscriptionControllerTest method whenGetSubscriptionAndExceptionThenServiceUnavailable.

@Test
public void whenGetSubscriptionAndExceptionThenServiceUnavailable() throws Exception {
    when(subscriptionRepository.getSubscription(any())).thenThrow(new ServiceUnavailableException("dummy message"));
    final Problem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE, "dummy message");
    checkForProblem(getSubscription("dummyId"), expectedProblem);
}
Also used : Problem(org.zalando.problem.Problem) ThrowableProblem(org.zalando.problem.ThrowableProblem) ServiceUnavailableException(org.zalando.nakadi.exceptions.ServiceUnavailableException) Test(org.junit.Test)

Aggregations

Problem (org.zalando.problem.Problem)75 Test (org.junit.Test)47 TestUtils.invalidProblem (org.zalando.nakadi.utils.TestUtils.invalidProblem)32 ResponseEntity (org.springframework.http.ResponseEntity)26 DefaultProblem (org.zalando.problem.DefaultProblem)26 ProblemBuilder (org.zalando.problem.ProblemBuilder)26 ConstraintViolationProblem (org.zalando.problem.spring.web.advice.validation.ConstraintViolationProblem)26 ThrowableProblem (org.zalando.problem.ThrowableProblem)25 EventType (org.zalando.nakadi.domain.EventType)18 TestUtils.buildDefaultEventType (org.zalando.nakadi.utils.TestUtils.buildDefaultEventType)18 NativeWebRequest (org.springframework.web.context.request.NativeWebRequest)14 List (java.util.List)13 Collectors (java.util.stream.Collectors)13 Nonnull (javax.annotation.Nonnull)13 Nullable (javax.annotation.Nullable)13 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 BindingResult (org.springframework.validation.BindingResult)13 MethodArgumentNotValidException (org.springframework.web.bind.MethodArgumentNotValidException)13 ControllerAdvice (org.springframework.web.bind.annotation.ControllerAdvice)13 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)13