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();
}
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();
}
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);
}
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);
}
Aggregations