JmsDestinationLinker implements EntityLinker<JmsDestination> { private void linkInboundAssociatedService(JmsDestination entity, Bundle bundle) { if (entity.getInboundDetail() == null || entity.getInboundDetail().getServiceResolutionSettings() == null || StringUtils.isEmpty(entity.getInboundDetail().getServiceResolutionSettings().getServiceRef())) { return; } final String serviceRef = entity.getInboundDetail().getServiceResolutionSettings().getServiceRef(); final Service service = bundle.getEntities(Service.class).values() .stream() .filter(e -> e.getId().equals(serviceRef)) .findFirst() .orElse(null); if (service == null) { throw new LinkerException("Could not find associated Service for inbound JMS Destination: " + entity.getName() + ". Service path: " + serviceRef); } entity.getInboundDetail().getServiceResolutionSettings().setServiceRef(getServicePath(bundle, service)); }  @Override Class<JmsDestination> getEntityClass(); @Override void link(JmsDestination entity, Bundle bundle, Bundle targetBundle);  }
@Test void testLinkInboundAssociatedService() { Bundle bundle = new Bundle(); Folder folder = createFolder("my-folder-name", "my-folder-id", Folder.ROOT_FOLDER); Service service = createService("my-service-name", "my-service-id", folder, null, ""); FolderTree folderTree = new FolderTree(ImmutableSet.of(folder, folder.getParentFolder())); bundle.setFolderTree(folderTree); bundle.addEntity(folder); bundle.addEntity(service); final ServiceResolutionSettings serviceResolutionSettings = new ServiceResolutionSettings(); serviceResolutionSettings.setServiceRef("my-service-id"); final InboundJmsDestinationDetail inboundDetail = new InboundJmsDestinationDetail(); inboundDetail.setAcknowledgeType(ON_TAKE); inboundDetail.setReplyType(NO_REPLY); inboundDetail.setUseRequestCorrelationId(false); inboundDetail.setServiceResolutionSettings(serviceResolutionSettings); final JmsDestination jmsDestination = createJmsDestinationBuilder(null,null) .inboundDetail(inboundDetail) .build(); linker.link(jmsDestination, bundle, bundle); assertNotNull(jmsDestination.getInboundDetail()); assertNotNull(jmsDestination.getInboundDetail().getServiceResolutionSettings()); assertEquals("my-folder-name/my-service-name", jmsDestination.getInboundDetail().getServiceResolutionSettings().getServiceRef()); }