@Test public void testLoadExternalLinksIntoExtensionElements() { final org.kie.workbench.common.dmn.api.definition.model.DRGElement source = mock(org.kie.workbench.common.dmn.api.definition.model.DRGElement.class); final org.kie.dmn.model.api.DRGElement target = mock(org.kie.dmn.model.api.DRGElement.class); final DocumentationLinksHolder linksHolder = mock(DocumentationLinksHolder.class); when(source.getLinksHolder()).thenReturn(linksHolder); final DocumentationLinks documentationLinks = new DocumentationLinks(); final String url1 = "url1"; final String description1 = "desc1"; final org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink link1 = createWBExternalLinkMock(description1, url1); documentationLinks.addLink(link1); final String url2 = "url2"; final String description2 = "desc2"; final org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink link2 = createWBExternalLinkMock(description2, url2); documentationLinks.addLink(link2); when(linksHolder.getValue()).thenReturn(documentationLinks); final DMNElement.ExtensionElements extensionElements = mock(DMNElement.ExtensionElements.class); when(target.getExtensionElements()).thenReturn(extensionElements); final List<Object> externalLinks = new ArrayList<>(); when(extensionElements.getAny()).thenReturn(externalLinks); loadExternalLinksIntoExtensionElements(source, target); assertEquals(2, externalLinks.size()); compare((ExternalLink) externalLinks.get(0), description1, url1); compare((ExternalLink) externalLinks.get(1), description2, url2); }
static void loadExternalLinksIntoExtensionElements(final org.kie.workbench.common.dmn.api.definition.model.DRGElement source, final org.kie.dmn.model.api.DRGElement target) { if (Objects.isNull(source.getLinksHolder()) || Objects.isNull(source.getLinksHolder().getValue())) { return; } final DocumentationLinks links = source.getLinksHolder().getValue(); final DMNElement.ExtensionElements elements = getOrCreateExtensionElements(target); removeAllExistingLinks(elements); for (final DMNExternalLink link : links.getLinks()) { final ExternalLink external = new ExternalLink(); external.setName(link.getDescription()); external.setUrl(link.getUrl()); elements.getAny().add(external); } target.setExtensionElements(elements); }
DMNExternalLinksToExtensionElements { static void loadExternalLinksIntoExtensionElements(final org.kie.workbench.common.dmn.api.definition.model.DRGElement source, final org.kie.dmn.model.api.DRGElement target) { if (Objects.isNull(source.getLinksHolder()) || Objects.isNull(source.getLinksHolder().getValue())) { return; } final DocumentationLinks links = source.getLinksHolder().getValue(); final DMNElement.ExtensionElements elements = getOrCreateExtensionElements(target); removeAllExistingLinks(elements); for (final DMNExternalLink link : links.getLinks()) { final ExternalLink external = new ExternalLink(); external.setName(link.getDescription()); external.setUrl(link.getUrl()); elements.getAny().add(external); } target.setExtensionElements(elements); } }
DMNExternalLinksToExtensionElements { static void loadExternalLinksIntoExtensionElements(final org.kie.workbench.common.dmn.api.definition.model.DRGElement source, final org.kie.dmn.model.api.DRGElement target) { if (Objects.isNull(source.getLinksHolder()) || Objects.isNull(source.getLinksHolder().getValue())) { return; } final DocumentationLinks links = source.getLinksHolder().getValue(); final DMNElement.ExtensionElements elements = getOrCreateExtensionElements(target); removeAllExistingLinks(elements); for (final DMNExternalLink link : links.getLinks()) { final ExternalLink external = new ExternalLink(); external.setName(link.getDescription()); external.setUrl(link.getUrl()); elements.getAny().add(external); } target.setExtensionElements(elements); }  }
DMNExternalLinksToExtensionElements { static void loadExternalLinksIntoExtensionElements(final org.kie.workbench.common.dmn.api.definition.model.DRGElement source, final org.kie.dmn.model.api.DRGElement target) { if (Objects.isNull(source.getLinksHolder()) || Objects.isNull(source.getLinksHolder().getValue())) { return; } final DocumentationLinks links = source.getLinksHolder().getValue(); final DMNElement.ExtensionElements elements = getOrCreateExtensionElements(target); removeAllExistingLinks(elements); for (final DMNExternalLink link : links.getLinks()) { final ExternalLink external = new ExternalLink(); external.setName(link.getDescription()); external.setUrl(link.getUrl()); elements.getAny().add(external); } target.setExtensionElements(elements); }   }
DMNExternalLinksToExtensionElements { static void loadExternalLinksIntoExtensionElements(final org.kie.workbench.common.dmn.api.definition.model.DRGElement source, final org.kie.dmn.model.api.DRGElement target) { if (Objects.isNull(source.getLinksHolder()) || Objects.isNull(source.getLinksHolder().getValue())) { return; } final DocumentationLinks links = source.getLinksHolder().getValue(); final DMNElement.ExtensionElements elements = getOrCreateExtensionElements(target); removeAllExistingLinks(elements); for (final DMNExternalLink link : links.getLinks()) { final ExternalLink external = new ExternalLink(); external.setName(link.getDescription()); external.setUrl(link.getUrl()); elements.getAny().add(external); } target.setExtensionElements(elements); }    }