use of org.zalando.problem.ThrowableProblem in project nakadi by zalando.
the class EventTypeControllerTest method askingForANonExistingEventTypeResultsIn404.
@Test
public void askingForANonExistingEventTypeResultsIn404() throws Exception {
final String eventTypeName = randomValidEventTypeName();
when(eventTypeRepository.findByName(anyString())).thenThrow(new NoSuchEventTypeException(String.format("EventType '%s' does not exist.", eventTypeName)));
final MockHttpServletRequestBuilder requestBuilder = get("/event-types/" + eventTypeName).accept(APPLICATION_JSON);
final ThrowableProblem expectedProblem = Problem.valueOf(NOT_FOUND, "EventType '" + eventTypeName + "' does not exist.");
mockMvc.perform(requestBuilder).andExpect(status().is(404)).andExpect(content().contentTypeCompatibleWith("application/problem+json")).andExpect(content().string(matchesProblem(expectedProblem)));
}
use of org.zalando.problem.ThrowableProblem in project nakadi by zalando.
the class SubscriptionControllerTest method whenGetNoneExistingSubscriptionThenNotFound.
@Test
public void whenGetNoneExistingSubscriptionThenNotFound() throws Exception {
final Subscription subscription = builder().build();
when(subscriptionRepository.getSubscription(subscription.getId())).thenThrow(new NoSuchSubscriptionException("dummy-message"));
final ThrowableProblem expectedProblem = Problem.valueOf(Response.Status.NOT_FOUND, "dummy-message");
getSubscription(subscription.getId()).andExpect(status().isNotFound()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem)));
}
use of org.zalando.problem.ThrowableProblem in project nakadi by zalando.
the class PartitionsControllerTest method whenListPartitionsForWrongTopicThenNotFound.
@Test
public void whenListPartitionsForWrongTopicThenNotFound() throws Exception {
final ThrowableProblem expectedProblem = Problem.valueOf(NOT_FOUND, "topic not found");
mockMvc.perform(get(String.format("/event-types/%s/partitions", UNKNOWN_EVENT_TYPE))).andExpect(status().isNotFound()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem)));
}
use of org.zalando.problem.ThrowableProblem in project nakadi by zalando.
the class PartitionsControllerTest method whenListPartitionsAndNakadiExceptionThenServiceUnavaiable.
@Test
public void whenListPartitionsAndNakadiExceptionThenServiceUnavaiable() throws Exception {
when(timelineService.getActiveTimelinesOrdered(eq(TEST_EVENT_TYPE))).thenThrow(ServiceUnavailableException.class);
final ThrowableProblem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE, null);
mockMvc.perform(get(String.format("/event-types/%s/partitions", TEST_EVENT_TYPE))).andExpect(status().isServiceUnavailable()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem)));
}
use of org.zalando.problem.ThrowableProblem in project nakadi by zalando.
the class PartitionsControllerTest method whenGetPartitionAndNakadiExceptionThenServiceUnavaiable.
@Test
public void whenGetPartitionAndNakadiExceptionThenServiceUnavaiable() throws Exception {
when(timelineService.getActiveTimelinesOrdered(eq(TEST_EVENT_TYPE))).thenThrow(ServiceUnavailableException.class);
final ThrowableProblem expectedProblem = Problem.valueOf(SERVICE_UNAVAILABLE, null);
mockMvc.perform(get(String.format("/event-types/%s/partitions/%s", TEST_EVENT_TYPE, TEST_PARTITION))).andExpect(status().isServiceUnavailable()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem)));
}
Aggregations