### Question:
Destination extends ManageableComponent implements java.io.Serializable { public void setService(Service service) { Service oldService = getService(); setParent(service); if (oldService != null) oldService.removeDestination(getId()); if (service.getDestination(getId()) != this) service.addDestination(this); } Destination();  Destination(boolean enableManagement); @Override void initialize(String id, ConfigMap properties); boolean isInitialized(); @Override void start(); @Override void stop(); ServiceAdapter getAdapter(); ServiceAdapter createAdapter(String id); void setAdapter(ServiceAdapter adapter); boolean isBackendShared(); List<String> getChannels(); void addChannel(String id); boolean removeChannel(String id); void setChannels(List<String> ids); boolean isClustered(); @Override void setId(String id); NetworkSettings getNetworkSettings(); void setNetworkSettings(NetworkSettings networkSettings); Service getService(); void setService(Service service); String getServiceType(); SecurityConstraint getSecurityConstraint(); void setSecurityConstraint(SecurityConstraint securityConstraint); void setSecurityConstraint(String ref); ConfigMap describeDestination(); ConfigMap describeDestination(boolean onlyReliable); void addExtraProperty(String name, Object value); Object getExtraProperty(String name); static final String LOG_CATEGORY; static final String PUSH_DESTINATION_ID; }### Answer:
@Test public void testSetService() { MessageBroker broker = new MessageBroker(false); broker.initThreadLocals(); AbstractService service = new MessageService(); service.setId("dummy-service"); broker.addService(service); destination.setService(service); MessageService actualSvc = (MessageService) destination.getService(); Assert.assertEquals(service, actualSvc); Destination actualDest = service.getDestination(destination.getId()); Assert.assertEquals(destination, actualDest); }
@Test public void testSetServiceNull() { try { destination.setService(null); Assert.fail("ConfigurationException expected"); } catch (ConfigurationException ce) { int error = 11116; Assert.assertEquals(ce.getNumber(), error); } }