Search in sources :

Example 6 with ThrowableProblem

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

the class PartitionsControllerTest method whenGetPartitionForWrongPartitionThenNotFound.

@Test
public void whenGetPartitionForWrongPartitionThenNotFound() throws Exception {
    when(eventTypeRepositoryMock.findByName(TEST_EVENT_TYPE)).thenReturn(EVENT_TYPE);
    when(topicRepositoryMock.topicExists(eq(EVENT_TYPE.getName()))).thenReturn(true);
    when(topicRepositoryMock.loadPartitionStatistics(eq(TIMELINE), eq(UNKNOWN_PARTITION))).thenReturn(Optional.empty());
    final ThrowableProblem expectedProblem = Problem.valueOf(NOT_FOUND, "partition not found");
    mockMvc.perform(get(String.format("/event-types/%s/partitions/%s", TEST_EVENT_TYPE, UNKNOWN_PARTITION))).andExpect(status().isNotFound()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem)));
}
Also used : ThrowableProblem(org.zalando.problem.ThrowableProblem) Test(org.junit.Test)

Example 7 with ThrowableProblem

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

the class PartitionsControllerTest method whenGetPartitionForWrongTopicThenNotFound.

@Test
public void whenGetPartitionForWrongTopicThenNotFound() throws Exception {
    when(eventTypeRepositoryMock.findByName(UNKNOWN_EVENT_TYPE)).thenThrow(NoSuchEventTypeException.class);
    final ThrowableProblem expectedProblem = Problem.valueOf(NOT_FOUND, "topic not found");
    mockMvc.perform(get(String.format("/event-types/%s/partitions/%s", UNKNOWN_EVENT_TYPE, TEST_PARTITION))).andExpect(status().isNotFound()).andExpect(content().string(TestUtils.JSON_TEST_HELPER.matchesObject(expectedProblem)));
}
Also used : ThrowableProblem(org.zalando.problem.ThrowableProblem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 ThrowableProblem (org.zalando.problem.ThrowableProblem)7 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.anyString (org.mockito.Matchers.anyString)1 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)1 Subscription (org.zalando.nakadi.domain.Subscription)1 NoSuchEventTypeException (org.zalando.nakadi.exceptions.NoSuchEventTypeException)1 NoSuchSubscriptionException (org.zalando.nakadi.exceptions.NoSuchSubscriptionException)1