@Test void getAllMolgenisUsersSu() { String molgenisUserId0 = "id0"; String molgenisUserName0 = "user0"; User user0 = when(mock(User.class).getId()).thenReturn(molgenisUserId0).getMock(); when(user0.getUsername()).thenReturn(molgenisUserName0); String molgenisUserId1 = "id1"; String molgenisUserName1 = "user1"; User user1 = when(mock(User.class).getId()).thenReturn(molgenisUserId1).getMock(); when(user1.getUsername()).thenReturn(molgenisUserName1); when(dataService.findOneById(USER, molgenisUserId0, User.class)).thenReturn(user0); when(dataService.findOneById(USER, molgenisUserId1, User.class)).thenReturn(user1); when(dataService.findAll(USER, User.class)).thenReturn(Stream.of(user0, user1)); this.setSecurityContextSuperUser(); assertEquals( asList(new UserViewData(user0), new UserViewData(user1)), userManagerService.getAllUsers()); }
@Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional(readOnly = true) public List<UserViewData> getAllUsers() { Stream<User> users = dataService.findAll(USER, User.class); return this.parseToMolgenisUserViewData(users); }
UserManagerServiceImpl implements UserManagerService { @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional(readOnly = true) public List<UserViewData> getAllUsers() { Stream<User> users = dataService.findAll(USER, User.class); return this.parseToMolgenisUserViewData(users); } }
UserManagerServiceImpl implements UserManagerService { @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional(readOnly = true) public List<UserViewData> getAllUsers() { Stream<User> users = dataService.findAll(USER, User.class); return this.parseToMolgenisUserViewData(users); } UserManagerServiceImpl(DataService dataService); }
UserManagerServiceImpl implements UserManagerService { @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional(readOnly = true) public List<UserViewData> getAllUsers() { Stream<User> users = dataService.findAll(USER, User.class); return this.parseToMolgenisUserViewData(users); } UserManagerServiceImpl(DataService dataService); @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional(readOnly = true) List<UserViewData> getAllUsers(); @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional void setActivationUser(String userId, Boolean active); }
UserManagerServiceImpl implements UserManagerService { @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional(readOnly = true) public List<UserViewData> getAllUsers() { Stream<User> users = dataService.findAll(USER, User.class); return this.parseToMolgenisUserViewData(users); } UserManagerServiceImpl(DataService dataService); @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional(readOnly = true) List<UserViewData> getAllUsers(); @Override @PreAuthorize("hasAnyRole('ROLE_SU','ROLE_MANAGER')") @Transactional void setActivationUser(String userId, Boolean active);  }