use of org.codenergic.theskeleton.user.UserRestData in project theskeleton by codenergic.
the class PostRestControllerTest method testFindPostReactions.
@Test
public void testFindPostReactions() throws Exception {
when(postReactionService.findUserByPostReaction(eq("1234"), eq(PostReactionType.LIKE), any())).thenReturn(new PageImpl<>(Collections.singletonList(new UserEntity().setUsername("user").setPictureUrl("1234"))));
MockHttpServletResponse response = mockMvc.perform(get("/api/posts/1234/reactions/likes").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andDo(document("post-reactions-read")).andReturn().getResponse();
assertThat(response.getStatus()).isEqualTo(200);
Page<UserRestData> expectedResponse = new PageImpl<>(Collections.singletonList(ImmutableUserRestData.builder().username("user").pictureUrl("1234").isNonLocked(false).build()));
assertThat(response.getContentAsString()).isEqualTo(objectMapper.writeValueAsString(expectedResponse));
verify(postReactionService).findUserByPostReaction(eq("1234"), eq(PostReactionType.LIKE), any());
}
Aggregations