Search in sources :

Example 11 with KnowledgeSource

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

the class DMNMarshallerStandalone method ddExtAugmentStunner.

private void ddExtAugmentStunner(final Optional<org.kie.dmn.model.api.dmndi.DMNDiagram> dmnDDDiagram, Node currentNode) {
    if (!dmnDDDiagram.isPresent()) {
        return;
    }
    final Stream<DMNShape> drgShapeStream = dmnDDDiagram.get().getDMNDiagramElement().stream().filter(DMNShape.class::isInstance).map(DMNShape.class::cast);
    final View content = (View) currentNode.getContent();
    final Bound ulBound = upperLeftBound(content);
    final Bound lrBound = lowerRightBound(content);
    if (content.getDefinition() instanceof Decision) {
        final Decision d = (Decision) content.getDefinition();
        internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
    } else if (content.getDefinition() instanceof InputData) {
        final InputData d = (InputData) content.getDefinition();
        internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
    } else if (content.getDefinition() instanceof BusinessKnowledgeModel) {
        final BusinessKnowledgeModel d = (BusinessKnowledgeModel) content.getDefinition();
        internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
    } else if (content.getDefinition() instanceof KnowledgeSource) {
        final KnowledgeSource d = (KnowledgeSource) content.getDefinition();
        internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
    } else if (content.getDefinition() instanceof TextAnnotation) {
        final TextAnnotation d = (TextAnnotation) content.getDefinition();
        internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet());
    } else if (content.getDefinition() instanceof DecisionService) {
        final DecisionService d = (DecisionService) content.getDefinition();
        internalAugment(drgShapeStream, d.getId(), ulBound, d.getDimensionsSet(), lrBound, d.getStylingSet(), dividerLineY -> d.setDividerLineY(new DecisionServiceDividerLineY(dividerLineY - ulBound.getY())));
    }
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) Edge(org.kie.workbench.common.stunner.core.graph.Edge) PointUtils.yOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.yOfBound) PointUtils.xOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.xOfBound) DoubleConsumer(java.util.function.DoubleConsumer) Bounds(org.kie.dmn.model.api.dmndi.Bounds) Map(java.util.Map) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) Point2D(org.kie.workbench.common.stunner.core.graph.content.view.Point2D) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) Set(java.util.Set) BusinessKnowledgeModelConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.BusinessKnowledgeModelConverter) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) PointUtils.heightOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.heightOfShape) Stream(java.util.stream.Stream) PointUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils) QName(javax.xml.namespace.QName) PointUtils.widthOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.widthOfShape) DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) PointUtils.yOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.yOfShape) DMNDefinitionSet(org.kie.workbench.common.dmn.api.DMNDefinitionSet) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle) Point(org.kie.dmn.model.api.dmndi.Point) Connection(org.kie.workbench.common.stunner.core.graph.content.view.Connection) Color(org.kie.dmn.model.api.dmndi.Color) ItemDefinitionPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.ItemDefinitionPropertyConverter) DiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMetadataMarshaller) ArrayList(java.util.ArrayList) FontSetPropertyConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.FontSetPropertyConverter) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) PointUtils.upperLeftBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.upperLeftBound) BiConsumer(java.util.function.BiConsumer) StreamSupport(java.util.stream.StreamSupport) BindableAdapterUtils(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils) IOException(java.io.IOException) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) InputStreamReader(java.io.InputStreamReader) InputDataConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.InputDataConverter) Association(org.kie.workbench.common.dmn.api.definition.model.Association) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) KnowledgeSourceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.KnowledgeSourceConverter) Graph(org.kie.workbench.common.stunner.core.graph.Graph) MagnetConnection(org.kie.workbench.common.stunner.core.graph.content.view.MagnetConnection) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) DecisionConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionConverter) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) DMNDecisionServiceDividerLine(org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine) DMNEdge(org.kie.dmn.model.api.dmndi.DMNEdge) UUID(org.kie.workbench.common.stunner.core.util.UUID) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) TextAnnotationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.TextAnnotationConverter) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Collectors.toMap(java.util.stream.Collectors.toMap) PointUtils.lowerRightBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.lowerRightBound) InformationRequirement(org.kie.workbench.common.dmn.api.definition.model.InformationRequirement) DiagramElement(org.kie.dmn.model.v1_2.dmndi.DiagramElement) Collections.emptyList(java.util.Collections.emptyList) DiagramMarshaller(org.kie.workbench.common.stunner.core.definition.service.DiagramMarshaller) Import(org.kie.dmn.model.api.Import) DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) Collectors(java.util.stream.Collectors) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Objects(java.util.Objects) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) List(java.util.List) DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) DMNDI(org.kie.dmn.model.v1_2.dmndi.DMNDI) Entry(java.util.Map.Entry) Optional(java.util.Optional) ApplicationScoped(javax.enterprise.context.ApplicationScoped) Node(org.kie.workbench.common.stunner.core.graph.Node) PointUtils.xOfShape(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.xOfShape) PMMLDocumentMetadata(org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) DefinitionsConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DefinitionsConverter) HashMap(java.util.HashMap) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ColorUtils(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ColorUtils) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ComponentsWidthsExtension(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentsWidthsExtension) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) KnowledgeRequirement(org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) DMNViewDefinition(org.kie.workbench.common.dmn.api.definition.DMNViewDefinition) SimpleEntry(java.util.AbstractMap.SimpleEntry) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) XMLEncoderDiagramMetadataMarshaller(org.kie.workbench.common.stunner.core.backend.service.XMLEncoderDiagramMetadataMarshaller) AssociationConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.AssociationConverter) DMNMarshallerImportsHelperStandalone(org.kie.workbench.common.dmn.backend.common.DMNMarshallerImportsHelperStandalone) DecisionServiceConverter(org.kie.workbench.common.dmn.backend.definition.v1_1.DecisionServiceConverter) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) AuthorityRequirement(org.kie.workbench.common.dmn.api.definition.model.AuthorityRequirement) Consumer(java.util.function.Consumer) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DiscreteConnection(org.kie.workbench.common.stunner.core.graph.content.view.DiscreteConnection) InputStream(java.io.InputStream) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) PointUtils.yOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.yOfBound) PointUtils.xOfBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.xOfBound) PointUtils.upperLeftBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.upperLeftBound) PointUtils.lowerRightBound(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.PointUtils.lowerRightBound) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService)

