Search in sources :

Example 66 with InputData

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

the class DecisionTableEditorDefinitionEnricherTest method setupGraphWithInputData.

@SuppressWarnings("unchecked")
private void setupGraphWithInputData() {
    Node<Definition, Edge> targetNode = graph.getNode(NODE_UUID);
    if (Objects.isNull(targetNode)) {
        targetNode = new NodeImpl<>(NODE_UUID);
        graph.addNode(targetNode);
    }
    final Node<Definition, Edge> sourceNode1 = new NodeImpl<>(UUID.uuid());
    final Node<Definition, Edge> sourceNode2 = new NodeImpl<>(UUID.uuid());
    inputData1.getName().setValue(INPUT_DATA_NAME_1);
    inputData2.getName().setValue(INPUT_DATA_NAME_2);
    final QName inputData1QName = new QName(QName.NULL_NS_URI, STRING.getName());
    final QName inputData2QName = new QName(QName.NULL_NS_URI, NUMBER.getName());
    inputData1.getVariable().setTypeRef(inputData1QName);
    inputData2.getVariable().setTypeRef(inputData2QName);
    final Definition<InputData> sourceNode1Definition = new DefinitionImpl<>(inputData1);
    final Definition<InputData> sourceNode2Definition = new DefinitionImpl<>(inputData2);
    sourceNode1.setContent(sourceNode1Definition);
    sourceNode2.setContent(sourceNode2Definition);
    final Edge edge1 = new EdgeImpl<>(UUID.uuid());
    final Edge edge2 = new EdgeImpl<>(UUID.uuid());
    edge1.setTargetNode(targetNode);
    edge1.setSourceNode(sourceNode1);
    edge2.setTargetNode(targetNode);
    edge2.setSourceNode(sourceNode2);
    targetNode.getInEdges().add(edge1);
    targetNode.getInEdges().add(edge2);
    sourceNode1.getOutEdges().add(edge1);
    sourceNode2.getOutEdges().add(edge2);
    graph.addNode(sourceNode1);
    graph.addNode(sourceNode2);
}
Also used : DefinitionImpl(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionImpl) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Example 67 with InputData

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

the class DMNIncludedModelHandlerTest method testUpdate.

@Test
public void testUpdate() {
    final Decision drgElement1 = makeDecision("model1.tUUID", "string", true);
    final Decision drgElement2 = makeDecision("model1.imported person", "model1.tPerson", true);
    final InputData drgElement3 = makeInputData("local person", "model1.tPerson", false);
    final InputData drgElement4 = makeInputData("regular DRG Element", "boolean", false);
    setId(drgElement2, "model1.uuid");
    final List<DRGElement> drgElements = asList(drgElement1, drgElement2, drgElement3, drgElement4);
    doNothing().when(handler).updateDRGElementName(any(), Mockito.<String>any());
    when(dmnGraphUtils.getModelDRGElements()).thenReturn(drgElements);
    handler.update("model1", "model2");
    verify(handler).updateDRGElementName(drgElement1, "model2.tUUID");
    verify(handler).updateDRGElementName(drgElement2, "model2.imported person");
    assertEquals("string", drgElement1.getVariable().getTypeRef().getLocalPart());
    assertEquals("model2.uuid", drgElement2.getId().getValue());
    assertEquals("model2.tPerson", drgElement2.getVariable().getTypeRef().getLocalPart());
    assertEquals("model2.tPerson", drgElement3.getVariable().getTypeRef().getLocalPart());
    assertEquals("boolean", drgElement4.getVariable().getTypeRef().getLocalPart());
}
Also used : InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Test(org.junit.Test)

Aggregations

InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)67 Test (org.junit.Test)42 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)37 View (org.kie.workbench.common.stunner.core.graph.content.view.View)26 Node (org.kie.workbench.common.stunner.core.graph.Node)22 Edge (org.kie.workbench.common.stunner.core.graph.Edge)21 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)17 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)17 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)15 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)13 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)12 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)11 Optional (java.util.Optional)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)8 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)8 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)7