Search in sources :

Example 6 with NamedElement

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

the class NodeTextSetterTest method testGetName.

@Test
public void testGetName() {
    final NamedElement named = mock(NamedElement.class);
    final Node node = mock(Node.class);
    final Name name = mock(Name.class);
    final String nodeName = "node name";
    when(name.getValue()).thenReturn(nodeName);
    when(named.getName()).thenReturn(name);
    doReturn(Optional.of(named)).when(nodeTextSetter).getNamedElement(node);
    final String actualName = nodeTextSetter.getName(node);
    assertEquals(nodeName, actualName);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 7 with NamedElement

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

the class NodeTextSetterTest method testGetNamedElementWhenNamedIsNotPresent.

@Test
public void testGetNamedElementWhenNamedIsNotPresent() {
    final Node node = mock(Node.class);
    final View content = mock(View.class);
    final Object namedElement = mock(Object.class);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(namedElement);
    final Optional<NamedElement> actualNamed = nodeTextSetter.getNamedElement(node);
    assertFalse(actualNamed.isPresent());
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) View(org.kie.workbench.common.stunner.core.graph.content.view.View) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) Test(org.junit.Test)

Example 8 with NamedElement

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

the class NodeTextSetterTest method testGetNamedElementWhenViewIsNotPresent.

@Test
public void testGetNamedElementWhenViewIsNotPresent() {
    final Node node = mock(Node.class);
    final Object content = mock(Object.class);
    when(node.getContent()).thenReturn(content);
    final Optional<NamedElement> actualNamed = nodeTextSetter.getNamedElement(node);
    assertFalse(actualNamed.isPresent());
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) Test(org.junit.Test)

Example 9 with NamedElement

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

the class MonacoFEELSuggestions method getName.

private String getName(final Object definition) {
    final NamedElement namedElement = (NamedElement) definition;
    final Name name = namedElement.getName();
    return name.getValue();
}
Also used : NamedElement(org.kie.workbench.common.dmn.api.definition.model.NamedElement) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) BuiltInType.determineTypeFromName(org.kie.dmn.feel.lang.types.BuiltInType.determineTypeFromName)

Aggregations

NamedElement (org.kie.workbench.common.dmn.api.definition.model.NamedElement)9 Test (org.junit.Test)6 Node (org.kie.workbench.common.stunner.core.graph.Node)5 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 QName (javax.xml.namespace.QName)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)2 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)2 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)2 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)2 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)2 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)2 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)2 RectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2