@Test public void getAllNonDeletedDtoShouldRespondWithEmptyJsonArrayWhenThereAreNoChannels() throws Exception { given(channelService.getAllNonDeletedDto()).willReturn(Collections.emptyList()); mockMvc .perform(get(REQUEST_URL)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$").isArray()) .andExpect(jsonPath("$").isEmpty()); then(channelService).should().getAllNonDeletedDto(); }
@Test public void getAllNonDeletedDtoShouldRespondWithJsonWithOneChannelWhenThereIsOneChannel() throws Exception { List<ChannelDTO> channels = Collections.singletonList(persistedDto); given(channelService.getAllNonDeletedDto()).willReturn(channels); mockMvc .perform(get(REQUEST_URL)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$").isArray()) .andExpect(jsonPath("$", hasSize(1))) .andExpect(jsonPath("$[0].id", is(CHANNEL_ID.intValue()))) .andExpect(jsonPath("$[0].name", is(CHANNEL_NAME))); then(channelService).should().getAllNonDeletedDto(); }