use of org.codenergic.theskeleton.user.UserEntity in project theskeleton by codenergic.
the class ProfileServiceTest method testUpdateProfile.
@Test
public void testUpdateProfile() {
when(userRepository.findByUsername(anyString())).thenReturn(new UserEntity());
profileService.updateProfile("username", new UserEntity());
verify(userRepository).findByUsername("username");
}
use of org.codenergic.theskeleton.user.UserEntity in project theskeleton by codenergic.
the class ProfileServiceTest method testUpdateProfilePicture.
@Test
public void testUpdateProfilePicture() throws Exception {
final InputStream inputStream = ClassLoader.getSystemResourceAsStream("static/logo.png");
when(userRepository.findByUsername("user")).thenReturn(new UserEntity());
profileService.updateProfilePicture("user", inputStream, "image/png");
verify(userRepository).findByUsername("user");
verify(minioClient).putObject(anyString(), anyString(), any(InputStream.class), eq("image/png"));
verify(minioClient).getObjectUrl(anyString(), anyString());
inputStream.close();
}
use of org.codenergic.theskeleton.user.UserEntity in project theskeleton by codenergic.
the class ProfileServiceTest method testUpdateProfilePassword.
@Test
public void testUpdateProfilePassword() {
final String rawPassword = "p@$$w0rd!";
when(userRepository.findByUsername("user")).thenReturn(new UserEntity());
final UserEntity result = profileService.updateProfilePassword("user", rawPassword);
assertThat(passwordEncoder.matches(rawPassword, result.getPassword())).isTrue();
verify(userRepository).findByUsername("user");
}
use of org.codenergic.theskeleton.user.UserEntity 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());
}
use of org.codenergic.theskeleton.user.UserEntity in project theskeleton by codenergic.
the class UserPostRestControllerTest method init.
@Before
public void init() {
mockMvc = MockMvcBuilders.standaloneSetup(new UserPostRestController(postService)).setCustomArgumentResolvers(new UserArgumentResolver(username -> new UserEntity().setUsername(username)), new AuthenticationPrincipalArgumentResolver(), new PageableHandlerMethodArgumentResolver()).apply(documentationConfiguration(restDocumentation)).build();
Authentication authentication = new TestingAuthenticationToken(new UserEntity().setId(USER_ID).setUsername(USERNAME), "1234");
SecurityContextHolder.getContext().setAuthentication(authentication);
}
Aggregations