/** * @see org.openmrs.Attributable#getPossibleValues() */ @Override public List<User> getPossibleValues() { try { return Context.getUserService().getAllUsers(); } catch (Exception e) { return Collections.emptyList(); } }
/** * @see UserService#getAllUsers() */ @Test public void getAllUsers_shouldFetchAllUsersInTheSystem() { List<User> users = userService.getAllUsers(); Assert.assertEquals(3, users.size()); }
/** * @see UserService#getAllUsers() */ @Test public void getAllUsers_shouldNotContainsAnyDuplicateUsers() { executeDataSet(XML_FILENAME); List<User> users = userService.getAllUsers(); assertEquals(11, users.size()); // TODO Need to test with duplicate data in the dataset (not sure if that's possible) }
@RunWith( SpringJUnit4ClassRunner.class ) @ContextConfiguration(locations = { "classpath:META-INF/your-spring-context.xml" }) public class UserServiceTest extends AbstractJUnit4SpringContextTests { @Autowired private UserService userService; @Test public void testName() throws Exception { List<UserEntity> userEntities = userService.getAllUsers(); Assert.assertNotNull(userEntities); } }
@RunWith( SpringJUnit4ClassRunner.class ) @ContextConfiguration(locations = { "classpath:META-INF/your-spring-context.xml" }) public class UserServiceTest extends AbstractJUnit4SpringContextTests { @Autowired private UserService userService; @Test public void testName() throws Exception { List<UserEntity> userEntities = userService.getAllUsers(); Assert.assertNotNull(userEntities); } }
for (User user : Context.getUserService().getAllUsers()) { String output = "<update tableName=\"users\"><column name=\"uuid\" value=\"" + user.getUuid() + "\"/><where> user_id = '" + user.getUserId() + "' and system_id = '"
/** * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() */ @Override public long getAllCount() { return service.getAllUsers().size(); } }
/** * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() */ @Override public long getAllCount() { return service.getAllUsers().size(); } }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<UserAndPassword1_8> doGetAll(RequestContext context) { List<UserAndPassword1_8> users = new ArrayList<UserAndPassword1_8>(); for (User user : Context.getUserService().getAllUsers()) { users.add(new UserAndPassword1_8(user)); } return new NeedsPaging<UserAndPassword1_8>(users, context); } }
/** * Gets all users present in the openMRS system * * @return List of all Users if users exist, else empty list */ @Override public List<MRSUser> getAllUsers() { List<MRSUser> mrsUsers = new ArrayList<>(); List<org.openmrs.User> openMRSUsers = userService.getAllUsers(); for (org.openmrs.User openMRSUser : openMRSUsers) { if (isSystemAdmin(openMRSUser.getSystemId())) { continue; } mrsUsers.add(openMrsToMrsUser(openMRSUser)); } return mrsUsers; }
List<User> allUsers = userService.getAllUsers(); assertEquals(10, allUsers.size());
@Override public String generateHtml(FormEntryContext context) { if (context.getMode() == Mode.VIEW) { if (user != null) return WidgetFactory.displayValue(user.getPersonName().toString()); else return ""; } StringBuilder sb = new StringBuilder(); sb.append("<select name=\"" + context.getFieldName(this) + "\">"); // TODO translate sb.append("\n<option value=\"\">"); sb.append(Context.getMessageSourceService().getMessage("general.choose") + "..."); sb.append("</option>"); List<User> userList; if (options != null) { userList = options; } else { userList = Context.getUserService().getAllUsers(); } for (User u : userList) { sb.append("\n<option"); if (user != null && user.equals(u)) sb.append(" selected=\"true\""); sb.append(" value=\"" + u.getUserId() + "\">").append(u.getPersonName()).append("</option>"); } sb.append("</select>"); return sb.toString(); }