use of py.org.fundacionparaguaya.pspserver.security.dtos.UserDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class UserApplicationMapper method entityToUserDto.
public UserDTO entityToUserDto(UserApplicationEntity entity) {
UserDTO dto = userMapper.entityToDto(entity.getUser());
entity.getApplicationOpt().ifPresent(application -> dto.setApplication(applicationMapper.entityToDto(application)));
entity.getOrganizationOpt().ifPresent(organization -> dto.setOrganization(organizationMapper.entityToDto(organization)));
return dto;
}
use of py.org.fundacionparaguaya.pspserver.security.dtos.UserDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class UserMapper method entityToDto.
@Override
public UserDTO entityToDto(UserEntity entity) {
UserDTO dto = modelMapper.map(entity, UserDTO.class);
dto.setPass(null);
return dto;
}
use of py.org.fundacionparaguaya.pspserver.security.dtos.UserDTO in project FP-PSP-SERVER by FundacionParaguaya.
the class UserControllerTest method requestingPostUserShouldFailIfUserAlreadyExists.
@Test
public void requestingPostUserShouldFailIfUserAlreadyExists() throws Exception {
UserDTO dto = UserDTO.builder().username("admin").email("foo@bar").pass("123").build();
when(userService.addUser(anyObject())).thenThrow(new CustomParameterizedException("User already exists.", new ImmutableMultimap.Builder<String, String>().put("username", dto.getUsername()).build().asMap()));
String json = TestHelper.mapToJson(dto);
mockMvc.perform(post("/api/v1/users").content(json).contentType(MediaType.APPLICATION_JSON)).andDo(print()).andExpect(status().isBadRequest()).andExpect(jsonPath("$.message", containsString("User already exists."))).andExpect(jsonPath("$.fieldErrors.[0].field", is("username"))).andExpect(jsonPath("$.fieldErrors.[0].messages[0]").value("admin"));
}
Aggregations