### Question:
UserRolesServiceImpl implements UserRolesService { @Override public Page<UserRolesResponse> getAllUserRoles(String searchTerm, int page, int size) { Page<UserRoles> userRoles = userRolesRepository.findAllUserRolesDetails(searchTerm, PageRequest.of(page, size)); List<UserRolesResponse> allUserRolesList = Lists.newCopyOnWriteArrayList(); userRoles.getContent().forEach(userRoleDetail -> { UserRolesResponse userRolesResponse = new UserRolesResponse(); if(userRoleDetail != null){ userRolesResponse.setCreatedBy(userRoleDetail.getOwner()); userRolesResponse.setCreatedDate(userRoleDetail.getCreatedDate()); userRolesResponse.setModifiedDate(userRoleDetail.getModifiedDate()); userRolesResponse.setRoleId(userRoleDetail.getRoleId()); userRolesResponse.setDescription(userRoleDetail.getRoleDesc()); userRolesResponse.setRoleName(userRoleDetail.getRoleName()); userRolesResponse.setUsers(userRoleDetail.getUsers().parallelStream().map(user -> user != null ? user.getUserId() : StringUtils.EMPTY).collect(Collectors.toList())); allUserRolesList.add(userRolesResponse); } }); Page<UserRolesResponse> allUserRoles = new PageImpl<UserRolesResponse>(allUserRolesList, PageRequest.of(page, size), userRoles.getTotalElements()); return allUserRoles; }  @Override Page<UserRolesResponse> getAllUserRoles(String searchTerm, int page, int size); @Override String createUserRole(final CreateRoleDetailsRequest roleDetailsRequest, final String userId); @Override String updateUserRole(final UpdateRoleDetailsRequest roleDetailsRequest, final String userId); @Override UserRoles getUserRoleById(final String roleId);  }### Answer:
@Test public void getAllUserRolesTest() { List<UserRoles> userRolesDetails = Lists.newArrayList(); Optional<UserRoles> userRolesDetail = getUserRoleDetails(); userRolesDetails.add(userRolesDetail.get()); Page<UserRoles> allUserRolesDetails = new PageImpl<UserRoles>(userRolesDetails, new PageRequest(0, 1), userRolesDetails.size()); when(userRolesRepository.findAllUserRolesDetails(StringUtils.EMPTY, new PageRequest(0, 1))).thenReturn(allUserRolesDetails); assertThat(userRolesService.getAllUserRoles(StringUtils.EMPTY, 0, 1).getContent().size(), is(1)); }