@Test public void shouldListWebUsersByRole() { MotechUser provider1 = new MotechUserCouchdbImpl( "provider1", "testpassword", "*****@*****.**", "id1", asList("PROVIDER"), ""); MotechUser provider2 = new MotechUserCouchdbImpl( "provider2", "testpassword", "*****@*****.**", "id2", asList("PROVIDER"), ""); MotechUser cmfAdmin = new MotechUserCouchdbImpl( "cmfadmin", "testpassword", "*****@*****.**", "id3", asList("CMFADMIN"), ""); MotechUser itAdmin = new MotechUserCouchdbImpl( "itadmin", "testpassword", "*****@*****.**", "id4", asList("ITADMIN"), ""); allMotechUsers.add(provider1); allMotechUsers.add(provider2); allMotechUsers.add(cmfAdmin); allMotechUsers.add(itAdmin); List<? extends MotechUser> providers = allMotechUsers.findByRole("PROVIDER"); assertEquals(asList("id1", "id2"), extract(providers, on(MotechUser.class).getExternalId())); }