Search in sources :

Example 1 with DRGElement

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

the class DMNMarshallerStandaloneTest method testIsImportedDRGElementWithDmnDRGElement.

@Test
public void testIsImportedDRGElementWithDmnDRGElement() {
    final DMNMarshallerStandalone marshaller = spy(getDMNMarshaller());
    final List<org.kie.dmn.model.api.DRGElement> importedDrgElements = new ArrayList<>();
    final org.kie.dmn.model.api.DRGElement imported = mock(org.kie.dmn.model.api.DRGElement.class);
    when(imported.getId()).thenReturn("id");
    importedDrgElements.add(imported);
    final org.kie.dmn.model.api.DRGElement drgElement = mock(org.kie.dmn.model.api.DRGElement.class);
    when(drgElement.getId()).thenReturn("id");
    final boolean actual = marshaller.isImportedDRGElement(importedDrgElements, drgElement);
    assertTrue(actual);
}
Also used : ArrayList(java.util.ArrayList) DRGElement(org.kie.dmn.model.api.DRGElement) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Example 2 with DRGElement

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

the class DMNMarshallerStandaloneTest method createDRGElementWithNamespaceAndId.

private org.kie.dmn.model.api.DRGElement createDRGElementWithNamespaceAndId(final String namespace, final String id) {
    final org.kie.dmn.model.api.DRGElement drgElement = mock(DRGElement.class);
    final Map<QName, String> additionalAttributes = new HashMap<>();
    additionalAttributes.put(new QName("Namespace"), namespace);
    when(drgElement.getAdditionalAttributes()).thenReturn(additionalAttributes);
    when(drgElement.getId()).thenReturn(id);
    return drgElement;
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) DRGElement(org.kie.dmn.model.api.DRGElement)

Example 3 with DRGElement

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

the class DMNMarshallerStandaloneTest method testRemoveDrgElementsWithoutShapeFromDMN11.

@Test
public void testRemoveDrgElementsWithoutShapeFromDMN11() {
    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 List<DMNShape> dmnShapes = new ArrayList<>();
    getDMNMarshaller().removeDrgElementsWithoutShape(drgElements, dmnShapes);
    assertEquals(3, drgElements.size());
    assertEquals(e1, drgElements.get(0));
    assertEquals(e2, drgElements.get(1));
    assertEquals(e3, drgElements.get(2));
}
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)

Example 4 with DRGElement

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

the class DMNMarshallerStandaloneTest method createDRGElement.

private DRGElement createDRGElement(final String id) {
    final DRGElement element = mock(DRGElement.class);
    when(element.getId()).thenReturn(id);
    return element;
}
Also used : DRGElement(org.kie.dmn.model.api.DRGElement)

Example 5 with DRGElement

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

the class DMNExternalLinksToExtensionElementsTest method testGetOrCreateExtensionElements.

@Test
public void testGetOrCreateExtensionElements() {
    final DRGElement element = mock(DRGElement.class);
    final DMNElement.ExtensionElements result = getOrCreateExtensionElements(element);
    assertNotNull(result);
    final DMNElement.ExtensionElements existingElements = mock(DMNElement.ExtensionElements.class);
    when(element.getExtensionElements()).thenReturn(existingElements);
    final DMNElement.ExtensionElements actual = getOrCreateExtensionElements(element);
    assertEquals(actual, existingElements);
}
Also used : DMNElement(org.kie.dmn.model.api.DMNElement) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Aggregations

DRGElement (org.kie.dmn.model.api.DRGElement)25 Definitions (org.kie.dmn.model.api.Definitions)15 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)8 Artifact (org.kie.dmn.model.api.Artifact)7 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)7 Decision (org.kie.dmn.model.api.Decision)7 Import (org.kie.dmn.model.api.Import)7 BusinessKnowledgeModel (org.kie.dmn.model.api.BusinessKnowledgeModel)6 InputData (org.kie.dmn.model.api.InputData)6 DMNModel (org.kie.dmn.api.core.DMNModel)4 Association (org.kie.dmn.model.api.Association)4 DecisionService (org.kie.dmn.model.api.DecisionService)4 ElementCollection (org.kie.dmn.model.api.ElementCollection)4 KnowledgeSource (org.kie.dmn.model.api.KnowledgeSource)4 OrganizationUnit (org.kie.dmn.model.api.OrganizationUnit)4 PerformanceIndicator (org.kie.dmn.model.api.PerformanceIndicator)4 TextAnnotation (org.kie.dmn.model.api.TextAnnotation)4 DMNShape (org.kie.dmn.model.api.dmndi.DMNShape)4