Search in sources :

Example 21 with DMNModelInstrumentedBase

use of org.kie.dmn.model.api.DMNModelInstrumentedBase in project kie-wb-common by kiegroup.

the class DMNDIExtensionsRegisterTest method testBeforeMarshal.

@Test
public void testBeforeMarshal() {
    final DMNModelInstrumentedBase base = mock(TDefinitions.class);
    when(base.getPrefixForNamespaceURI(Mockito.<String>any())).thenReturn(Optional.empty());
    register.beforeMarshal(base, qmap);
    verify(qmap).registerMapping(qNameCaptor.capture(), eq(COMPONENTS_WIDTHS_EXTENSION_ALIAS));
    final QName qName1 = qNameCaptor.getValue();
    assertThat(qName1.getNamespaceURI()).isEqualTo(KIE.getUri());
    assertThat(qName1.getLocalPart()).isEqualTo(COMPONENTS_WIDTHS_EXTENSION_ALIAS);
    assertThat(qName1.getPrefix()).isEqualTo(KIE.getPrefix());
    verify(qmap).registerMapping(qNameCaptor.capture(), eq(COMPONENT_WIDTHS_ALIAS));
    final QName qName2 = qNameCaptor.getValue();
    assertThat(qName2.getNamespaceURI()).isEqualTo(KIE.getUri());
    assertThat(qName2.getLocalPart()).isEqualTo(COMPONENT_WIDTHS_ALIAS);
    assertThat(qName2.getPrefix()).isEqualTo(KIE.getPrefix());
    verify(qmap).registerMapping(qNameCaptor.capture(), eq(COMPONENT_WIDTH_ALIAS));
    final QName qName3 = qNameCaptor.getValue();
    assertThat(qName3.getNamespaceURI()).isEqualTo(KIE.getUri());
    assertThat(qName3.getLocalPart()).isEqualTo(COMPONENT_WIDTH_ALIAS);
    assertThat(qName3.getPrefix()).isEqualTo(KIE.getPrefix());
    verify(qmap).registerMapping(qNameCaptor.capture(), eq(EXTERNAL_LINK_ALIAS));
    final QName qName4 = qNameCaptor.getValue();
    assertThat(qName4.getNamespaceURI()).isEqualTo(KIE.getUri());
    assertThat(qName4.getLocalPart()).isEqualTo(EXTERNAL_LINK_ALIAS);
    assertThat(qName4.getPrefix()).isEqualTo(KIE.getPrefix());
}
Also used : QName(javax.xml.namespace.QName) DMNModelInstrumentedBase(org.kie.dmn.model.api.DMNModelInstrumentedBase) Test(org.junit.Test)

Example 22 with DMNModelInstrumentedBase

use of org.kie.dmn.model.api.DMNModelInstrumentedBase in project kie-wb-common by kiegroup.

the class QNamePropertyConverterTest method testGetDefaultNamespaceFromParent.

@Test
public void testGetDefaultNamespaceFromParent() {
    final String defaultNamespace = "http://www.kiegroup.org/";
    final TDefinitions definition = mock(TDefinitions.class);
    final DMNModelInstrumentedBase model = mock(DMNModelInstrumentedBase.class);
    when(model.getParent()).thenReturn(definition);
    when(definition.getNamespace()).thenReturn(defaultNamespace);
    final String actual = QNamePropertyConverter.getDefaultNamespace(model);
    assertEquals(defaultNamespace, actual);
}
Also used : DMNModelInstrumentedBase(org.kie.dmn.model.api.DMNModelInstrumentedBase) TDefinitions(org.kie.dmn.model.v1_1.TDefinitions) Test(org.junit.Test)

Aggregations

DMNModelInstrumentedBase (org.kie.dmn.model.api.DMNModelInstrumentedBase)22 CannotResolveClassException (com.thoughtworks.xstream.mapper.CannotResolveClassException)6 ArrayList (java.util.ArrayList)6 QName (javax.xml.namespace.QName)6 Reader (java.io.Reader)5 StringReader (java.io.StringReader)5 List (java.util.List)5 Definitions (org.kie.dmn.model.api.Definitions)5 KieDMNModelInstrumentedBase (org.kie.dmn.model.v1_2.KieDMNModelInstrumentedBase)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 XStream (com.thoughtworks.xstream.XStream)4 AbstractPullReader (com.thoughtworks.xstream.io.xml.AbstractPullReader)4 QNameMap (com.thoughtworks.xstream.io.xml.QNameMap)4 StaxDriver (com.thoughtworks.xstream.io.xml.StaxDriver)4 StaxWriter (com.thoughtworks.xstream.io.xml.StaxWriter)4 TypeHierarchyPermission (com.thoughtworks.xstream.security.TypeHierarchyPermission)4 StringWriter (java.io.StringWriter)4 Writer (java.io.Writer)4 Map (java.util.Map)4