Search in sources :

Example 6 with DMNShape

use of org.kie.dmn.model.api.dmndi.DMNShape in project drools by kiegroup.

the class UnmarshalMarshalTest method test_FontSize_sharedStyle.

@Test
public void test_FontSize_sharedStyle() throws Exception {
    testRoundTripV12("org/kie/dmn/backend/marshalling/v1_2/", "test-FontSize-sharedStyle.dmn");
    Definitions definitions = MARSHALLER.unmarshal(new InputStreamReader(this.getClass().getResourceAsStream("test-FontSize-sharedStyle.dmn")));
    DMNShape shape0 = (DMNShape) definitions.getDMNDI().getDMNDiagram().get(0).getDMNDiagramElement().get(0);
    DMNStyle shape0sharedStyle = (DMNStyle) shape0.getDMNLabel().getSharedStyle();
    assertEquals("LS_4d396200-362f-4939-830d-32d2b4c87042_0", shape0sharedStyle.getId());
    assertEquals(21d, shape0sharedStyle.getFontSize(), 0.0d);
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) InputStreamReader(java.io.InputStreamReader) Definitions(org.kie.dmn.model.api.Definitions) DMNStyle(org.kie.dmn.model.api.dmndi.DMNStyle) Test(org.junit.Test)

Example 7 with DMNShape

use of org.kie.dmn.model.api.dmndi.DMNShape in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method testGetUniqueDMNShapes.

@Test
public void testGetUniqueDMNShapes() {
    final DMNMarshallerStandalone marshaller = spy(getDMNMarshaller());
    final org.kie.dmn.model.api.dmndi.DMNDiagram diagram = mock(org.kie.dmn.model.api.dmndi.DMNDiagram.class);
    final List<DiagramElement> elements = new ArrayList<>();
    final DMNShape unique1 = mock(DMNShape.class);
    when(unique1.getId()).thenReturn("unique1");
    final DMNShape unique2 = mock(DMNShape.class);
    when(unique2.getId()).thenReturn("unique2");
    final DMNShape duplicate1 = mock(DMNShape.class);
    when(duplicate1.getId()).thenReturn("duplicate");
    final DMNShape duplicate2 = mock(DMNShape.class);
    when(duplicate2.getId()).thenReturn("duplicate");
    elements.add(unique1);
    elements.add(unique2);
    elements.add(duplicate1);
    elements.add(duplicate2);
    when(diagram.getDMNDiagramElement()).thenReturn(elements);
    final List<DMNShape> actual = marshaller.getUniqueDMNShapes(diagram);
    assertEquals(3, actual.size());
    assertTrue(actual.contains(unique1));
    assertTrue(actual.contains(unique2));
    assertTrue(actual.contains(duplicate1) || actual.contains(duplicate2));
}
Also used : DiagramElement(org.kie.dmn.model.api.dmndi.DiagramElement) DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 8 with DMNShape

use of org.kie.dmn.model.api.dmndi.DMNShape in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method createDMNShape.

private DMNShape createDMNShape(final String refId) {
    final DMNShape shape = mock(DMNShape.class);
    final QName ref = mock(QName.class);
    when(shape.getDmnElementRef()).thenReturn(ref);
    when(ref.getLocalPart()).thenReturn(refId);
    return shape;
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) QName(javax.xml.namespace.QName)

Example 9 with DMNShape

use of org.kie.dmn.model.api.dmndi.DMNShape in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method testGetDmnElementRef.

@Test
public void testGetDmnElementRef() {
    final DMNMarshallerStandalone marshaller = spy(getDMNMarshaller());
    final String expected = "localPart";
    final DMNShape shape = mock(DMNShape.class);
    final javax.xml.namespace.QName ref = mock(javax.xml.namespace.QName.class);
    when(ref.getLocalPart()).thenReturn(expected);
    when(shape.getDmnElementRef()).thenReturn(ref);
    final String actual = marshaller.getDmnElementRef(shape);
    assertEquals(expected, actual);
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 10 with DMNShape

use of org.kie.dmn.model.api.dmndi.DMNShape in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method testRemoveDrgElementsWithoutShape.

@Test
public void testRemoveDrgElementsWithoutShape() {
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final DRGElement e1 = createDRGElement(id1);
    final DRGElement e2 = createDRGElement(id2);
    final DRGElement e3 = createDRGElement(id3);
    final List<org.kie.dmn.model.api.DRGElement> drgElements = new ArrayList<>(Arrays.asList(e1, e2, e3));
    final DMNShape s1 = createDMNShape(id1);
    final DMNShape s3 = createDMNShape(id3);
    final List<DMNShape> dmnShapes = new ArrayList<>(Arrays.asList(s1, s3));
    getDMNMarshaller().removeDrgElementsWithoutShape(drgElements, dmnShapes);
    assertEquals(2, drgElements.size());
    assertEquals(e1, drgElements.get(0));
    assertEquals(e3, drgElements.get(1));
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) ArrayList(java.util.ArrayList) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Aggregations

DMNShape (org.kie.dmn.model.api.dmndi.DMNShape)14 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 QName (javax.xml.namespace.QName)6 InputStreamReader (java.io.InputStreamReader)5 DMNStyle (org.kie.dmn.model.api.dmndi.DMNStyle)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 DMNMarshaller (org.kie.dmn.api.marshalling.DMNMarshaller)4 Definitions (org.kie.dmn.model.api.Definitions)4 Bounds (org.kie.dmn.model.api.dmndi.Bounds)4 DMNDecisionServiceDividerLine (org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine)4 Point (org.kie.dmn.model.api.dmndi.Point)4 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 SimpleEntry (java.util.AbstractMap.SimpleEntry)3 Collections.emptyList (java.util.Collections.emptyList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3