Search in sources :

Example 1 with DocumentationLinksHolder

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder 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 2 with DocumentationLinksHolder

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder 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 3 with DocumentationLinksHolder

use of org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder 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)

Example 4 with DocumentationLinksHolder

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

the class DMNElementsSynchronizerTest method testSynchronizeBaseDRGProperties.

@Test
public void testSynchronizeBaseDRGProperties() {
    final DRGElement from = mock(DRGElement.class);
    final DRGElement to = mock(DRGElement.class);
    final Description description = mock(Description.class);
    final DocumentationLinksHolder linksHolder = mock(DocumentationLinksHolder.class);
    final Name name = mock(Name.class);
    when(from.getDescription()).thenReturn(description);
    when(from.getLinksHolder()).thenReturn(linksHolder);
    when(from.getName()).thenReturn(name);
    synchronizer.synchronizeBaseDRGProperties(from, to);
    verify(to).setDescription(description);
    verify(to).setName(name);
    verify(to).setLinksHolder(linksHolder);
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) DocumentationLinksHolder(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 5 with DocumentationLinksHolder

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

the class DMNDocumentationDRDsFactoryTest method testCreate.

@Test
public void testCreate() {
    final String nodeUUID1 = "1111-1111-1111-1111";
    final String nodeUUID2 = "2222-2222-2222-2222";
    final Node<View, Edge> node1 = new NodeImpl<>(nodeUUID1);
    final Node<View, Edge> node2 = new NodeImpl<>(nodeUUID2);
    final View view1 = mock(View.class);
    final View view2 = mock(View.class);
    final HasExpression hasExpression1 = mock(HasExpression.class);
    final List<Node<View, Edge>> nodes = asList(node1, node2);
    final Decision drgElement1 = new Decision();
    final InputData drgElement2 = new InputData();
    final String name1 = "Decision-1";
    final String name2 = "Input-data-2";
    final String description1 = "Description...";
    final InformationItemPrimary variable1 = new InformationItemPrimary();
    final QName typeRef1 = BOOLEAN.asQName();
    final String image1 = "<image1>";
    final DMNExternalLink externalLink = new DMNExternalLink();
    final DocumentationLinksHolder linksHolder = new DocumentationLinksHolder();
    linksHolder.getValue().addLink(externalLink);
    drgElement2.setLinksHolder(linksHolder);
    node1.setContent(view1);
    node2.setContent(view2);
    when(view1.getDefinition()).thenReturn(drgElement1);
    when(view2.getDefinition()).thenReturn(drgElement2);
    when(expressionHelper.getOptionalHasExpression(node1)).thenReturn(Optional.ofNullable(hasExpression1));
    when(expressionHelper.getOptionalHasExpression(node2)).thenReturn(Optional.empty());
    when(expressionContainerGrid.getNodeUUID()).thenReturn(Optional.of(nodeUUID2));
    when(graph.nodes()).thenReturn(nodes);
    doReturn(image1).when(factory).getNodeImage(diagram, node1);
    doNothing().when(factory).setExpressionContainerGrid(any(), any());
    variable1.setTypeRef(typeRef1);
    drgElement1.setVariable(variable1);
    drgElement1.setDescription(new Description(description1));
    drgElement1.setName(new Name(name1));
    drgElement2.setName(new Name(name2));
    final List<DMNDocumentationDRD> drds = factory.create(diagram);
    final DMNDocumentationDRD documentationDRD1 = drds.get(0);
    final DMNDocumentationDRD documentationDRD2 = drds.get(1);
    assertEquals(2, drds.size());
    assertEquals(name1, documentationDRD1.getDrdName());
    assertEquals(BOOLEAN.getName(), documentationDRD1.getDrdType());
    assertEquals(description1, documentationDRD1.getDrdDescription());
    assertEquals(image1, documentationDRD1.getDrdBoxedExpressionImage());
    assertEquals(NONE, documentationDRD2.getDrdDescription());
    assertEquals(UNDEFINED.getName(), documentationDRD2.getDrdType());
    assertEquals(name2, documentationDRD2.getDrdName());
    assertEquals(NONE, documentationDRD2.getDrdBoxedExpressionImage());
    assertFalse(documentationDRD1.getHasExternalLinks());
    assertTrue(documentationDRD2.getHasExternalLinks());
    verify(factory).setExpressionContainerGrid(diagram, nodeUUID2);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Node(org.kie.workbench.common.stunner.core.graph.Node) DocumentationLinksHolder(org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder) ExpressionEditorView(org.kie.workbench.common.dmn.client.editors.expressions.ExpressionEditorView) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Edge(org.kie.workbench.common.stunner.core.graph.Edge) DMNExternalLink(org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 DocumentationLinksHolder (org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinksHolder)5 DocumentationLinks (org.kie.workbench.common.dmn.api.property.dmn.DocumentationLinks)3 ArrayList (java.util.ArrayList)2 DMNElement (org.kie.dmn.model.api.DMNElement)2 DRGElement (org.kie.dmn.model.api.DRGElement)2 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)1 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)1 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)1 DMNExternalLink (org.kie.workbench.common.dmn.api.property.dmn.DMNExternalLink)1 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)1 ExternalLink (org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ExternalLink)1 ExpressionEditorView (org.kie.workbench.common.dmn.client.editors.expressions.ExpressionEditorView)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1