Search in sources :

Example 81 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class WrapperUtilsTest method testGetDmnElementRefWithFakeNamespace.

@Test
public void testGetDmnElementRefWithFakeNamespace() {
    final Decision drgElement = mock(Decision.class);
    final View<? extends DMNElement> view = new ViewImpl<>(drgElement, null);
    final String defaultNamespace = "://default";
    final Name drgElementName = mock(Name.class);
    final Id id = mock(Id.class);
    final org.kie.workbench.common.dmn.api.definition.model.Definitions definitions = mock(org.kie.workbench.common.dmn.api.definition.model.Definitions.class);
    when(id.getValue()).thenReturn("0000-1111-2222");
    when(drgElementName.getValue()).thenReturn("fakeNamespace.Decision");
    when(drgElement.getId()).thenReturn(id);
    when(drgElement.getName()).thenReturn(drgElementName);
    when(drgElement.getParent()).thenReturn(definitions);
    when(definitions.getImport()).thenReturn(emptyList());
    final QName actual = getDmnElementRef(definitions, view, defaultNamespace);
    assertEquals(defaultNamespace, actual.getNamespaceURI());
    assertEquals("0000-1111-2222", actual.getLocalPart());
    assertEquals("", actual.getPrefix());
}
Also used : QName(javax.xml.namespace.QName) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 82 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class WrapperUtilsTest method testGetDmnElementRefWithoutNamespace.

@Test
public void testGetDmnElementRefWithoutNamespace() {
    final Decision drgElement = mock(Decision.class);
    final View<? extends DMNElement> view = new ViewImpl<>(drgElement, null);
    final String defaultNamespace = "://default";
    final Name drgElementName = mock(Name.class);
    final Id id = mock(Id.class);
    final org.kie.workbench.common.dmn.api.definition.model.Definitions definitions = mock(org.kie.workbench.common.dmn.api.definition.model.Definitions.class);
    when(id.getValue()).thenReturn("0000-1111-2222");
    when(drgElementName.getValue()).thenReturn("Decision");
    when(drgElement.getId()).thenReturn(id);
    when(drgElement.getName()).thenReturn(drgElementName);
    when(drgElement.getParent()).thenReturn(definitions);
    when(definitions.getImport()).thenReturn(emptyList());
    final QName actual = getDmnElementRef(definitions, view, defaultNamespace);
    assertEquals(defaultNamespace, actual.getNamespaceURI());
    assertEquals("0000-1111-2222", actual.getLocalPart());
    assertEquals("", actual.getPrefix());
}
Also used : QName(javax.xml.namespace.QName) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 83 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class WrapperUtilsTest method testGetDmnElementRefWithNamespace.

@Test
public void testGetDmnElementRefWithNamespace() {
    final Decision drgElement = mock(Decision.class);
    final View<? extends DMNElement> view = new ViewImpl<>(drgElement, null);
    final Name drgElementName = mock(Name.class);
    final Name importName = mock(Name.class);
    final Id id = mock(Id.class);
    final org.kie.workbench.common.dmn.api.definition.model.Definitions definitions = mock(org.kie.workbench.common.dmn.api.definition.model.Definitions.class);
    final Import anImport = mock(Import.class);
    final List<Import> imports = singletonList(anImport);
    final String includedModelName = "includedModel";
    final String defaultNamespace = "://default";
    final String namespaceName = "include1";
    final String importNamespace = "://namespace";
    final Map<String, String> nsContext = new HashMap<>();
    when(importName.getValue()).thenReturn(includedModelName);
    when(anImport.getName()).thenReturn(importName);
    when(anImport.getNamespace()).thenReturn(importNamespace);
    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);
    nsContext.put(namespaceName, importNamespace);
    when(definitions.getImport()).thenReturn(imports);
    when(definitions.getNsContext()).thenReturn(nsContext);
    final QName actual = getDmnElementRef(definitions, view, defaultNamespace);
    assertEquals(defaultNamespace, actual.getNamespaceURI());
    assertEquals("include1:0000-1111-2222", actual.getLocalPart());
    assertEquals("", actual.getPrefix());
}
Also used : Import(org.kie.workbench.common.dmn.api.definition.model.Import) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(javax.xml.namespace.QName) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) Test(org.junit.Test)

Example 84 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id 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)

Example 85 with Id

use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.

the class LiteralExpressionPropertyConverterTest method testDMNFromWB.

@Test
public void testDMNFromWB() {
    when(wb.getId()).thenReturn(new Id(UUID));
    when(wb.getDescription()).thenReturn(new Description(DESCRIPTION));
    when(wb.getTypeRef()).thenReturn(new QName(KIE.getUri(), TYPE_REF, KIE.getPrefix()));
    when(wb.getText()).thenReturn(new Text(TEXT));
    when(wb.getExpressionLanguage()).thenReturn(new ExpressionLanguage(EXPRESSION_LANGUAGE));
    final JSITLiteralExpression result = LiteralExpressionPropertyConverter.dmnFromWB(wb);
    verify(result).setId(UUID);
    verify(result).setDescription(DESCRIPTION);
    verify(result).setTypeRef("{" + KIE.getUri() + "}" + TYPE_REF);
    verify(result).setText(TEXT);
    verify(result).setExpressionLanguage(EXPRESSION_LANGUAGE);
}
Also used : JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Text(org.kie.workbench.common.dmn.api.property.dmn.Text) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) ExpressionLanguage(org.kie.workbench.common.dmn.api.property.dmn.ExpressionLanguage) Test(org.junit.Test)

Aggregations

Id (org.kie.workbench.common.dmn.api.property.dmn.Id)173 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)102 Test (org.junit.Test)78 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)74 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)59 Text (org.kie.workbench.common.dmn.api.property.dmn.Text)30 Node (org.kie.workbench.common.stunner.core.graph.Node)29 View (org.kie.workbench.common.stunner.core.graph.content.view.View)29 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)23 QName (javax.xml.namespace.QName)20 GeneralRectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.GeneralRectangleDimensionsSet)18 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)17 ArrayList (java.util.ArrayList)16 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)15 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)15 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)15 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)14 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)14 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)13 List (java.util.List)11