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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations