### Question:
RMEndpoint { void setPolicies(Message message) { PolicyEngine engine = manager.getBus().getExtension(PolicyEngine.class); if (null == engine || !engine.isEnabled()) { return; } for (Endpoint endpoint : endpoints.values()) { EndpointInfo ei = endpoint.getEndpointInfo(); EndpointPolicy epi = null == conduit ? engine.getServerEndpointPolicy(applicationEndpoint.getEndpointInfo(), null, message) : engine.getClientEndpointPolicy(applicationEndpoint.getEndpointInfo(), conduit, message); if (conduit != null) { engine.setClientEndpointPolicy(ei, epi); } else { engine.setServerEndpointPolicy(ei, epi); } EffectivePolicyImpl effectiveOutbound = new EffectivePolicyImpl(); effectiveOutbound.initialise(epi, engine, false, false, message); EffectivePolicyImpl effectiveInbound = new EffectivePolicyImpl(); effectiveInbound.initialise(epi, engine, true, false, message); BindingInfo bi = ei.getBinding(); Collection<BindingOperationInfo> bois = bi.getOperations(); for (BindingOperationInfo boi : bois) { engine.setEffectiveServerRequestPolicy(ei, boi, effectiveInbound); engine.setEffectiveServerResponsePolicy(ei, boi, effectiveOutbound); engine.setEffectiveClientRequestPolicy(ei, boi, effectiveOutbound); engine.setEffectiveClientResponsePolicy(ei, boi, effectiveInbound); } } } 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 testSetPoliciesNoEngine() { Message m = new MessageImpl(); Bus bus = control.createMock(Bus.class); EasyMock.expect(manager.getBus()).andReturn(bus); EasyMock.expect(bus.getExtension(PolicyEngine.class)).andReturn(null); control.replay(); rme.setPolicies(m); }
@Test public void testSetPoliciesEngineDisabled() { Message m = new MessageImpl(); Bus bus = control.createMock(Bus.class); EasyMock.expect(manager.getBus()).andReturn(bus); PolicyEngineImpl pe = control.createMock(PolicyEngineImpl.class); EasyMock.expect(bus.getExtension(PolicyEngine.class)).andReturn(pe); EasyMock.expect(pe.isEnabled()).andReturn(false); control.replay(); rme.setPolicies(m); }