use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class DMNMarshallerStandaloneTest method testGetDmnElementRefWithFakeNamespace.
@Test
public void testGetDmnElementRefWithFakeNamespace() {
final Decision drgElement = mock(Decision.class);
final View<? extends DMNElement> view = new ViewImpl<>(drgElement, null);
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 String actual = getDmnElementRef(definitions, view).getLocalPart();
final String expected = "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 BaseLiteralExpressionPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final org.kie.workbench.common.dmn.api.definition.model.ImportedValues importedValues = new org.kie.workbench.common.dmn.api.definition.model.ImportedValues();
importedValues.setImportedElement(IMPORTED_ELEMENT);
final org.kie.workbench.common.dmn.api.definition.model.LiteralExpression wb = new org.kie.workbench.common.dmn.api.definition.model.LiteralExpression(new Id(UUID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new Text(TEXT), importedValues, new ExpressionLanguage(EXPRESSION_LANGUAGE));
final LiteralExpression dmn = LiteralExpressionPropertyConverter.dmnFromWB(wb);
assertThat(dmn.getId()).isEqualTo(UUID);
assertThat(dmn.getDescription()).isEqualTo(DESCRIPTION);
assertThat(dmn.getTypeRef().getNamespaceURI()).isEmpty();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(BuiltInType.BOOLEAN.getName());
assertThat(dmn.getText()).isEqualTo(TEXT);
assertThat(dmn.getImportedValues()).isNotNull();
assertThat(dmn.getImportedValues().getImportedElement()).isEqualTo(IMPORTED_ELEMENT);
assertThat(dmn.getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);
}
use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class InformationItemPrimaryPropertyConverterTest method testDmnFromWBWhenWBIsNotNull.
@Test
public void testDmnFromWBWhenWBIsNotNull() {
final String expectedId = "id";
final String expectedName = "name";
final Id id = new Id(expectedId);
final Name name = new Name(expectedName);
final String qNameNamespaceURI = "qName namespaceURI";
final String qNameLocalPart = "qName local part";
final String qNamePrefix = "qName prefix";
final InformationItemPrimary wb = mock(InformationItemPrimary.class);
final QName qName = mock(QName.class);
final javax.xml.namespace.QName expectedQName = new javax.xml.namespace.QName(qNameNamespaceURI, qNameLocalPart, qNamePrefix);
final NamedElement parentElement = mock(NamedElement.class);
when(wb.getId()).thenReturn(id);
when(wb.getName()).thenReturn(name);
when(wb.getTypeRef()).thenReturn(qName);
when(wb.getParent()).thenReturn(parentElement);
when(parentElement.getName()).thenReturn(name);
when(qName.getNamespaceURI()).thenReturn(qNameNamespaceURI);
when(qName.getLocalPart()).thenReturn(qNameLocalPart);
when(qName.getPrefix()).thenReturn(qNamePrefix);
final TInformationItem informationItem = InformationItemPrimaryPropertyConverter.dmnFromWB(wb, wb);
final String actualId = informationItem.getId();
final String actualName = informationItem.getName();
final javax.xml.namespace.QName actualQName = informationItem.getTypeRef();
assertEquals(expectedId, actualId);
assertEquals(expectedName, actualName);
assertEquals(expectedQName, actualQName);
}
use of org.kie.workbench.common.dmn.api.property.dmn.Id in project kie-wb-common by kiegroup.
the class InformationItemPrimaryPropertyConverterTest method testWbFromDMNWhenDMNIsNotNull.
@Test
public void testWbFromDMNWhenDMNIsNotNull() {
final String id = "id";
final Id expectedId = new Id(id);
final String qNameNamespaceURI = "qName namespaceURI";
final String qNameLocalPart = "qName local part";
final String qNamePrefix = "qName prefix";
final QName expectedTypeRef = new QName(qNameNamespaceURI, qNameLocalPart, qNamePrefix);
final javax.xml.namespace.QName qName = mock(javax.xml.namespace.QName.class);
final org.kie.dmn.model.api.InformationItem dmn = mock(org.kie.dmn.model.api.InformationItem.class);
when(dmn.getId()).thenReturn(id);
when(dmn.getTypeRef()).thenReturn(qName);
when(qName.getNamespaceURI()).thenReturn(qNameNamespaceURI);
when(qName.getLocalPart()).thenReturn(qNameLocalPart);
when(qName.getPrefix()).thenReturn(qNamePrefix);
final InformationItemPrimary informationItemPrimary = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn, dmn);
final Id actualId = informationItemPrimary.getId();
final QName actualTypeRef = informationItemPrimary.getTypeRef();
assertEquals(expectedId, actualId);
assertEquals(expectedTypeRef, actualTypeRef);
}
use of org.kie.workbench.common.dmn.api.property.dmn.Id 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);
}
Aggregations