Example 12 with KnowledgeSource

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

the class DecisionConverter method dmnFromNode.

@Override
public org.kie.dmn.model.api.Decision dmnFromNode(final Node<View<Decision>, ?> node, final Consumer<ComponentWidths> componentWidthsConsumer) {
    final Decision source = (Decision) DefinitionUtils.getElementDefinition(node);
    final org.kie.dmn.model.api.Decision d = new org.kie.dmn.model.v1_2.TDecision();
    d.setId(source.getId().getValue());
    d.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription()));
    d.setName(source.getName().getValue());
    final org.kie.dmn.model.api.InformationItem variable = InformationItemPrimaryPropertyConverter.dmnFromWB(source.getVariable(), source);
    if (variable != null) {
        variable.setParent(d);
    }
    d.setVariable(variable);
    final org.kie.dmn.model.api.Expression expression = ExpressionPropertyConverter.dmnFromWB(source.getExpression(), componentWidthsConsumer);
    if (expression != null) {
        expression.setParent(d);
    }
    d.setExpression(expression);
    d.setQuestion(QuestionPropertyConverter.dmnFromWB(source.getQuestion()));
    d.setAllowedAnswers(AllowedAnswersPropertyConverter.dmnFromWB(source.getAllowedAnswers()));
    // DMN spec table 2: Requirements connection rules
    final List<Edge<?, ?>> inEdges = (List<Edge<?, ?>>) node.getInEdges();
    for (Edge<?, ?> e : inEdges) {
        final Node<?, ?> sourceNode = e.getSourceNode();
        if (sourceNode.getContent() instanceof View<?>) {
            final View<?> view = (View<?>) sourceNode.getContent();
            if (view.getDefinition() instanceof DRGElement) {
                final DRGElement drgElement = (DRGElement) view.getDefinition();
                if (drgElement instanceof Decision) {
                    final org.kie.dmn.model.api.InformationRequirement iReq = new org.kie.dmn.model.v1_2.TInformationRequirement();
                    iReq.setId(e.getUUID());
                    final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                    ri.setHref(getHref(drgElement));
                    iReq.setRequiredDecision(ri);
                    d.getInformationRequirement().add(iReq);
                } else if (drgElement instanceof BusinessKnowledgeModel) {
                    final org.kie.dmn.model.api.KnowledgeRequirement iReq = new org.kie.dmn.model.v1_2.TKnowledgeRequirement();
                    iReq.setId(e.getUUID());
                    final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                    ri.setHref(getHref(drgElement));
                    iReq.setRequiredKnowledge(ri);
                    d.getKnowledgeRequirement().add(iReq);
                } else if (drgElement instanceof KnowledgeSource) {
                    final org.kie.dmn.model.api.AuthorityRequirement iReq = new org.kie.dmn.model.v1_2.TAuthorityRequirement();
                    iReq.setId(e.getUUID());
                    final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                    ri.setHref(getHref(drgElement));
                    iReq.setRequiredAuthority(ri);
                    d.getAuthorityRequirement().add(iReq);
                } else if (drgElement instanceof InputData) {
                    final org.kie.dmn.model.api.InformationRequirement iReq = new org.kie.dmn.model.v1_2.TInformationRequirement();
                    iReq.setId(e.getUUID());
                    final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                    ri.setHref(getHref(drgElement));
                    iReq.setRequiredInput(ri);
                    d.getInformationRequirement().add(iReq);
                } else if (drgElement instanceof DecisionService) {
                    if (e.getContent() instanceof Child) {
                    // Stunner relationship of this Decision be encapsulated by the DecisionService, not managed here.
                    } else if (e.getContent() instanceof View && ((View) e.getContent()).getDefinition() instanceof KnowledgeRequirement) {
                        final org.kie.dmn.model.api.KnowledgeRequirement iReq = new org.kie.dmn.model.v1_2.TKnowledgeRequirement();
                        iReq.setId(e.getUUID());
                        final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                        ri.setHref(getHref(drgElement));
                        iReq.setRequiredKnowledge(ri);
                        d.getKnowledgeRequirement().add(iReq);
                    } else {
                        throw new UnsupportedOperationException("wrong model definition.");
                    }
                } else {
                    throw new UnsupportedOperationException("wrong model definition.");
                }
            }
        }
    }
    DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, d);
    return d;
}
Also used : DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) List(java.util.List) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) KnowledgeRequirement(org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) Edge(org.kie.workbench.common.stunner.core.graph.Edge) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Example 13 with KnowledgeSource

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

