Search in sources :

Example 61 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testMarshallEvaluationTwice.

@Test
public void testMarshallEvaluationTwice() throws Exception {
    Diagram diagram = unmarshall(BPMN_EVALUATION);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    Diagram diagram2 = unmarshall(BPMN_EVALUATION);
    String result2 = tested.marshall(diagram2);
    assertDiagram(result2, 1, 7, 7);
}
Also used : Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Assertions.assertDiagram(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.Assertions.assertDiagram) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Test(org.junit.Test)

Example 62 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class DMNGraphUtilsTest method testGetDefinitionsWithDiagram.

@Test
public void testGetDefinitionsWithDiagram() {
    final Definitions expectedDefinitions = mock(Definitions.class);
    final Diagram diagram = mock(Diagram.class);
    when(dmnDiagramUtils.getDefinitions(diagram)).thenReturn(expectedDefinitions);
    final Definitions actualDefinitions = utils.getDefinitions(diagram);
    assertNotNull(actualDefinitions);
    assertEquals(expectedDefinitions, actualDefinitions);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 63 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class ProjectDiagramServiceControllerTest method testGetDiagramByPathWhenStunnerSVGFileExists.

@Test
public void testGetDiagramByPathWhenStunnerSVGFileExists() throws IOException {
    final Path path = mockGetDiagramByPathObjects();
    final Path expectedSVGPath = prepareSVGFile(path, DIAGRAM_SVG);
    prepareLoadDiagramByPath(path);
    final Diagram result = diagramService.getDiagramByPath(path);
    assertEquals(diagram, result);
    verifyExpectedResult(path, result, expectedSVGPath, ProjectMetadata.SVGGenerator.STUNNER);
}
Also used : Path(org.uberfire.backend.vfs.Path) ProjectDiagram(org.kie.workbench.common.stunner.project.diagram.ProjectDiagram) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) AbstractVFSDiagramServiceTest(org.kie.workbench.common.stunner.core.backend.service.AbstractVFSDiagramServiceTest) Test(org.junit.Test)

Example 64 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class ProjectValidationServiceImplTest method setUp.

@Before
@SuppressWarnings("unchecked")
public void setUp() {
    domainViolationList = Arrays.asList(domainViolation, domainViolation2, domainViolation3, domainViolation4, domainViolationNull, domainViolationNullStr);
    domainValidator = new DomainValidator() {

        @Override
        public String getDefinitionSetId() {
            return DEF_SET_ID;
        }

        @Override
        public void validate(Diagram entity, Consumer<Collection<DomainViolation>> resultConsumer) {
            resultConsumer.accept(domainViolationList);
        }
    };
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getDefinitionSetId()).thenReturn(DEF_SET_ID);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.getUUID()).thenReturn(GRAPH_UUID);
    mockViolations(domainViolationList);
    validationService = new ProjectValidationServiceImpl(new MockInstanceImpl(domainValidator));
}
Also used : MockInstanceImpl(org.uberfire.mocks.MockInstanceImpl) Collection(java.util.Collection) DomainValidator(org.kie.workbench.common.stunner.core.validation.DomainValidator) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Before(org.junit.Before)

Example 65 with Diagram

use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.

the class CaseManagementDrawCommand method execute.

@Override
@SuppressWarnings("unchecked")
public CommandResult<CanvasViolation> execute(final AbstractCanvasHandler context) {
    final Diagram diagram = context.getDiagram();
    final String shapeSetId = context.getDiagram().getMetadata().getShapeSetId();
    childrenTraverseProcessor.traverse(diagram.getGraph(), new AbstractChildrenTraverseCallback<Node<View, Edge>, Edge<Child, Node>>() {

        @Override
        public void startNodeTraversal(final Node<View, Edge> node) {
            super.startNodeTraversal(node);
            addNode(node);
        }

        @Override
        public boolean startNodeTraversal(final List<Node<View, Edge>> parents, final Node<View, Edge> node) {
            super.startNodeTraversal(parents, node);
            addNode(node);
            context.addChild(parents.get(parents.size() - 1), node);
            return true;
        }

        private void addNode(final Node<View, Edge> node) {
            context.register(shapeSetId, node);
            context.applyElementMutation(node, MutationContext.STATIC);
        }

        @Override
        public void endGraphTraversal() {
            super.endGraphTraversal();
            context.getCanvas().draw();
        }
    });
    return buildResult();
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Edge(org.kie.workbench.common.stunner.core.graph.Edge) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Aggregations

Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)128 Test (org.junit.Test)64 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)48 Node (org.kie.workbench.common.stunner.core.graph.Node)38 Graph (org.kie.workbench.common.stunner.core.graph.Graph)31 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)24 View (org.kie.workbench.common.stunner.core.graph.content.view.View)23 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)22 ArrayList (java.util.ArrayList)20 List (java.util.List)20 Edge (org.kie.workbench.common.stunner.core.graph.Edge)20 Inject (javax.inject.Inject)15 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)15 Before (org.junit.Before)14 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)14 Map (java.util.Map)13 Optional (java.util.Optional)13 Collectors (java.util.stream.Collectors)13 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)13 Collection (java.util.Collection)12