Search in sources :

Example 86 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DecisionServiceParametersListWidgetTest method testAddDecisionNodeToGroup.

@Test
public void testAddDecisionNodeToGroup() {
    final ParameterGroup group = mock(ParameterGroup.class);
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final Decision decision = mock(Decision.class);
    final InformationItemPrimary variable = mock(InformationItemPrimary.class);
    final String decisionName = "decision name";
    final String type = "type";
    final QName typeRef = mock(QName.class);
    when(definition.getDefinition()).thenReturn(decision);
    when(node.getContent()).thenReturn(definition);
    when(decision.getVariable()).thenReturn(variable);
    when(decision.getName()).thenReturn(new Name(decisionName));
    when(typeRef.getLocalPart()).thenReturn(type);
    when(variable.getTypeRef()).thenReturn(typeRef);
    widget.addDecisionNodeToGroup(group, node);
    verify(group).addParameter(decisionName, type);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ParameterGroup(org.kie.workbench.common.dmn.client.widgets.decisionservice.parameters.parametergroup.ParameterGroup) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) 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) Test(org.junit.Test)

Example 87 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class BaseNameAndDataTypeHeaderMetaDataTest method testGetTitleWithHasName.

@Test
public void testGetTitleWithHasName() {
    final Decision decision = new Decision();
    decision.setName(NAME);
    setup(Optional.of(decision));
    assertThat(metaData.getTitle()).isEqualTo(NAME.getValue());
}
Also used : Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 88 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DMNSVGShapeDefImplTest method testNewViewInstance.

@Test
public void testNewViewInstance() {
    final BusinessKnowledgeModel businessKnowledgeModel = new BusinessKnowledgeModel();
    shapeDef.newViewInstance(viewFactory, businessKnowledgeModel);
    verify(viewFactory).businessKnowledgeModel();
    verify(viewResource).build(businessKnowledgeModel.getDimensionsSet().getWidth().getValue(), businessKnowledgeModel.getDimensionsSet().getHeight().getValue(), true);
    reset(viewResource);
    final Decision decision = new Decision();
    shapeDef.newViewInstance(viewFactory, decision);
    verify(viewFactory).decision();
    verify(viewResource).build(decision.getDimensionsSet().getWidth().getValue(), decision.getDimensionsSet().getHeight().getValue(), true);
    reset(viewResource);
    shapeDef.newViewInstance(viewFactory, new InputData());
    verify(viewFactory).inputData();
    verify(viewResource).build(businessKnowledgeModel.getDimensionsSet().getWidth().getValue(), businessKnowledgeModel.getDimensionsSet().getHeight().getValue(), true);
    reset(viewResource);
    final KnowledgeSource knowledgeSource = new KnowledgeSource();
    shapeDef.newViewInstance(viewFactory, knowledgeSource);
    verify(viewFactory).knowledgeSource();
    verify(viewResource).build(knowledgeSource.getDimensionsSet().getWidth().getValue(), knowledgeSource.getDimensionsSet().getHeight().getValue(), true);
    reset(viewResource);
    final TextAnnotation textAnnotation = new TextAnnotation();
    shapeDef.newViewInstance(viewFactory, textAnnotation);
    verify(viewFactory).textAnnotation();
    verify(viewResource).build(textAnnotation.getDimensionsSet().getWidth().getValue(), textAnnotation.getDimensionsSet().getHeight().getValue(), true);
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 89 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.

the class DMNDocumentationDRDsFactoryTest method testSetExpressionContainerGrid.

@Test
public void testSetExpressionContainerGrid() {
    final String uuid = "0000-1111-2222-3333";
    final String name = "Decision-1";
    final Node<View, Edge> node = new NodeImpl<>(uuid);
    final Decision drgElement = new Decision();
    final HasExpression hasExpression = mock(HasExpression.class);
    final View view = mock(View.class);
    node.setContent(view);
    drgElement.setName(new Name(name));
    when(graph.nodes()).thenReturn(singletonList(node));
    when(view.getDefinition()).thenReturn(drgElement);
    when(expressionHelper.getHasExpression(node)).thenReturn(hasExpression);
    factory.setExpressionContainerGrid(diagram, uuid);
    verify(expressionContainerGrid).setExpression(uuid, hasExpression, Optional.of(drgElement), false);
    verify(factory).clearSelections(expressionContainerGrid);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ExpressionEditorView(org.kie.workbench.common.dmn.client.editors.expressions.ExpressionEditorView) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) 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) Test(org.junit.Test)

Example 90 with Decision

use of org.kie.workbench.common.dmn.api.definition.model.Decision 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

Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)121 Test (org.junit.Test)79 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)39 View (org.kie.workbench.common.stunner.core.graph.content.view.View)38 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)37 Node (org.kie.workbench.common.stunner.core.graph.Node)28 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)23 Edge (org.kie.workbench.common.stunner.core.graph.Edge)23 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)22 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)21 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)21 ViewImpl (org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl)20 List (java.util.List)16 TDecision (org.kie.dmn.model.v1_2.TDecision)16 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)16 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)16 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)16 ArrayList (java.util.ArrayList)15 Optional (java.util.Optional)15 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)15