TypedQuery<IdpRole> query = mock(TypedQuery.class);
@SuppressWarnings("unchecked")
TypedQuery<IdpRole> parameterQuery = mock(TypedQuery.class);
when(em.createQuery("SELECT r from IdpRole r WHERE rolename = :rolename", IdpRole.class)).thenReturn(query);
when(query.setParameter(anyString(), anyObject())).thenReturn(parameterQuery);
IdpRole authenticatedRole = new IdpRole();
authenticatedRole.setRoleName("authenticated");
when(parameterQuery.getSingleResult()).thenReturn(authenticatedRole);
userManager.setEntityManager(em);
// -- test --
IdpUser submittedUser = new IdpUser();