MotechUser { public boolean hasRole(String role) { return CollectionUtils.isNotEmpty(roles) && roles.contains(role); } MotechUser();  MotechUser(String userName, String password, String email, String externalId,
                      List<String> roles, String openId, Locale locale); String getExternalId(); String getUserName(); String getPassword(); void setPassword(String password); List<String> getRoles(); String getEmail(); void setEmail(String email); void setUserName(String userName); void setRoles(List<String> roles); void setExternalId(String externalId); UserStatus getUserStatus(); void setUserStatus(UserStatus userStatus); String getOpenId(); void setOpenId(String openId); Locale getLocale(); void setLocale(Locale locale); Integer getFailureLoginCounter(); void setFailureLoginCounter(Integer failureLoginCounter); boolean hasRole(String role); DateTime getLastPasswordChange(); void setLastPasswordChange(DateTime lastPasswordChange); DateTime getModificationDate(); void setModificationDate(DateTime modificationDate); @Ignore DateTime getSafeLastPasswordChange(); @Ignore void incrementFailureLoginCounter(); @Ignore boolean isActive(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void shouldReturnTrueIfUserHasGivenRole() { List<String> roles = Arrays.asList("fooRole"); MotechUser user = new MotechUser(null, "p@ssw0rd", "", "", roles, "", Locale.ENGLISH); assertTrue(user.hasRole("fooRole")); assertFalse(user.hasRole("barRole")); }