### Question:
ExternalAttachmentProvider extends AbstractPolicyProvider { public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) { readDocument(); Policy p = null; for (PolicyAttachment pa : attachments) { if (pa.appliesTo(bfi)) { if (p == null) { p = new Policy(); } p = p.merge(pa.getPolicy()); } } return p; } ExternalAttachmentProvider();   ExternalAttachmentProvider(Bus b); void setLocation(Resource u); Resource getLocation(); Policy getEffectivePolicy(BindingFaultInfo bfi, Message m); Policy getEffectivePolicy(BindingMessageInfo bmi, Message m); Policy getEffectivePolicy(BindingOperationInfo boi, Message m); Policy getEffectivePolicy(EndpointInfo ei, Message m); Policy getEffectivePolicy(ServiceInfo si, Message m); Collection<PolicyAttachment> getAttachments();  }### Answer:
@Test public void testGetEffectiveFaultPolicy() { ExternalAttachmentProvider eap = new ExternalAttachmentProvider(); BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); setUpAttachment(bfi, false, eap); control.replay(); assertNull(eap.getEffectivePolicy(bfi, null)); control.verify(); control.reset(); setUpAttachment(bfi, true, eap); control.replay(); assertSame(assertion, eap.getEffectivePolicy(bfi, null).getAssertions().get(0)); control.verify(); }
@Test public void testGetEffectiveMessagePolicy() { ExternalAttachmentProvider eap = new ExternalAttachmentProvider(); BindingMessageInfo bmi = control.createMock(BindingMessageInfo.class); setUpAttachment(bmi, false, eap); control.replay(); assertNull(eap.getEffectivePolicy(bmi, null)); control.verify(); control.reset(); setUpAttachment(bmi, true, eap); control.replay(); assertSame(assertion, eap.getEffectivePolicy(bmi, null).getAssertions().get(0)); control.verify(); }
@Test public void testGetEffectiveOperationPolicy() { BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); ExternalAttachmentProvider eap = new ExternalAttachmentProvider(); setUpAttachment(boi, false, eap); control.replay(); assertNull(eap.getEffectivePolicy(boi, null)); control.verify(); control.reset(); setUpAttachment(boi, true, eap); control.replay(); assertSame(assertion, eap.getEffectivePolicy(boi, null).getAssertions().get(0)); control.verify(); }
@Test public void testGetEffectiveEndpointPolicy() { ExternalAttachmentProvider eap = new ExternalAttachmentProvider(); EndpointInfo ei = control.createMock(EndpointInfo.class); setUpAttachment(ei, false, eap); control.replay(); assertNull(eap.getEffectivePolicy(ei, null)); control.verify(); control.reset(); setUpAttachment(ei, true, eap); control.replay(); assertSame(assertion, eap.getEffectivePolicy(ei, null).getAssertions().get(0)); control.verify(); }
@Test public void testGetEffectiveServicePolicy() { ExternalAttachmentProvider eap = new ExternalAttachmentProvider(); ServiceInfo si = control.createMock(ServiceInfo.class); setUpAttachment(si, false, eap); control.replay(); assertNull(eap.getEffectivePolicy(si, null)); control.verify(); control.reset(); setUpAttachment(si, true, eap); control.replay(); assertSame(assertion, eap.getEffectivePolicy(si, null).getAssertions().get(0)); control.verify(); }