EmrUtils { public static Provider getProvider(User user) { Person person = user.getPerson(); Collection<Provider> providers = Context.getProviderService().getProvidersByPerson(person); return providers.size() > 0 ? providers.iterator().next() : null; }  static boolean dateHasTime(Date date); static boolean isToday(Date date); static Integer whoStage(Concept c); static List<String> parseCsv(String csv); static List<Concept> parseConcepts(String csv); static Provider getProvider(User user);  }
@Test public void getProvider_shouldReturnFirstAssociatedProviderOfUserOrNull() { Assert.assertThat(EmrUtils.getProvider(Context.getAuthenticatedUser()), is(Context.getProviderService().getProvider(1))); User user = new User(); user.setPerson(Context.getPersonService().getPerson(2)); user.setUsername("user2"); Context.getUserService().saveUser(user, "Qwerty123"); Assert.assertThat(EmrUtils.getProvider(user), nullValue()); }