### Question:
DefinitionsConverter { public static org.kie.dmn.model.api.Definitions dmnFromWB(final Definitions wb) { if (wb == null) { return null; } final org.kie.dmn.model.api.Definitions result = new org.kie.dmn.model.v1_2.TDefinitions(); final String defaultId = (wb.getId() != null) ? wb.getId().getValue() : UUID.uuid(); final String defaultName = (wb.getName() != null) ? wb.getName().getValue() : UUID.uuid(8); final String defaultNamespace = !StringUtils.isEmpty(wb.getNamespace().getValue()) ? wb.getNamespace().getValue() : DMNModelInstrumentedBase.Namespace.DEFAULT.getUri() + UUID.uuid(); result.setId(defaultId); result.setName(defaultName); result.setNamespace(defaultNamespace); result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription())); result.getNsContext().putAll(wb.getNsContext()); result.getNsContext().putIfAbsent(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix(), defaultNamespace); for (ItemDefinition itemDef : wb.getItemDefinition()) { final org.kie.dmn.model.api.ItemDefinition itemDefConverted = ItemDefinitionPropertyConverter.dmnFromWB(itemDef); if (itemDefConverted != null) { itemDefConverted.setParent(result); } result.getItemDefinition().add(itemDefConverted); } for (Import i : wb.getImport()) { final org.kie.dmn.model.api.Import importConverted = ImportConverter.dmnFromWb(i); if (importConverted != null) { importConverted.setParent(result); } result.getImport().add(importConverted); } return result; }  static Definitions wbFromDMN(final org.kie.dmn.model.api.Definitions dmn,
                                        final Map<org.kie.dmn.model.api.Import, org.kie.dmn.model.api.Definitions> importDefinitions,
                                        final Map<org.kie.dmn.model.api.Import, PMMLDocumentMetadata> pmmlDocuments); static org.kie.dmn.model.api.Definitions dmnFromWB(final Definitions wb);  }### Answer:
@Test public void dmnFromWB() { when(wbDefinitions.getNamespace()).thenReturn(new Text()); org.kie.dmn.model.api.Definitions dmn = DefinitionsConverter.dmnFromWB(wbDefinitions); String defaultNs = dmn.getNsContext().get(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix()); String namespace = dmn.getNamespace(); assertNotNull(defaultNs); assertEquals(defaultNs, namespace); when(wbDefinitions.getNamespace()).thenReturn(new Text(NAMESPACE)); dmn = DefinitionsConverter.dmnFromWB(wbDefinitions); defaultNs = dmn.getNsContext().get(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix()); namespace = dmn.getNamespace(); assertNotNull(defaultNs); assertEquals(defaultNs, namespace); assertEquals(NAMESPACE, defaultNs); }
@Test public void testDmnFromWBWithExistingDefaultNamespace() { final Map<String, String> existingNsContext = new HashMap<>(); final String existing = "existing"; existingNsContext.put(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix(), existing); when(wbDefinitions.getNamespace()).thenReturn(new Text()); when(wbDefinitions.getNsContext()).thenReturn(existingNsContext); org.kie.dmn.model.api.Definitions dmn = DefinitionsConverter.dmnFromWB(wbDefinitions); String defaultNs = dmn.getNsContext().get(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix()); assertNotNull(defaultNs); assertEquals(existing, defaultNs); when(wbDefinitions.getNamespace()).thenReturn(new Text(NAMESPACE)); dmn = DefinitionsConverter.dmnFromWB(wbDefinitions); defaultNs = dmn.getNsContext().get(DMNModelInstrumentedBase.Namespace.DEFAULT.getPrefix()); assertNotNull(defaultNs); assertEquals(existing, defaultNs); }