Search in sources :

Example 31 with Definitions

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

the class ItemDefinitionUtilsTest method testFindByName.

@Test
public void testFindByName() {
    final String name = "item1";
    final ItemDefinition item1 = makeItem("item1");
    final ItemDefinition item2 = makeItem("item2");
    final Definitions definitions = mock(Definitions.class);
    final List<ItemDefinition> itemDefinitions = asList(item1, item2);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(definitions.getItemDefinition()).thenReturn(itemDefinitions);
    final Optional<ItemDefinition> actual = utils.findByName(name);
    final Optional<ItemDefinition> expected = Optional.of(item1);
    assertEquals(expected, actual);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) Test(org.junit.Test)

Example 32 with Definitions

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

the class ItemDefinitionUtilsTest method testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsNotPresent.

@Test
public void testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsNotPresent() {
    final String namespaceURI = FEEL.getUri();
    final Definitions definitions = mock(Definitions.class);
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(definitions.getPrefixForNamespaceURI(namespaceURI)).thenReturn(Optional.empty());
    final Optional<String> prefix = utils.getPrefixForNamespaceURI(namespaceURI);
    assertFalse(prefix.isPresent());
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Test(org.junit.Test)

Example 33 with Definitions

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

the class QNameConverterTest method testToWidgetValueWhenDMNDiagramDefinesNameSpaces.

@Test
public void testToWidgetValueWhenDMNDiagramDefinesNameSpaces() {
    final Definitions definitions = new Definitions();
    definitions.getNsContext().put(DMNModelInstrumentedBase.Namespace.FEEL.getPrefix(), DMNModelInstrumentedBase.Namespace.FEEL.getUri());
    final Decision decision = new Decision();
    decision.setParent(definitions);
    converter.setDMNModel(decision);
    final String encoding = converter.toWidgetValue(BuiltInType.DATE.asQName());
    assertEquals(ENCODED_FEEL_DATE, encoding);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 34 with Definitions

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

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

the class HrefBuilderTest method testGetHrefForImportedDRGElement.

@Test
public void testGetHrefForImportedDRGElement() {
    final DRGElement drgElement = mock(DRGElement.class);
    final Name drgElementName = mock(Name.class);
    final Name importName = mock(Name.class);
    final Id id = mock(Id.class);
    final Definitions definitions = mock(Definitions.class);
    final Import anImport = mock(Import.class);
    final List<Import> imports = singletonList(anImport);
    final String includedModelName = "includedModel";
    when(importName.getValue()).thenReturn(includedModelName);
    when(anImport.getName()).thenReturn(importName);
    when(anImport.getNamespace()).thenReturn("https://github.com/kiegroup/dmn/something");
    when(id.getValue()).thenReturn("0000-1111-2222");
    when(drgElementName.getValue()).thenReturn(includedModelName + ".Decision");
    when(drgElement.getId()).thenReturn(id);
    when(drgElement.getName()).thenReturn(drgElementName);
    when(drgElement.getParent()).thenReturn(definitions);
    when(definitions.getImport()).thenReturn(imports);
    final String actual = HrefBuilder.getHref(drgElement);
    final String expected = "https://github.com/kiegroup/dmn/something#0000-1111-2222";
    assertEquals(expected, actual);
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Aggregations

Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)70 Test (org.junit.Test)41 ItemDefinition (org.kie.workbench.common.dmn.api.definition.model.ItemDefinition)24 Node (org.kie.workbench.common.stunner.core.graph.Node)23 DMNDiagram (org.kie.workbench.common.dmn.api.definition.model.DMNDiagram)22 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)19 ArrayList (java.util.ArrayList)18 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)18 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)15 Import (org.kie.workbench.common.dmn.api.definition.model.Import)15 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 View (org.kie.workbench.common.stunner.core.graph.content.view.View)14 List (java.util.List)13 Objects (java.util.Objects)12 Optional (java.util.Optional)12 PMMLDocumentMetadata (org.kie.workbench.common.dmn.api.editors.included.PMMLDocumentMetadata)12 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)12 JSITDefinitions (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDefinitions)12 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 Map (java.util.Map)11