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)));
}
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)));
}
Aggregations