Search in sources :

Example 56 with Definitions

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

the class HrefBuilderTest method testGetHrefForImportedDRGElementWhenImportHasAnOddName.

@Test
public void testGetHrefForImportedDRGElementWhenImportHasAnOddName() {
    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 = "d.i.v.i.";
    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)

Example 57 with Definitions

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

the class HrefBuilderTest method testGetHref.

@Test
public void testGetHref() {
    final DRGElement drgElement = mock(DRGElement.class);
    final Name name = mock(Name.class);
    final Id id = mock(Id.class);
    final Definitions definitions = mock(Definitions.class);
    final String uuid = "0000-1111-2222";
    when(id.getValue()).thenReturn(uuid);
    when(name.getValue()).thenReturn("Decision");
    when(drgElement.getId()).thenReturn(id);
    when(drgElement.getName()).thenReturn(name);
    when(drgElement.getParent()).thenReturn(definitions);
    when(definitions.getImport()).thenReturn(Collections.emptyList());
    final String actual = HrefBuilder.getHref(drgElement);
    final String expected = "#" + uuid;
    assertEquals(expected, actual);
}
Also used : 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)

Example 58 with Definitions

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

the class IncludedModelsPageStateProviderImplTest method testGetImportsWhenDiagramIsPresent.

@Test
public void testGetImportsWhenDiagramIsPresent() {
    final Definitions definitions = mock(Definitions.class);
    final List<Import> expectedImports = asList(mock(Import.class), mock(Import.class));
    when(dmnGraphUtils.getDefinitions(diagram)).thenReturn(definitions);
    when(definitions.getImport()).thenReturn(expectedImports);
    final List<Import> actualImports = stateProvider.getImports();
    assertEquals(expectedImports, actualImports);
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Test(org.junit.Test)

Example 59 with Definitions

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

the class ItemDefinitionUtilsTest method testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsPresent.

@Test
public void testGetPrefixForNamespaceURIWhenPrefixForNamespaceURIIsPresent() {
    final String namespaceURI = FEEL.getUri();
    final Definitions definitions = mock(Definitions.class);
    final Optional<String> expectedPrefix = Optional.of("prefix");
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(definitions.getPrefixForNamespaceURI(namespaceURI)).thenReturn(expectedPrefix);
    final Optional<String> actualPrefix = utils.getPrefixForNamespaceURI(namespaceURI);
    assertEquals(expectedPrefix, actualPrefix);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) Test(org.junit.Test)

Example 60 with Definitions

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

the class ItemDefinitionUtilsTest method testAddItemDefinitions.

@Test
public void testAddItemDefinitions() {
    final Definitions definitions = mock(Definitions.class);
    final ItemDefinition itemDefinition1 = mock(ItemDefinition.class);
    final ItemDefinition itemDefinition2 = mock(ItemDefinition.class);
    final ItemDefinition itemDefinition3 = mock(ItemDefinition.class);
    final ItemDefinition itemDefinition4 = mock(ItemDefinition.class);
    final List<ItemDefinition> newItemDefinitions = asList(itemDefinition1, itemDefinition3);
    final List<ItemDefinition> expectedItemDefinitions = asList(itemDefinition2, itemDefinition4, itemDefinition1, itemDefinition3);
    final List<ItemDefinition> actualItemDefinitions = new ArrayList<>(asList(itemDefinition2, itemDefinition4));
    when(dmnGraphUtils.getModelDefinitions()).thenReturn(definitions);
    when(definitions.getItemDefinition()).thenReturn(actualItemDefinitions);
    utils.addItemDefinitions(newItemDefinitions);
    assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
Also used : Definitions(org.kie.workbench.common.dmn.api.definition.model.Definitions) ItemDefinition(org.kie.workbench.common.dmn.api.definition.model.ItemDefinition) ArrayList(java.util.ArrayList) 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