Search in sources :

Example 1 with DocumentationLinks

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks in project kie-wb-common by kiegroup.

the class DMNExternalLinksToExtensionElements method loadExternalLinksIntoExtensionElements.

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);
}
Also used : DocumentationLinks(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks) DMNElement(org.kie.dmn.model.api.DMNElement) TDMNElement(org.kie.dmn.model.v1_2.TDMNElement) DMNExternalLink(org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink) ExternalLink(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ExternalLink) DMNExternalLink(org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink)

Example 2 with DocumentationLinks

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks in project kie-wb-common by kiegroup.

the class DMNExternalLinksToExtensionElementsTest method testLoadExternalLinksIntoExtensionElements.

@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);
}
Also used : DocumentationLinksHolder(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder) ArrayList(java.util.ArrayList) DocumentationLinks(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks) DMNElement(org.kie.dmn.model.api.DMNElement) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Example 3 with DocumentationLinks

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks in project kie-wb-common by kiegroup.

the class DMNExternalLinksToExtensionElementsTest method testLoadExternalLinksFromExtensionElements.

@Test
public void testLoadExternalLinksFromExtensionElements() {
    final org.kie.dmn.model.api.DRGElement source = mock(org.kie.dmn.model.api.DRGElement.class);
    final org.kie.workbench.common.dmn.api.definition.model.DRGElement target = mock(org.kie.workbench.common.dmn.api.definition.model.DRGElement.class);
    final DMNElement.ExtensionElements extensionElements = mock(DMNElement.ExtensionElements.class);
    final List<Object> externalLinks = new ArrayList<>();
    final String linkDescription1 = "l1";
    final String url1 = "url1";
    final ExternalLink external1 = createExternalLinkMock(linkDescription1, url1);
    externalLinks.add(external1);
    final String linkDescription2 = "l2";
    final String url2 = "url2";
    final ExternalLink external2 = createExternalLinkMock(linkDescription2, url2);
    externalLinks.add(external2);
    when(extensionElements.getAny()).thenReturn(externalLinks);
    when(source.getExtensionElements()).thenReturn(extensionElements);
    final DocumentationLinksHolder linksHolder = mock(DocumentationLinksHolder.class);
    final DocumentationLinks links = new DocumentationLinks();
    when(linksHolder.getValue()).thenReturn(links);
    when(target.getLinksHolder()).thenReturn(linksHolder);
    loadExternalLinksFromExtensionElements(source, target);
    assertEquals(2, links.getLinks().size());
    compare(links.getLinks().get(0), linkDescription1, url1);
    compare(links.getLinks().get(1), linkDescription2, url2);
}
Also used : ArrayList(java.util.ArrayList) DocumentationLinksHolder(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder) ExternalLink(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ExternalLink) DocumentationLinks(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks) DMNElement(org.kie.dmn.model.api.DMNElement) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Example 4 with DocumentationLinks

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks in project kie-wb-common by kiegroup.

the class DocumentationLinksWidgetTest method testOnExternalLinkDeleted.

@Test
public void testOnExternalLinkDeleted() {
    final DocumentationLinks value = mock(DocumentationLinks.class);
    final DMNExternalLink externalLink = mock(DMNExternalLink.class);
    final List<DMNExternalLink> links = new ArrayList<>();
    links.add(externalLink);
    when(value.getLinks()).thenReturn(links);
    widget.setValue(value);
    widget.onExternalLinkDeleted(externalLink);
    assertFalse(links.contains(externalLink));
    verify(widget).refresh();
    verify(locker).fire(any());
}
Also used : DocumentationLinks(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks) ArrayList(java.util.ArrayList) DMNExternalLink(org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink) Test(org.junit.Test)

Example 5 with DocumentationLinks

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks in project kie-wb-common by kiegroup.

the class DocumentationLinksWidgetTest method testSetDMNModel.

@Test
public void testSetDMNModel() {
    final DocumentationLinksHolder holder = mock(DocumentationLinksHolder.class);
    final DocumentationLinks value = mock(DocumentationLinks.class);
    when(holder.getValue()).thenReturn(value);
    final DRGElement model = mock(DRGElement.class);
    when(model.getLinksHolder()).thenReturn(holder);
    widget.setDMNModel(model);
    verify(widget).setValue(value);
    verify(widget).refresh();
}
Also used : DocumentationLinks(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks) DocumentationLinksHolder(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

DocumentationLinks (org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks)9 Test (org.junit.Test)7 DMNExternalLink (org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink)6 ArrayList (java.util.ArrayList)5 DMNElement (org.kie.dmn.model.api.DMNElement)3 DocumentationLinksHolder (org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder)3 DRGElement (org.kie.dmn.model.api.DRGElement)2 ExternalLink (org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ExternalLink)2 HTMLElement (elemental2.dom.HTMLElement)1 TDMNElement (org.kie.dmn.model.v1_2.TDMNElement)1 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)1 JSITDMNElement (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElement)1 JSITAttachment (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.kie.JSITAttachment)1