### Question:
DMNDIExtensionsRegister implements DMNExtensionRegister { @Override public void beforeMarshal(final Object o, final QNameMap qmap) { if (o instanceof TDefinitions) { final TDefinitions tDefinitions = (TDefinitions) o; final String prefix = tDefinitions.getPrefixForNamespaceURI(KieDMNModelInstrumentedBase.URI_KIE).orElse(KIE.getPrefix()); qmap.registerMapping(new QName(KIE.getUri(), COMPONENTS_WIDTHS_EXTENSION_ALIAS, prefix), COMPONENTS_WIDTHS_EXTENSION_ALIAS); qmap.registerMapping(new QName(KIE.getUri(), COMPONENT_WIDTHS_ALIAS, prefix), COMPONENT_WIDTHS_ALIAS); qmap.registerMapping(new QName(KIE.getUri(), COMPONENT_WIDTH_ALIAS, prefix), COMPONENT_WIDTH_ALIAS); qmap.registerMapping(new QName(KIE.getUri(), EXTERNAL_LINK_ALIAS, prefix), EXTERNAL_LINK_ALIAS); } }  @Override void registerExtensionConverters(final XStream xStream); @Override void beforeMarshal(final Object o,
                              final QNameMap qmap);  }### Answer:
@Test public void testBeforeMarshal() { final DMNModelInstrumentedBase base = mock(TDefinitions.class); when(base.getPrefixForNamespaceURI(anyString())).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()); }