### Question:
RMEndpoint { Object getUsingAddressing(EndpointInfo endpointInfo) { if (null == endpointInfo) { return null; } Object ua = null; List<ExtensibilityElement> exts = endpointInfo.getExtensors(ExtensibilityElement.class); ua = getUsingAddressing(exts); if (null != ua) { return ua; } exts = endpointInfo.getBinding() != null ? endpointInfo.getBinding() .getExtensors(ExtensibilityElement.class) : null; ua = getUsingAddressing(exts); if (null != ua) { return ua; } exts = endpointInfo.getService() != null ? endpointInfo.getService() .getExtensors(ExtensibilityElement.class) : null; ua = getUsingAddressing(exts); if (null != ua) { return ua; } return ua; } RMEndpoint(RMManager m, Endpoint ae); RMManager getManager(); Endpoint getApplicationEndpoint(); Endpoint getEndpoint(ProtocolVariation protocol); Service getService(ProtocolVariation protocol); BindingInfo getBindingInfo(ProtocolVariation protocol); Proxy getProxy(); Servant getServant(); Destination getDestination(); void setDestination(Destination destination); Source getSource(); void setSource(Source source); long getLastApplicationMessage(); int getApplicationMessageCount(); void receivedApplicationMessage(); long getLastControlMessage(); int getControlMessageCount(); void receivedControlMessage(); Conduit getConduit(); RMConfiguration getConfiguration(); void handleAccept(String ssid, long number, Message msg); void handleAcknowledgment(String ssid, long number, Message msg);  }### Answer:
@Test public void testGetUsingAddressing() { EndpointInfo ei = null; control.replay(); assertNull(rme.getUsingAddressing(ei)); control.verify(); control.reset(); ExtensibilityElement ua = control.createMock(ExtensibilityElement.class); ei = control.createMock(EndpointInfo.class); List<ExtensibilityElement> noExts = new ArrayList<>(); List<ExtensibilityElement> exts = new ArrayList<>(); exts.add(ua); EasyMock.expect(ei.getExtensors(ExtensibilityElement.class)).andReturn(noExts); BindingInfo bi = control.createMock(BindingInfo.class); EasyMock.expect(ei.getBinding()).andReturn(bi).times(2); EasyMock.expect(bi.getExtensors(ExtensibilityElement.class)).andReturn(noExts); ServiceInfo si = control.createMock(ServiceInfo.class); EasyMock.expect(ei.getService()).andReturn(si).times(2); EasyMock.expect(si.getExtensors(ExtensibilityElement.class)).andReturn(exts); EasyMock.expect(ua.getElementType()).andReturn(Names.WSAW_USING_ADDRESSING_QNAME); control.replay(); assertSame(ua, rme.getUsingAddressing(ei)); }
@Test public void testGetUsingAddressingFromExtensions() { List<ExtensibilityElement> exts = new ArrayList<>(); ExtensibilityElement ua = control.createMock(ExtensibilityElement.class); exts.add(ua); EasyMock.expect(ua.getElementType()).andReturn(Names.WSAW_USING_ADDRESSING_QNAME); control.replay(); assertSame(ua, rme.getUsingAddressing(exts)); }