### Question:
RealmHelper { public Set<String> getAssociatedRealmIds() { HashSet<String> toReturn = new HashSet<String>(); if (isSandboxEnabled) { toReturn.add(getSandboxRealmId()); } else { NeutralQuery realmQuery = new NeutralQuery(); String edOrg = SecurityUtil.getEdOrg(); LOG.debug("Looking up realms for edorg {}.", edOrg); realmQuery.addCriteria(new NeutralCriteria("edOrg", NeutralCriteria.OPERATOR_EQUAL, edOrg)); realmQuery .addCriteria(new NeutralCriteria("tenantId", NeutralCriteria.OPERATOR_EQUAL, SecurityUtil .getTenantId())); Iterable<String> realmIds = repo.findAllIds("realm", realmQuery); for (String id : realmIds) { toReturn.add(id); } } return toReturn; }  String getSandboxRealmId(); String getAdminRealmId(); String getEdOrgIdFromRealm(String realmId); Entity getRealmFromSession(String sessionId); List<String> getPreferredLoginRealmIds(Entity userEntity); Iterable<Entity> getRealms(Entity edOrg); boolean isUserAllowedLoginToRealm(Entity userEntity, Entity realm); Set<String> getAssociatedRealmIds(); Entity findRealmById(String id); static final String USER_SESSION; }### Answer:
@Test public void testGetAssociatedRealmIsTenantSpecific() { Entity sea = buildEdOrg("SEA1", null, injector.TENANT_ID, true); Entity lea1 = buildEdOrg("LEA1", sea, injector.TENANT_ID, false); Entity lea2 = buildEdOrg("LEA1", null, "Two", false); Entity lea2Realm = buildRealm(lea2, "Two"); Entity lea1Realm = buildRealm(lea1, injector.TENANT_ID); Entity staff = buildStaff("LEA One", lea1); injector.setCustomContext("LEA", "LEA One", lea1Realm.getEntityId(), Arrays.asList("Realm Administrator"), staff, (String) lea1Realm.getBody().get("edOrg")); Set<String> realmIds = helper.getAssociatedRealmIds(); assertTrue(realmIds != null); assertTrue(realmIds.contains(lea1Realm.getEntityId())); }