Search in sources :

Example 6 with DocumentationLinks

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

the class DocumentationLinksWidgetTest method testRefresh.

@Test
public void testRefresh() {
    final DocumentationLinks value = mock(DocumentationLinks.class);
    final DMNExternalLink externalLink = mock(DMNExternalLink.class);
    final List<DMNExternalLink> links = new ArrayList<>();
    links.add(externalLink);
    final DocumentationLinkItem listItem = mock(DocumentationLinkItem.class);
    final HTMLElement element = mock(HTMLElement.class);
    when(listItem.getElement()).thenReturn(element);
    when(listItems.get()).thenReturn(listItem);
    widget.setValue(value);
    when(value.getLinks()).thenReturn(links);
    widget.refresh();
    verify(listItem).init(externalLink);
    verify(linksContainer).appendChild(element);
    verify(widget).refreshContainersVisibility();
}
Also used : HTMLElement(elemental2.dom.HTMLElement) 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 7 with DocumentationLinks

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

the class DocumentationLinksWidgetTest method testOnDMNExternalLinkCreated.

@Test
public void testOnDMNExternalLinkCreated() {
    final DMNExternalLink createdLink = mock(DMNExternalLink.class);
    final DocumentationLinks value = mock(DocumentationLinks.class);
    widget.setValue(value);
    widget.onDMNExternalLinkCreated(createdLink);
    verify(value).addLink(createdLink);
    verify(locker).fire(any());
    verify(widget).refresh();
}
Also used : DocumentationLinks(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks) DMNExternalLink(org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink) Test(org.junit.Test)

Example 8 with DocumentationLinks

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

the class DocumentationLinksWidgetTest method testRefreshContainersVisibility.

@Test
public void testRefreshContainersVisibility() {
    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.refreshContainersVisibility();
    verify(noneContainerClassList).add(HiddenHelper.HIDDEN_CSS_CLASS);
    verify(linksContainerClassList).remove(HiddenHelper.HIDDEN_CSS_CLASS);
    links.clear();
    widget.refreshContainersVisibility();
    verify(noneContainerClassList).remove(HiddenHelper.HIDDEN_CSS_CLASS);
    verify(linksContainerClassList).add(HiddenHelper.HIDDEN_CSS_CLASS);
}
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 9 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 DRGElement source, final JSITDRGElement target) {
    if (Objects.isNull(source.getLinksHolder()) || Objects.isNull(source.getLinksHolder().getValue())) {
        return;
    }
    final DocumentationLinks links = source.getLinksHolder().getValue();
    final JSITDMNElement.JSIExtensionElements elements = getOrCreateExtensionElements(target);
    removeAllExistingLinks(elements);
    for (final DMNExternalLink link : links.getLinks()) {
        final JSITAttachment attachment = new JSITAttachment();
        attachment.setName(link.getDescription());
        attachment.setUrl(link.getUrl());
        final JSITAttachment wrappedAttachment = WrapperUtils.getWrappedJSITAttachment(attachment);
        elements.addAny(wrappedAttachment);
    }
    target.setExtensionElements(elements);
}
Also used : JSITDMNElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElement) JSITAttachment(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.kie.JSITAttachment) DocumentationLinks(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks) DMNExternalLink(org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink)

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