use of com.baeldung.service.dto.UserDTO in project tutorials by eugenp.
the class UserServiceIntegrationTest method assertThatAnonymousUserIsNotGet.
@Test
public void assertThatAnonymousUserIsNotGet() {
final PageRequest pageable = new PageRequest(0, (int) userRepository.count());
final Page<UserDTO> allManagedUsers = userService.getAllManagedUsers(pageable);
assertThat(allManagedUsers.getContent().stream().noneMatch(user -> Constants.ANONYMOUS_USER.equals(user.getLogin()))).isTrue();
}
use of com.baeldung.service.dto.UserDTO in project tutorials by eugenp.
the class UserResource method getAllUsers.
/**
* GET /users : get all users.
*
* @param pageable the pagination information
* @return the ResponseEntity with status 200 (OK) and with body all users
*/
@GetMapping("/users")
@Timed
public ResponseEntity<List<UserDTO>> getAllUsers(@ApiParam Pageable pageable) {
final Page<UserDTO> page = userService.getAllManagedUsers(pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/users");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of com.baeldung.service.dto.UserDTO in project tutorials by eugenp.
the class AccountResourceIntegrationTest method testSaveInvalidLogin.
@Test
@Transactional
public void testSaveInvalidLogin() throws Exception {
UserDTO invalidUser = new UserDTO(// id
null, // login <-- invalid
"funky-log!n", // firstName
"Funky", // lastName
"One", // e-mail
"funky@example.com", // activated
true, // imageUrl
"http://placehold.it/50x50", // langKey
"en", // createdBy
null, // createdDate
null, // lastModifiedBy
null, // lastModifiedDate
null, new HashSet<>(Arrays.asList(AuthoritiesConstants.USER)));
restUserMockMvc.perform(post("/api/account").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(invalidUser))).andExpect(status().isBadRequest());
Optional<User> user = userRepository.findOneByEmail("funky@example.com");
assertThat(user.isPresent()).isFalse();
}
Aggregations