the class KnowledgeSourceConverter method nodeFromDMN.

@Override
public Node<View<KnowledgeSource>, ?> nodeFromDMN(final org.kie.dmn.model.api.KnowledgeSource dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    @SuppressWarnings("unchecked") final Node<View<KnowledgeSource>, ?> node = (Node<View<KnowledgeSource>, ?>) factoryManager.newElement(dmn.getId(), getDefinitionId(KnowledgeSource.class)).asNode();
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final KnowledgeSourceType ksType = new KnowledgeSourceType(dmn.getType());
    final LocationURI locationURI = new LocationURI(dmn.getLocationURI());
    final KnowledgeSource ks = new KnowledgeSource(id, description, name, ksType, locationURI, new StylingSet(), new GeneralRectangleDimensionsSet());
    node.getContent().setDefinition(ks);
    DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, ks);
    return node;
}
Also used : LocationURI(org.kie.workbench.common.dmn.api.property.dmn.LocationURI) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) KnowledgeSourceType(org.kie.workbench.common.dmn.api.property.dmn.KnowledgeSourceType) Node(org.kie.workbench.common.stunner.core.graph.Node) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) GeneralRectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) BindableAdapterUtils.getDefinitionId(org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 14 with KnowledgeSource

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

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

the class DecisionNavigatorItemsProviderTest method testGetItems.

@Test
public void testGetItems() {
    final Diagram stunnerDiagram1 = mock(Diagram.class);
    final Diagram stunnerDiagram2 = mock(Diagram.class);
    final DMNDiagramElement dmnDiagramElement1 = mock(DMNDiagramElement.class);
    final DMNDiagramElement dmnDiagramElement2 = mock(DMNDiagramElement.class);
    final DMNDiagramTuple dmnDiagramTuple1 = new DMNDiagramTuple(stunnerDiagram1, dmnDiagramElement1);
    final DMNDiagramTuple dmnDiagramTuple2 = new DMNDiagramTuple(stunnerDiagram2, dmnDiagramElement2);
    final DecisionNavigatorItem decisionNavigatorItem1 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem2 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem3 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem4 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem5 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem6 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem7 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem8 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem9 = mock(DecisionNavigatorItem.class);
    final DecisionNavigatorItem decisionNavigatorItem10 = mock(DecisionNavigatorItem.class);
    final List<DMNDiagramTuple> diagramTuples = asList(dmnDiagramTuple1, dmnDiagramTuple2);
    final Node node1 = mockNode(new Decision());
    final Node node2 = mockNode(new InputData());
    final Node node3 = mockNode(new TextAnnotation());
    final Node node4 = mockNode(new BusinessKnowledgeModel());
    final Node node5 = mockNode(new KnowledgeSource());
    final Node node6 = mockNode(new TextAnnotation());
    final Stream<Node> stunnerNodes1 = Stream.of(node1, node2, node3);
    final Stream<Node> stunnerNodes2 = Stream.of(node4, node5, node6);
    when(dmnDiagramElement1.getName()).thenReturn(new Name("DRD"));
    when(dmnDiagramElement2.getName()).thenReturn(new Name("DRG"));
    when(dmnDiagramsSession.getDMNDiagrams()).thenReturn(diagramTuples);
    when(itemFactory.makeRoot(dmnDiagramTuple1)).thenReturn(decisionNavigatorItem1);
    when(itemFactory.makeRoot(dmnDiagramTuple2)).thenReturn(decisionNavigatorItem2);
    when(itemFactory.makeItem(node1)).thenReturn(decisionNavigatorItem5);
    when(itemFactory.makeItem(node2)).thenReturn(decisionNavigatorItem6);
    when(itemFactory.makeItem(node3)).thenReturn(decisionNavigatorItem7);
    when(itemFactory.makeItem(node4)).thenReturn(decisionNavigatorItem8);
    when(itemFactory.makeItem(node5)).thenReturn(decisionNavigatorItem9);
    when(itemFactory.makeItem(node6)).thenReturn(decisionNavigatorItem10);
    when(itemFactory.makeSeparator(DRG)).thenReturn(decisionNavigatorItem3);
    when(itemFactory.makeSeparator(DRDs)).thenReturn(decisionNavigatorItem4);
    when(dmnDiagramUtils.getNodeStream(stunnerDiagram1)).thenReturn(stunnerNodes1);
    when(dmnDiagramUtils.getNodeStream(stunnerDiagram2)).thenReturn(stunnerNodes2);
    final List<DecisionNavigatorItem> actualItems = itemsProvider.getItems();
    final List<DecisionNavigatorItem> expectedItems = asList(decisionNavigatorItem3, decisionNavigatorItem2, decisionNavigatorItem4, decisionNavigatorItem1);
    assertEquals(expectedItems, actualItems);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem5);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem6);
    verify(decisionNavigatorItem1).addChild(decisionNavigatorItem7);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem8);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem9);
    verify(decisionNavigatorItem2).addChild(decisionNavigatorItem10);
}
Also used : DMNDiagramTuple(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramTuple) Node(org.kie.workbench.common.stunner.core.graph.Node) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) DMNDiagramElement(org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Test(org.junit.Test)

Aggregations

KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)23 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)16 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)16 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)16 Test (org.junit.Test)11 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)11 View (org.kie.workbench.common.stunner.core.graph.content.view.View)10 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)9 List (java.util.List)8 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)8 Edge (org.kie.workbench.common.stunner.core.graph.Edge)7 ArrayList (java.util.ArrayList)5 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)5 Node (org.kie.workbench.common.stunner.core.graph.Node)5 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)4 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)4 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)3 KnowledgeSourceType (org.kie.workbench.common.dmn.api.property.dmn.KnowledgeSourceType)3 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)3