Helper { public static Caller getCaller(IdentityManager identityManager, String loginName) throws IdentityManagementException { if (identityManager == null) { throw MESSAGES.nullArgument("IdentityManager"); } if (isNullOrEmpty(loginName)) { return null; } IdentityQueryBuilder queryBuilder = identityManager.getQueryBuilder(); List<Caller> callers = queryBuilder.createIdentityQuery(Caller.class) .where(queryBuilder.equal(Caller.LOGIN_NAME, loginName)).getResultList(); if (callers.isEmpty()) { return null; } else if (callers.size() == 1) { return callers.get(0); } else { throw new IdentityManagementException("Error - multiple Caller objects found with same login name"); } }  static Caller getCaller(IdentityManager identityManager, String loginName); static Role getRole(IdentityManager identityManager, String name); static Group getGroup(IdentityManager identityManager, String groupPath); static Group getGroup(IdentityManager identityManager, String groupName, Group parent); static boolean isMember(RelationshipManager relationshipManager, Account member, Group group); static void addToGroup(RelationshipManager relationshipManager, Account member, Group group); static void removeFromGroup(RelationshipManager relationshipManager, Account member, Group group); static boolean hasRole(RelationshipManager relationshipManager, RoleAssignable assignee, Role role); static void grantRole(RelationshipManager relationshipManager, RoleAssignable assignee, Role role); static void revokeRole(RelationshipManager relationshipManager, RoleAssignable assignee, Role role);  }
@Test public void caller() { assertNull(Helper.getCaller(identityManager, "foo")); Caller joe = new Caller("joe"); Caller sam = new Caller("sam"); Caller mary = new Caller("mary"); identityManager.add(joe); identityManager.add(sam); identityManager.add(mary); assertEquals("joe", joe, Helper.getCaller(identityManager, "joe")); assertEquals("sam", sam, Helper.getCaller(identityManager, "sam")); assertEquals("mary", mary, Helper.getCaller(identityManager, "mary")); }