### Question:
AssertionInfoMap extends HashMap<QName, Collection<AssertionInfo>> { public List<List<Assertion>> checkEffectivePolicy(Policy policy) { List<List<Assertion>> validated = new ArrayList<>(4); List<QName> errors = new ArrayList<>(); Iterator<List<Assertion>> alternatives = policy.getAlternatives(); while (alternatives.hasNext()) { List<Assertion> pc = alternatives.next(); if (supportsAlternative(pc, errors)) { validated.add(pc); } } if (!validated.isEmpty()) { return validated; } Set<String> msgs = new LinkedHashSet<>(); for (QName name : errors) { Collection<AssertionInfo> ais = getAssertionInfo(name); boolean found = false; for (AssertionInfo ai : ais) { if (!ai.isAsserted()) { String s = name.toString(); if (ai.getErrorMessage() != null) { s += ": " + ai.getErrorMessage(); } msgs.add(s); found = true; } } if (!found) { msgs.add(name.toString()); } } StringBuilder error = new StringBuilder(); for (String msg : msgs) { error.append('\n').append(msg); } throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE, error.toString())); } AssertionInfoMap(Policy p);  AssertionInfoMap(Collection<? extends Assertion> assertions); Collection<AssertionInfo> getAssertionInfo(QName name); boolean supportsAlternative(PolicyComponent assertion,
                                       List<QName> errors); boolean supportsAlternative(Collection<? extends PolicyComponent> alternative,
                                       List<QName> errors); List<List<Assertion>> checkEffectivePolicy(Policy policy); void check();  }### Answer:
@Test public void testCheckEffectivePolicy() { Policy p = new Policy(); QName aqn = new QName("http: Assertion a = new PrimitiveAssertion(aqn); QName bqn = new QName("http: Assertion b = new PrimitiveAssertion(bqn); QName cqn = new QName("http: Assertion c = new PrimitiveAssertion(cqn); All alt1 = new All(); alt1.addAssertion(a); alt1.addAssertion(b); All alt2 = new All(); alt2.addAssertion(c); ExactlyOne ea = new ExactlyOne(); ea.addPolicyComponent(alt1); ea.addPolicyComponent(alt2); p.addPolicyComponent(ea); AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, PolicyAssertion.class)); AssertionInfo ai = new AssertionInfo(a); AssertionInfo bi = new AssertionInfo(b); AssertionInfo ci = new AssertionInfo(c); aim.put(aqn, Collections.singleton(ai)); aim.put(bqn, Collections.singleton(bi)); aim.put(cqn, Collections.singleton(ci)); try { aim.checkEffectivePolicy(p); fail("Expected PolicyException not thrown."); } catch (PolicyException ex) { } ai.setAsserted(true); ci.setAsserted(true); aim.checkEffectivePolicy(p); }